I need some help with this problem.
A particle of mass $m_1$ hangs from a rod of negligible mass and length $l$, whose support point consists of another particle of mass $m_2$ that moves horizontally subject to two springs of constant $k$ each one. Find the equations of motion for this system.
What I first did was setting the reference system on the left corner. Then, I said that the position of the mass $m_2$ is $x_2$. I also supposed that the pendulum makes an angle $\theta$ with respect to the vertical axis $y$. So the generalized coordinates of the system would be $x_2$ and $\theta$. Thus, the coordinates of $m_1$ are:
$$x_1=x_2+l\sin\theta$$ $$y_1=-l\cos\theta$$ Then I took the time derivative of both $x_1$ and $y_1$:
$$\dot x_1=\dot x_2+l\dot\theta\cos\theta$$ $$\dot y_1=l\dot\theta\sin\theta$$ The Kinetic energy $T$ would be the sum of the kinetic energy of each mass $T=T_1+T_2$. Since $T1=\frac{1}{2}m_2\dot x_2^2$ and $T_2=\frac{1}{2}m_1(\dot x_1^2+\dot y_1^2)$, I got:
$$T=\frac{1}{2}m_2\dot x_2^2+\frac{1}{2}m_1(\dot x_2^2+l^2\dot\theta^2+2\dot x_2\dot\theta l)$$ Now, I have trouble with the potential energy. The potential energy of $m_1$ is easy, it would be just $V_1=m_1gh$:
$$V_1=-m_1gl\cos\theta$$ The potential energy of $m_2$ would be the sum of the potential energy that each spring has on the mass. What I did was saying that that the mass $m_2$ moves a distance $x_2$, thus the lhs spring would have a displacement of $x_2$ and the rhs spring would have a contraction of $x_2$ likewise. So:
$$V_2=\frac{1}{2}k x_2^2+\frac{1}{2}k(-x_2)^2=kx_2^2$$ But, according to my teacher, if the first spring moves a distance $x_2$, then the second would contract a distance of $a-x_2$, where $a$ is the distance between the walls, which is constant. I don't understand why this is the case, can you please explain it better for me to understand? After that, all I need to do is find the Lagrangian $L=T-V$ and find the equation of motion.