Solution
= Solution
Write $r_1=(x_1,y_1)$, $r_2=(x_2,y_2)$,
$\rho_1=|r_1|$, and $\rho_2=|r_2-r_1|$. Then
$$
L=\frac{m_1}2|\dot r_1|^2+\frac{m_2}2|\dot r_2|^2
-\frac{k_1}2(\rho_1-\ell)^2-\frac{k_2}2(\rho_2-\ell)^2
-m_1gy_1-m_2gy_2.
$$
With $e_y=(0,1)$, the Euler--Lagrange equations are
$$
m_1\ddot r_1
=-k_1\left(1-\frac{\ell}{\rho_1}\right)r_1
+k_2\left(1-\frac{\ell}{\rho_2}\right)(r_2-r_1)-m_1ge_y,
$$
$$
m_2\ddot r_2
=-k_2\left(1-\frac{\ell}{\rho_2}\right)(r_2-r_1)-m_2ge_y.
$$