= Solution
Take $x$ positive downward and put zero gravitational <potential energy> at the spring's support. The mass is then a distance $l+x$ below that reference, so $V_g=-mg(l+x)$. <Hooke's law> gives the elastic <potential energy> $kx^2/2$. Therefore
$$
\boxed{L=\frac12m\dot x^2-\frac12kx^2+mg(l+x).}
$$
The constant term $mgl$ fixes the requested reference but does not affect the motion. The <Euler-Lagrange equation> is
$$
\frac{d}{dt}(m\dot x)-(-kx+mg)=0,
\qquad
\boxed{m\ddot x=mg-kx.}
$$
This is exactly <Newton's second law> with gravity downward and spring <force> $kx$ upward for positive extension. The static extension is $x_0=mg/k$.
Back to article page