I have some doubt about a really trivial and simple problem in which I have to use ELE.
Supposing I have a pendulum, in which the rope is a spring, so it's length may change in time. I have a mass M and the spring rest length is $\ell$. I have to find the Lagrangian of the system, and the equations of motions.
Then I start finding $\mathcal{L} = T - V$
$$T = \frac{1}{2}m v^2$$
and to find $v$, remembering that $v^2 = \dot{x}^2 + \dot{y}^2$ I simply perform a change of coordinates with
$$x = \ell\cos\theta$$ $$y = \ell\sin\theta$$
and I'll get
$$v^2 = \dot{\ell}^2 + \ell^2\dot{\theta}^2$$
which leads me to have the kinetic energy $$T = \frac{1}{2}m\left(\dot{\ell}^2 + \ell^2\dot{\theta}^2\right)$$
Hope it's fine until here
Then The first problem: the potential $V$. I know that for a pendulum I can use $V = mg\ell\cos\theta$ but considering the rope is a spring, should I add to that term the elastic recall force $kx = k\ell\cos\theta$?
This would mean
$$V = (mg - k)\ell\cos\theta$$
but now a problem arises: $(mg - k)$ cannot be calculated because dimensions of $mg$ isn't the same of $k$ so where am I wrong?
EDIT AFTER FIRST ANSWER - UNDERSTOOD THIS I was using a Force, whilst I had to use, of course, the potential $\frac{1}{2}kx^2$
The potential then becomes
$$V = mg\ell\cos\theta - \frac{1}{2}k\ell^2\cos^2\theta$$
Continuing
After finding out what $V$ is, I get $\mathcal{L} = T - V$ so I'm ready for ELE:
$$\frac{\partial \mathcal{L}}{\partial \dot{q}_i} - \frac{d}{dt}\frac{\partial\mathcal{L}}{\partial q_i} = 0$$
I know we have Einstein convention about the $i$-index so here arises another problem: my generalized coordinates will be $q_1 = \ell$ and $q_2 = \theta$.
How will Euler-Lagrange equations be written? Will I have two coupled equations or one single chaotic equation?
ELE
So I cam up with those Euler-Lagrange equations. Taking into account the comment below, I don't really know if it's good to name $\ell = l - l_0$. Anyway, those should be the equations. Are they correct?
$$m\ell^2\dot{\theta} = \frac{\text{d}}{\text{d}t}\left(\left[mg - \frac{k}{2}\ell\right]\ell\sin\theta\right) = 0$$
$$m\dot{\ell} = \frac{\text{d}}{\text{d}t}\left(m\ell\dot{\theta}^2 - mg\cos\theta + k\ell\cos\theta\right)$$