# How to derive lagrangian for any classical system?

Tags:
1. Oct 8, 2014

### Alexandre

Suppose I come up with a system that has certain number of particles with certain masses and are interconnected between each other in a certain way and are acted by forces which are also part of the system. What's the general rule for finding potential and kinetic energies as functions of coordinates and their derivatives? I don't expect the answer to be as simple to put it out here in comment section but maybe you could point me to some textbook or a video that explains that in full detail?

2. Oct 8, 2014

### stevendaryl

Staff Emeritus
As far as I know, there is no rule for deriving the Lagrangian. Instead, one guesses the Lagrangian based on the sort of particles and fields you expect to have.

In nonrelativistic single-particle physics, the ingredients that you have to play around with are scalars, vectors and tensors:
1. The velocity vector $\vec{v}$
2. The electromagnetic vector potential $\vec{A}$
3. The electromagnetic scalar potential $\phi$
4. The electromagnetic field tensor, with components $\vec{E}$ and $\vec{B}$
Then you go through the possible ways to combine these to get a scalar (a Lagrangian has to be a scalar). The simplest Lagrangian that leads to interesting dynamics is:

$L = \frac{m}{2} |v|^2 - q \vec{v} \cdot \vec{A} - q \phi$

But you could certainly add more fields, or more complicated interactions between fields and particles. There is no rule other than the fact the result needs to be a scalar.

3. Oct 8, 2014

### Alexandre

Hmm interesting, thanks for the reply! I understand that now but what if there are many particles and they are not free but instead are bonded by either elastic or rigid rods to each other and/or to the ground/ceiling/wall. Are there any textbook examples for those kind of problems? Any useful tricks? How to chose generalized coordinates (cartesian, polar or any other coordinates) and so forth....

4. Oct 8, 2014

### stevendaryl

Staff Emeritus
Well, for most such problems, the Lagrangian can just be written as $KE - PE$ where $KE$ is the kinetic energy, and $PE$ is the potential energy. The form of the kinetic energy changes, depending on whether you are using cartesian coordinates, or not. The potential energy for such problems usually involves two types of potential: (1) gravitational (or electrical, which is similar), (2) harmonic oscillator, the potential of a spring. It can be a little complicated to figure out the kinetic energy and potential energy for extended objects (such as rods and blocks and ropes and so forth).

Another wrinkle is that often such problems involve constraints. That is, some object is constrained to move in a circle (on tracks), or something like that. Problems with constraints are typically not solved by trying to figure out the forces or the potentials, but instead are solved using the method of Lagrange multipliers. The general idea is this: Suppose you have a problem involving coordinates $x$ and $y$ and you are constrained so that $x^2 + y^2 = R^2$ (so the motion is confined to a circle). Then one approach is this: If $x$ and $y$ are constrained so that $F(x,y) =$ a constant, then let $L_0$ be the lagrangian that you would have without the constraint. Then you create a new Lagrangian: $L = L_0 - \lambda F(x,y)$ where $\lambda$ is some unspecified constant. So this is like a new potential energy term to the Lagrangian, although the magnitude is unknown. If you solve the Lagrangian equations of motion using this potential energy term, you'll get equations of motion that might involve $\lambda$. But then afterwards, $\lambda$ can be eliminated by imposing the constraint that $F(x,y) =$ whatever.

5. Oct 9, 2014

### Alexandre

Well, I've actually tried solving this and added potential energy due to gravity along y axes ($mgy$), Lagrangian I've got is:

$L=\frac{m}{2}(ẋ²+ẏ²)-mgy-\lambda(x²+y²)$

I've solved the equations and It turns out $\lambda$ should equal to mass, otherwise I get Lissajous curve shaped trajectory which makes no sense. The problem I have is that the trajectory is not always a circle, most of the times it's an ellipse. Here you can check the animated solution and play around with it:

https://www.desmos.com/calculator/pm3uuxqoif
(L≡lambda)

My guess is that initial position and velocity along both axis should be somehow restricted to satisfy my confinements. The obvious restriction is that initial position should not be greater than the radius of the circle and probably initial velocity should be a cosine of initial position. But that doesn't seem to be enough, I'm still getting an ellipse and the weirder thing is that changing free fall acceleration g also has an effect on the trajectory. What am I getting wrong? Do I have to think through all of these details every time I'm using $L = L_0 - \lambda F(x,y)$ formula?

P.S.

One more restriction I figured out is y initial should be equal to plus or minus square root of $1-x_0²$ (where x0 is x component of initial position) because initial point should lay on the circle. But there should be more restrictions because I'm getting ellipses anyway. And it seems to me that this system should be equivalent to mathematical pendulum with a rigid rod but what I'm getting is far from that.

Last edited: Oct 9, 2014
6. Oct 10, 2014

### vanhees71

