# Potential Energy in modified Atwood Machine

The initial length of the spring is $l_0$.

I need help understanding how the potential energy of this system comes to be. I know the answer:

$$U = -(m_1-m_2)gx-(m_1+m_2)gy+\frac{1}{2}k(y-l_0)^2+U_0$$

I understand that the term: $\frac{1}{2}k(y-l_0)^2$ is the potential energy of the spring and I know how that comes to be. And I guess that the terms $-(m_1-m_2)gx$ and $-(m_1+m_2)gy$ are the potential energies due to gravity? But where does $U_0$ come from?

• Are you aware that one can always add a constant $U_0$ without changing the physics? – ACuriousMind Mar 28 '15 at 13:42
• Hmm..that makes sense, thanks. But I still don't know how the terms from the potential energy from gravity comes to be. – Nillo Mar 28 '15 at 13:44

In your case $U_0$ is just a constant that one can add or subtract freely. You can assume that system had an initial constant potential energy (independent of your generalized coordinates of course) just before you started to examine it.
Because of the vertical motion of the pulley itself you have the term $(m_1 + m_2)gy$. Also, when one of the masses moves downwards, other one should move upwards (Here I assume they are connected with a rope of fixed length). That gives you the other term with a minus sign between masses, i.e; $(m_1 - m_2)gx$.