# The Lagrangian for gravitational potential energy in a double pendulum

For a double pendulum what would be the gravitational energy. I am trying to work out the Lagrangian for the double pendulum. I got the kinetic energy but I am struggling on the gravitational potential energy.

I tried calculating the gravitational: $$V = g(m_1+m_2)(l_1+l_2-l_1\cos\theta_1) - gm_2(l_2\cos\theta_2)$$ but on wolfram it uses a different equation. Am I wrong?

Your expression differs from ScienceWorld's expression by a constant (namely, $$g(m_1 + m_2)(l_1 + l_2)$$.) Since you can always add or subtract a constant from the potential energy without changing the physics, your expression and ScienceWorld's expression are equivalent.
The expression for the potential energy is given by $$V_{tot}=V_1+V_2$$ where $$V_1=m_1 g y_1$$ and $$V_2=m_2 g y_2$$. The $$y$$-coordinate for the first mass is $$y_1=-l_1 \cos(\theta)$$ and for the second mass $$y_2=-(l_2 \cos(\theta)+l_1 \cos(\theta))$$.
Then the expression for the total potential energy is: $$V_{tot}= -m_1 l_1 \cos(\theta)-m_2(l_2 \cos(\theta)+l_1 \cos(\theta))$$.