The Lagrangian you wrote down is the Lagrangian for a particle that moves in a plane and is subject to the constant gravitational force (an approximation valid close to the surface of the earth) and a harmonic-oscillator potential. The harmonic potential reads in physical terms
$$V_{\text{osc}}=\frac{m \omega^2}{2} (x^2+y^2).$$
The total potential is
$$V=\frac{m \omega^2}{2} (x^2+y^2)+mg y = \frac{m \omega^2}{2} x^2 + \frac{m \omega^2}{2} \left (y+\frac{g}{2 \omega^2} \right )^2 - \frac{m g^2}{8 \omega^2}.$$
Introducing the new coordinate $y'=y+\frac{g}{2 \omega^2}$ and dropping the irrelevant constant in the potential you get the corresponding new Lagrangian
$$L=\frac{m}{2} (\dot{x}^2+\dot{y}{}^2) - \frac{m \omega^2}{2} (x^2+y'{}^2).$$
$$\ddot{x}=-\omega^2 x, \quad \ddot{y}=-\omega^2 y.$$
The solutions are
$$x(t)=x_0 \cos(\omega t) +\frac{\dot{x}_0}{\omega} \sin(\omega t),$$
$$y'(t)=y_0' \cos(\omega t) + \frac{\dot{y}_0'}{\omega} \sin(\omega t).$$
The trajectory is an ellipse.

I do not understand your animations.

7. Oct 10, 2014

### Alexandre

If that Lagrangian which I constructed has an oscillator (and I think it has) than what stevendaryl said is not quite correct:
I should look up Lagrange multipliers on google to understand how they work.... And I think I've spotted an error here:

If you calculate backwards you get extra 2 in denominator of gravitational potential

$$\frac{m \omega^2}{2} x^2 + \frac{m \omega^2}{2} \left (y+\frac{g}{2 \omega^2} \right )^2 - \frac{m g^2}{8 \omega^2} = \frac{m \omega^2}{2} x^2 + \frac{m \omega^2}{2} \left (y^2+\frac{gy}{ \omega^2} + \frac{g^2}{4 \omega^4} \right ) - \frac{m g^2}{8 \omega^2}$$

$$\frac{m \omega^2}{2} x^2 + \frac{m \omega^2}{2}y^2+\frac{mg}{2}y + \frac{mg^2}{8 \omega^2} - \frac{m g^2}{8 \omega^2} = \frac{m \omega^2}{2} \left (x^2 + y^2 \right)+\frac{mg}{2}y$$

8. Oct 11, 2014

### stevendaryl

Staff Emeritus
That is certainly correct. However, according to http://en.wikipedia.org/wiki/Lagrangian_mechanics#Lagrange_equations_of_the_first_kind,
it is the way to incorporate the constraint $x^2+y^2 = R^2$ into the Lagrangian. However, I really don't see that the following two approaches are equivalent, in this example:

1. Use polar coordinates, and use the Lagrangian: $1/2 m R^2 \dot{\theta}^2 - m g R sin(\theta)$
2. Use rectangular coordinates, and use the Lagrangian $1/2 m (\dot{x}^2 + \dot{y}^2) - m g y - \lambda (x^2 + y^2)$

With the latter approach, $\lambda$ has to be chosen so that there is no motion in the radial direction.

As I said, it's not completely clear to me that these approaches give the same result.

9. Oct 12, 2014

### vanhees71

I see. Then I was mistaken, because I've not seen that you want to solve a system with constraints. As you correctly say, you can solve this holonomous contraint
$$f(x,y)=0$$
by introducing an auxiliary function in the sense of a Lagrange parameter. Varying the action wrt. this parameter should give the constraint. In our case the Lagrangian should then read
$$L=\frac{m}{2} (\dot{x}^2+\dot{y}^2) - m g y - \frac{\lambda}{2}(x^2+y^2-R^2).$$
I introduced the additional factor 1/2 for convenience, but it's important to put the $-R^2$ term in.

Now the equations of motion are given by the Euler-Lagrange equations of the variational principle under independent variations of $x$, $y$, $\lambda$:
$$m \ddot{x}=-\lambda x,$$
$$m \ddot{y}=-\lambda y - mg,$$
$$x^2+y^2-R^2=0.$$
It's clear from this equation that the terms in the first two equation involving $\lambda$ provide the force centripetal necessary to fulfill the constraint, i.e., to keep the particle on a circle.

It's clear that it's way easier to solve the problem by introducing the angle. It's a bit more convenient to count it from the minimum of the potential, i.e.,
$$x=R \sin \varphi, \quad y=-R \cos \varphi.$$
$$L=\frac{m R^2}{2} \dot{\varphi}^2+m g R \cos \varphi.$$
The term with the Lagrange parameter now is automatically eliminated, because the constraint is fulfilled by parametrizing via the introduction generalized coordinate.

The equation of motion then reads
$$m R^2 \ddot{\varphi}=-m g R \sin \varphi.$$
This is the equation of a mathematical pendulum as it must be, and now also the animation quoted in the posting above makes sense!

10. Nov 14, 2014

### pawan singh

please lagrangian for a particle of mass m is connected between two spring of constants k1& k2