# Lagrangian for 2 masses connected by a spring

I've been working on this problem for a while now and I'm stuck on getting the Lagrange equations of motion from the Lagrangian. I have the Lagrangian as $L= m(x'^2 + y'^2)/2 - (k/2) (y-x-l)^2$ and I think I have the $δL/δx$ & $δL/δy$ but I can't figure out how to get $dL/dx$ and $dL/dy$ now. Qny help is much appreciated!

• Is one of the masses attached to a fixed wall by a spring and a spring connecting the two masses? Jan 7, 2015 at 1:16

With

$$L = \frac{1}{2}m(\dot{x}^2+\dot{y}^2) - \frac{1}{2}k(y-x-l)^2$$

we have

$$\frac{\partial L}{\partial\dot{x}} = m\dot{x},~~~~\frac{\partial L}{\partial x} = k(y-x-l)$$ $$\frac{\partial L}{\partial\dot{y}} = m\dot{y},~~~~\frac{\partial L}{\partial y} = -k(y-x-l)$$

Note that we treat $x$ and $\dot{x}$ (and $y$ and $\dot{y}$) as independent variables so $\frac{\partial x}{\partial \dot{x}} = 0 = \frac{\partial \dot{x}}{\partial x}$ and also $\frac{\partial y}{\partial x} = \frac{\partial y}{\partial \dot{x}} = 0$ etc. This gives the two Euler-Lagrange equations

$$\frac{\partial L}{\partial x} - \frac{d}{dt}\frac{\partial L}{\partial\dot{x}} = k(y-x-l) - m\ddot{x} = 0$$

$$\frac{\partial L}{\partial y} - \frac{d}{dt}\frac{\partial L}{\partial\dot{y}} = -k(y-x-l) - m\ddot{y} = 0$$

I think you want

$$L = \frac12 m (\dot{x}^2+\dot{y}^2) - \frac12 k (x-y)^2$$

Then

$$\frac{\partial L}{\partial x} - \frac{d}{dt} \frac{\partial L}{\partial \dot{x}} = 0 \implies m \ddot{x}=-k (x-y)$$

$$\frac{\partial L}{\partial y} - \frac{d}{dt} \frac{\partial L}{\partial \dot{y}} = 0 \implies m \ddot{y}=k (x-y)$$

Subtracting, and defining $u=x-y$, we get

$$\ddot{u} + \frac{2 k}{m} u = 0$$

Hopefully you can take it from here.

• The spring has a length $l$ when not stetched therefore we have the $l$ in the potential energy term ($(y-x-l)^2$). Jan 7, 2015 at 1:22
• @Winther: Depends on how you define the coordinates. I define them as a change in displacement of the string from either end. Thus, the length plays no part. Defined otherwise, it might. Jan 7, 2015 at 1:26
• I agree that $l$ can be easily be removed by a change of coordinates, but imo this should be stated as OP has a different formulation and it can cause confusion. Anyway, now its in the comments anyway:) Jan 7, 2015 at 1:31
• I'm having trouble understanding the first term: $\frac{1}{2}m(\dot x^2+\dot y^2)$. Is it the KE of the oscillatory motion of both masses? Dec 10, 2016 at 6:10