Solution (source code)

= Solution

Each <simple pendulum> moves in the vertical plane containing the pivots. Ignoring contact between the ideal rods and <point masses>, each rod can turn through a full <circle>. Thus the <configuration space> is the <torus>
$$
\boxed{\mathcal Q=S^1\times S^1.}
$$
Choose <generalized coordinates> $\theta_1,\theta_2$, measured from the downward vertical, positive towards the right and understood modulo $2\pi$. These <angles> are local coordinates on the <torus>, rather than a single globally one-to-one real <coordinate chart>. With upward Cartesian coordinate $y$, the bob <positions> are
$$
\mathbf r_1=(l\sin\theta_1,-l\cos\theta_1),\qquad
\mathbf r_2=(r+l\sin\theta_2,-l\cos\theta_2).
$$
Their <velocities> satisfy $|\dot{\mathbf r}_j|^2=l^2\dot\theta_j^2$, so <kinetic energy from Cartesian position vectors> gives
$$
T=\frac{ml^2}{2}(\dot\theta_1^2+\dot\theta_2^2).
$$
The <spring> length is the <Euclidean distance>
$$
d=|\mathbf r_2-\mathbf r_1|
=\sqrt{\bigl(r+l(\sin\theta_2-\sin\theta_1)\bigr)^2+l^2(\cos\theta_2-\cos\theta_1)^2}.
$$
Taking gravitational <potential energy> zero at pivot height gives $V_g=-mgl(\cos\theta_1+\cos\theta_2)$. The <spring> <potential energy> is $V_s=k(d-r)^2/2$, since $r$ is its natural length. Consequently the <Lagrangian> is
$$
\boxed{L=T-V_g-V_s
=\frac{ml^2}{2}(\dot\theta_1^2+\dot\theta_2^2)
+mgl(\cos\theta_1+\cos\theta_2)-\frac{k}{2}(d-r)^2.}
$$
In the paper's notation $t(\theta_1,\theta_2)=V_s$; this function is distinct from the time variable. This is the <exact Lagrangian of two spring-coupled pendulums>.

One alternative <Lagrangian> is
$$
\boxed{\widetilde L=L-2mgl.}
$$
It corresponds to setting gravitational <potential energy> zero at the downward position. The constant disappears from every <Euler-Lagrange equation>. More generally, <total-time-derivative invariance of a Lagrangian> allows $\widetilde L=L+dF(\theta_1,\theta_2,t)/dt$ for any smooth $F$.