# Struggling to follow a differential equation

Suppose we have a differential equation of the from

$L = \frac{1}{2}((I_1 + I_2 + m_1r_1^2 + m_2q_2^2)\dot{q}_1^2 + m_2\dot{q}_2^2) - a_g(m_1r_1 + m_2q_2) \sin q_1$.

and we want to find $g = \frac{\operatorname{d}}{\operatorname{d}t} \frac{\partial L}{\partial \dot q_1}$, and $h = \frac{\partial L}{\partial q_1}$.

For the first term I get $g = (I_1 + I_2 + m_1r_1^2 + m_2q_2^2)\ddot{q}_1$ which I'm pretty sure is correct. However, I believe the second term should be $h = 2m_2q_2\dot{q_1}\dot{q_2} + a_g(m_1r_1 + m_2q_2) \cos q_1$. I see where the cosine term appears from, but not $2m_2q_2\dot{q_1}\dot{q_2}$. Can anybody help me out?

-
I'm not so sure about your $g$, since $\frac{d}{dt}q_2^2\dot q_1 = 2\dot q_2 q_2\dot q_1 + q_2^2 \ddot q_1$. I think. – Myself Apr 20 '11 at 17:45
@Myself: You're missing a $q_2$ in the first term. – joriki Apr 20 '11 at 17:49
@Joriki: right, thanks! I made an edit to avoid confusion. – Myself Apr 20 '11 at 17:50

The term $2m_2q_2\dot{q_1}\dot{q_2}$ that you're missing doesn't come from $h$ but from $g$ -- you forgot to take into account the variation of $q_2$ with time:
$$\frac{\mathrm d}{\mathrm d t}m_2q_2^2\dot{q_1}=m_2q_2^2\ddot{q_1}+2m_2q_2\dot{q_1}\dot{q_2}\;.$$