# Calculating the Generalized force with and without the lagrangian

In my mechanics class, I learned that the components of the generalized force, $$Q_i$$, could be calculated using:

$$$$\tag{1}Q_i = \sum_j \frac{\partial \mathbf{r}_j}{\partial q_i}\cdot \mathbf{F}_j.$$$$

But, by solving the Euler-Lagrange equations, I should also be able to find the generalized force.

Nonetheless, they yield vastly different results.

For example, in the simple case of a particle in a universe gravitational field, i.e. $$\vec{F}=mg\,\hat{e}_z$$, the equation above returns:

$$Q_r=-mg\cos\theta$$ $$Q_\theta=mgr\sin\theta$$

while, when taking the lagrangian, $$L=\frac{1}{2}m\left(\dot{r}^2+(r\dot{\theta})^2+(r\dot{\phi}\sin\theta)^2\right) - mgr\cos\theta,$$ and solving the Euler-Lagrange equations, I get:

$$m\ddot{r}=Q_r=mr\dot{\theta}^2+mr\phi^2\sin^2\theta-mg\cos\theta$$

$$mr^2\ddot{\theta}=Q_\theta=mr^2\phi^2\sin\theta\cos\theta+mgr\sin\theta$$

What's wrong here?

You are mixing up concepts from d'Alemberts principle and Lagrangian mechanics. To show you what is wrong we will look at an example which is related to your problem, s.t. you can find out the solution to your problem quite easy afterwards. Let us consider a pendulum of fixed length $$l$$ and a point mass $$m$$ attached to its end in two dimensions. The position, velocity and acceleration of the point mass can be parameterized in polar coordinates via $$\vec r = \begin{pmatrix}l \sin \phi \\ -l \cos\phi\end{pmatrix}$$ $$\dot{\vec r} = \dot\phi\begin{pmatrix}l \cos \phi \\ l \sin\phi\end{pmatrix}$$ $$\ddot{\vec r} =\ddot\phi\begin{pmatrix}l \cos \phi \\ l \sin\phi\end{pmatrix} +\dot\phi^2\begin{pmatrix}-l \sin \phi \\ l \cos\phi\end{pmatrix}$$ Note that this parameterization automatically respects the spatial constraint $$\vec r ^2 =l²$$ which is imposed by the rod. To find the equations of motion you now just make use of Newtons second law $$m\ddot{q}= Q$$ using the generalized force $$Q$$ and "generalized position" $$q$$. Actually I think it is a bit of a stretch to call this really a generalized force since the only thing you do is to project the force field, which fills all of our space, onto the submanifold our point mass is allowed to move on. Likewise you need to project the accelaration vector accordingly. So in this case $$Q = \vec F\cdot\frac{\partial\vec r}{\partial \phi} = \begin{pmatrix}0\\-mg\end{pmatrix}\cdot \begin{pmatrix}l \cos \phi \\ l \sin\phi\end{pmatrix}=-mgl\sin\phi$$ and $$\ddot q = \ddot{\vec r}\cdot\frac{\partial\vec r}{\partial \phi} = l^2\ddot\phi$$ resulting in $$ml^2\ddot \phi = -mgl\sin\phi,$$ which indeed is the correct equation of motion. So using d'Alemberts principle the only thing you do is projection of all quantities to tangentvectors of the submanifold and using Newtons third law. (Of course the formalism is based on the concept of virtual Work, but what you get is basically Newton + simple geometry, so for the formalism we refer to the linked Wikipedia page or your preferred mechanics book, I would suggest Goldstein for example.)
So in contrast to d'Alemberts principle Lagrangian mechanics is based on Hamiltons principle. Which states that the physical trajectory is given by the path $$\gamma: t\mapsto\gamma (t)$$ which minimizes the action $$S[\gamma] = \int_{t_1}^{t_2} L(\gamma(t), \dot\gamma(t),t)\text{d}t.$$ The information about the geometry of the problem (i.e. the submanifold your point particle is allowed to move on) is encoded in the way you parameterize your possible paths $$\gamma$$. So in this case we can parameterize all allowed paths on the submanifold simply by choosing a polar representation $$\gamma(t) = \begin{pmatrix}l \sin \phi(t) \\ -l \cos\phi(t)\end{pmatrix},$$ where $$\phi(t)$$ is determined by minimizing the action. The Lagrangian is given by $$L(\phi, \dot\phi) = \frac m 2 \dot\gamma^2-mg\ \gamma\cdot e_z =\frac m 2 l^2\dot\phi^2 + mgl\cos\phi,$$ which results in $$ml^2\ddot\phi + mgl \sin\phi = 0.$$ So both approaches yield the same result. The thing that is important is that both approaches are fundamentally different. In the first approach we start with the full 3 dimensional space and project "by hand" on the submanifold we are interested in. In the second approach we use Hamiltons principle and encode all geometric information in the subset of functions we search the minimum of the action in.
• Thank you for your explanation. I see that it works for the pendulum, but that just makes me more confused about why the case of the particle in a uniform field yields different results. I mean, I know why: it's because, when solving Euler-Lagrange's equations, I get not only the force related to the gravity acceleration, but also the imaginary forces that are "bending" $r$ and $\theta$. But, if that's the case, is there no way to reach the same results using d'Alemberts principle and Lagrangian mechanics? Feb 15 at 19:39
• You just try to identify two things which are not equal! $m\ddot r \neq Q_r$! Feb 16 at 13:09