# Confusion regarding the time derivative term in Lagrange's equation

I am solving a pendulum attached to a cart problem. Without going into unnecessary details, the generalised coordinates are chosen to be $$x$$ and $$\theta$$. The kinetic energy of the system contains a term (which contains) $$\dot x\dot\theta\cos\theta$$. Now when evaluating $$\frac{\mathrm d}{\mathrm dt}(\frac{\partial T}{\partial\dot\theta})$$ for this term, should the answer be just $$\ddot x\cos\theta$$ or $$\ddot x\cos\theta-\dot x\dot\theta\sin\theta$$? The former gives the correct equation of motion but I am not able to understand why it is not the latter, because $$\theta$$ also varies with time. I have checked that my kinetic energy expression is correct.

EDIT: To make the question clearer, I do not have a doubt in the fact that $$\frac{\partial}{\partial\dot\theta}(\dot x\dot\theta\cos\theta)=\dot x\cos\theta$$ My doubt is what is $$\frac{\mathrm d}{\mathrm dt}(\dot x\cos\theta)$$ equal to, more particularly, do we use the product rule to evaluate it or not? Because the correct answer seems to come about without using the product rule but that would mean assuming $$\theta$$ does not depend on time. Where am I wrong?

• Possible duplicates: physics.stackexchange.com/q/885/2451 and links therein. Apr 25 '20 at 11:00
• @Qmechanic, PM 2Ring I have edited my question to make what I am asking clearer. Apr 25 '20 at 11:49

By the looks of it you are trying to solve the "inverted pendulum above a cart problem".

You are just making an algebraic mistake. $$\theta$$ does depend on time and should be derived, and of course, you can never skip the product rule.

So you had: $$\frac{\mathrm d}{\mathrm dt}(\frac{\partial L}{\partial\dot\theta})$$ and this gives $$\ddot x\cos\theta-\dot x\dot\theta\sin\theta$$ But thats not the entire story, Euler's formula is: $$\frac{\mathrm d}{\mathrm dt}(\frac{\partial L}{\partial\dot\theta})-\frac{\partial L}{\partial\theta}=0$$ and $$-\frac{\partial L}{\partial\theta}=+\dot x\dot\theta\sin\theta$$

so... as you expected no terms with $$\dot\theta$$.

• I can already picture you having a mental breaking down after realizing it was just this all along. No worries man, it happens to everyone, sometimes we get so stuck we start to question if 2+2=4. Apr 25 '20 at 12:18
• Yes really! I failed to notice that $T$ also depends on $\theta$. This was a really stupid mistake, thank you very much for clearing it up. And, it isn't an inverted pendulum above a cart, it is a pendulum below the cart. Apr 25 '20 at 12:20
• Hi PedroDM, you can use \left( and )\right in MathJax to automatically adjust the sizes of ( and ) respectively.
– user258881
Apr 25 '20 at 12:25
• Oh thanks Fake Mod, I'm sorry for the bad formatting, I just copied from the OP cause I thought it was quicker and good enough. Thanks for the advice. Apr 25 '20 at 12:38