A mass material point is bound to move (without friction) on a guide located in a vertical plane. The guide has equation: $$y=x^2$$
In addition to the weight force there is an elastic force centered at the coordinate point (1.0).I want to write the Lagrangian.
$$T= \frac{m}{2}\left(\dot{x}^2+\dot{y}^2\right )=\frac{m}{2}\left((1+4x^2) \right )\dot{x}^2$$
$$U=\frac{1}{2}k\overrightarrow{PQ}+ mgy$$
$$L=T-U$$
$$\overrightarrow{PQ}=\sqrt{(x-1)^2+(x-1)^4}$$
$$L=\frac{m}{2}\left((1+4x^2) \right )\dot{x}^2-\frac{1}{2}k(x-1)^2((x-1)^2+1)-mgx^2$$
The result is wrong but I do not understand where the error is, since the problem seems pretty simple, I'm sure it has made a stupid mistake.
Thank you!
$$ \begin{align} T&= \frac{m}{2}\left(\dot{x}^2+\dot{y}^2\right )=\frac{m}{2}\dot{x}^2\left(1+4x^2 \right )\\ U&=\frac{1}{2}k\,r^2+ mgy\\ r^2&=\Big\lVert\overrightarrow{PQ}\Big\rVert^2=(x-1)^2+y^2=(x-1)^2+x^4\\ L&=T-U=\frac{m}{2}\dot{x}^2\left(1+4x^2 \right )-\frac{1}{2}k\left((x-1)^2+x^4\right)+ mgx^2 \end{align} $$