Lagrangian equation for a force applied to symmetric configuration consisting of two masses. Each mass connected to a spring

This is the configuration for which I have to write system dynamics.

Lagrangian question

This is my attempt:

T = $$\frac{1}{2}m\left(\dot{x}^2\right) + \frac{1}{2}m\left(\dot{x}^2\right)$$

U = $$\frac{1}{2}k(x\cos(\theta))^2 + \frac{1}{2}k(x\cos(\theta))^2 - \frac{1}{2}mgL\sin(\theta) - \frac{1}{2}mgL\sin(\theta)$$

Is my Lagrangian correct? I am assuming that both springs are displaced by a distance x from their undeformed position

Edit: I went back and tried a new approach. This time I assigned coordinates to the midpoint of both masses with respect to the middle point of the configuration. Then I use those coordinates (in terms of the angle theta) and the extension of the springs from the undeformed position (denoted as x) to compute the kinetic and potential energy

second attempt

• This is physics, not mathematics. Only self gratification here. – copper.hat Jul 1 at 20:17

Hint.

Here we have an one dimensional dynamic system that can be modeled according to

$$T = 2\left(\frac 12\dot x^2+\frac 12 J\dot\theta^2\right)\\ V = 2\left(\frac 12 k x^2\right)+2L m g\sin\theta$$

where $$J$$ is the inertia moment for bar $$L$$ regarding the mass center and also

$$y=L\sin\theta\\ x=L\cos\theta\\ \dot y = L\cos\theta\dot\theta\\ \dot x = -L\sin\theta\dot\theta$$

now with $$L = T-V$$ we have

$$\frac{d}{dt}\left(\frac{\partial L}{\partial\dot\theta}\right)-\frac{\partial L}{\partial\theta} = \frac{\partial W}{\partial\theta} = \frac{\partial( F y)}{\partial\theta} = L F \cos\theta$$