Lagrangian mechanics in generalized coordinates¶

Marcos Duarte
Laboratory of Biomechanics and Motor Control (http://demotu.org/)
Federal University of ABC, Brazil

Generalized coordinates¶

The direct application of Newton's laws to mechanical systems results in a set of equations of motion in terms of Cartesian coordinates of each of the particles that make up the system. In many cases, this is not the most convenient coordinate system to solve the problem or describe the movement of the system. For example, in problems involving many particles, it may be convenient to choose a system that includes the coordinate of the center of mass. Another example is a serial chain of rigid links, such as a member of the human body or from a robot manipulator, it may be simpler to describe the positions of each link by the angles between links.

Coordinate systems such as these are referred as generalized coordinates. Generalized coordinates uniquely specify the positions of the particles in a system. Although there may be several generalized coordinates to describe a system, usually a judicious choice of generalized coordinates provides the minimum number of independent coordinates that define the configuration of a system (which is the number of degrees of freedom of the system), turning the problem simpler to solve.

Being a little more technical, according to Wikipedia):
"In classical mechanics, the parameters that define the configuration of a system are called generalized coordinates, and the vector space defined by these coordinates is called the configuration space of the physical system. It is often the case that these parameters satisfy mathematical constraints, such that the set of actual configurations of the system is a manifold in the space of generalized coordinates. This manifold is called the configuration manifold of the system."

In problems where it is desired to use generalized coordinates, one can write Newton's equations of motion in terms of Cartesian coordinates and then transform them into generalized coordinates. However, it would be desirable and convenient to have a general method that would directly establish the equations of motion in terms of a set of convenient generalized coordinates. In addition, general methods for writing, and perhaps solving, the equations of motion in terms of any coordinate system would also be desirable. The Lagrangian mechanics is such a method.

When describing a system of particles using any set of generalized coordinates, $q_1,\dotsc,q_{3N}$, these are related to, for example, the Cartesian coordinates by:

\begin{equation} \begin{array}{rcl} q_i =q_i (x_1,\dotsc,x_{3N} ) \quad i=1,\dotsc,3N \\ x_i =x_i (q_1,\dotsc,q_{3N} ) \quad i=1,\dotsc,3N \label{eq24} \end{array} \end{equation}

The Cartesian components of velocity as a function of generalized coordinates are:

\begin{equation} \dot{x}_i =\frac{\mathrm d x_i (q_1, q_2,\dotsc,q_{3N} )}{\mathrm d t}=\sum\limits_{j=1}^{3N} {\frac{\partial x_i }{\partial q_j }} \frac{\mathrm d q_j }{\mathrm d t} \label{eq26} \end{equation}

where for simplicity we omitted the explicit mention of the temporal dependence of each coordinate.

That is, any Cartesian component of the particle velocity as a function of generalized coordinates is a function of all the components of position and velocity in the generalized coordinates:

\begin{equation} \dot{x}_i = \dot{x}_i (q_1,\dotsc,q_{3N} ,\dot{q}_1,\dotsc,\dot{q}_{3N} ) \quad i=1,\dotsc,3N \label{eq27} \end{equation}

Lagrange's equation¶

In analogy to Newtonian mechanics, one can think that the equations of motion can be obtained by equating the generalized force, $F_i$, to the temporal rate of change of each generalized momentum, $p_i$:

\begin{equation} F_i =\frac{\partial p_i }{\partial t} \label{eq28} \end{equation}

In the formula above, let's substitute the quantity $p_i$ by its definition in terms of the kinetic energy:

\begin{equation} \frac{\partial p_i }{\partial t} =\frac{\partial }{\partial t}\left( {\frac{\partial T}{\partial \dot{q}_i }} \right)=\frac{\partial }{\partial t}\left( {\sum\limits_{j=1}^{3N} {m_j \dot{x}_j \frac{\partial \dot{x}_j }{\partial \dot{q}_i }} } \right) \label{eq29} \end{equation}

where we used:

\begin{equation} \frac{\partial T}{\partial \dot{q}_i }=\sum\limits_{j=1}^{3N} {\frac{\partial T}{\partial \dot{x}_j }\frac{\partial \dot{x}_j }{\partial \dot{q}_i }} \label{eq30} \end{equation}

Using the product rule, the derivative of the product in Eq. (\ref{eq29}) is:

\begin{equation} \frac{\partial p_i }{\partial t}=\sum\limits_{j=1}^{3N} {m_j \ddot{x}_j \frac{\partial \dot{x}_j }{\partial \dot{q}_i }} +\sum\limits_{j=1}^{3N} {m_j \dot{x}_j \frac{\mathrm d }{\mathrm d t}\left( {\frac{\partial \dot{x}_j }{\partial \dot{q}_i }} \right)} \label{eq31} \end{equation}

But:

\begin{equation} \frac{\partial \dot{x}_i }{\partial \dot{q}_j }=\frac{\partial x_i }{\partial q_j } \quad because \quad \frac{\partial \dot{x}_i }{\partial \dot{q}_j }=\frac{\partial x_i }{\partial t}\frac{\partial t}{\partial q_j }=\frac{\partial x_i }{\partial q_j} \label{eq32} \end{equation}

Then:

\begin{equation} \frac{\partial p_i }{\partial t}=\sum\limits_{j=1}^{3N} {m_j \ddot{x}_j \frac{\partial x_j }{\partial q_i }} +\sum\limits_{j=1}^{3N} {m_j \dot{x}_j \frac{\mathrm d }{\mathrm d t}\left( {\frac{\partial x_j }{\partial q_i }} \right)} \label{eq33} \end{equation}

The first term on the right side of the equation above is proportional to $m_j \ddot{x}_j$ and we will define as the generalized force, $Q_i$. But, different from Newtonian mechanics, the temporal variation of the generalized momentum is equal to the generalized force plus another term, which will investigate now. The last part of this second term can be derived as:

\begin{equation} \frac{\mathrm d }{\mathrm d t}\left( {\frac{\partial x_j }{\partial q_i }} \right) = \sum\limits_{k=1}^{3N} {\frac{\mathrm d }{\mathrm d q_k }\left( {\frac{\partial x_j }{\partial q_i }} \right)\frac{\mathrm d q_k }{\mathrm d t}} =\sum\limits_{k=1}^{3N} {\frac{\partial^2 x_j }{\partial q_k \partial q_i }\dot{q}_k } \label{eq34} \end{equation}

where we used the chain rule for the differentiation: \begin{equation} \frac{\mathrm d }{\mathrm d t}\Big( {f\big({g(t)}\big)}\Big) = \frac{\partial f}{\partial g}\frac{\partial g}{\partial t} \label{eq35} \end{equation}

But if we look at Eq. (\ref{eq26}) we see that the term at the right side of the Eq. (\ref{eq34}) can be obtained by:

\begin{equation} \frac{\partial \dot{x}_j }{\partial q_i } = \frac{\partial }{\partial q_i }\left(\sum\limits_{k=1}^{3N} \frac{\partial x_j }{\partial q_i }\dot{q}_k \right) = \sum\limits_{k=1}^{3N} {\frac{\partial^2 x_j }{\partial q_k \partial q_i }\dot{q}_k } \label{eq36} \end{equation}

Comparing the Eq. (\ref{eq34}) and Eq. (\ref{eq36}) we have:

\begin{equation} \frac{\mathrm d }{\mathrm d t}\left( {\frac{\partial x_j }{\partial q_i }} \right) = \frac{\mathrm d }{\mathrm d q_i}\left( {\frac{\partial x_j }{\partial t }} \right) \label{eq37} \end{equation}

On the other hand, it is possible to relate the term $\partial \dot{x}_j / \partial q_i$ to the derivative of kinetic energy with respect to the coordinate $q_i$:

\begin{equation} \frac{\partial T}{\partial q_i }=\frac{\partial }{\partial q_i }\left( {\sum\limits_{j=1}^{3N} {\frac{1}{2}m_j \dot{x}_j^2} } \right)=\sum\limits_{j=1}^{3N} {m_j \dot{x}_j } \frac{\partial \dot{x}_j }{\partial q_i } \label{eq38} \end{equation}

where once again we used the chain rule for the differentiation.

Using Eq. (\ref{eq37}), Eq. (\ref{eq38}) becomes

\begin{equation} \frac{\partial T}{\partial q_i }=\sum\limits_{j=1}^{3N} {m_j \dot{x}_j } \frac{\mathrm d }{\mathrm d t}\left( {\frac{\partial x_j }{\partial q_i }} \right) \label{eq39} \end{equation}

Returning to Eq. (\ref{eq33}), it can be rewritten as:

\begin{equation} \frac{\mathrm d }{\mathrm d t}\left( {\frac{\partial T}{\partial \dot{q}_i }} \right) = Q_i + \frac{\partial T}{\partial q_i } \label{eq40} \end{equation}

and

\begin{equation} \frac{\mathrm d }{\mathrm d t}\left( {\frac{\partial T}{\partial \dot{q}_i }} \right) - \frac{\partial T}{\partial q_i } = Q_i \label{eq41} \end{equation}

Now let's look at $Q_i$, the generalized force. It can be decomposed into two terms:

The first term, composed of the conservative forces, i.e. forces that can be written as potential gradients:

\begin{equation} Q_C =-\frac{\partial V}{\partial q_i } \quad , \quad V=V\left( {q_1,\dotsc,q_{3N} } \right) \label{eq42} \end{equation}

An example of conservative force is the gravitational force.

And the second term, encompassing all non-conservative forces, $Q_{NC}$.

Then:

\begin{equation} Q_i =-\frac{\partial V}{\partial q_i }+Q_{NCi} \quad , \quad V=V\left( {q_1,\dotsc,q_{3N} } \right) \end{equation}

The Eq. (\ref{eq41}) becomes

\begin{equation} \frac{\mathrm d }{\mathrm d t}\left( {\frac{\partial T}{\partial \dot{q}_i }} \right)-\frac{\partial T}{\partial q_i }=-\frac{\partial V}{\partial q_i} + Q_{NCi} \label{eq43} \end{equation}

Rearranging, we have:

\begin{equation} \frac{\mathrm d }{\mathrm d t}\left( {\frac{\partial \left( {T-V} \right)}{\partial \dot{q}_i }} \right)-\frac{\partial \left( {T-V} \right)}{\partial q_i} = Q_{NCi} \label{eq44} \end{equation}

This is possible because:

\begin{equation} \frac{\partial V}{\partial \dot{q}_i} = 0 \label{eq45} \end{equation}

Defining:

\begin{equation} \mathcal{L} \equiv \mathcal{L}(q_1,\dotsc,q_{3N} ,\dot{q}_1,\dotsc,\dot{q}_{3N} ) = T - V \label{eq46} \end{equation}

as the Lagrange or Lagrangian function, we have the Lagrange's equation:

\begin{equation} \frac{\mathrm d }{\mathrm d t}\left( {\frac{\partial \mathcal{L}}{\partial \dot{q}_i }} \right)-\frac{\partial \mathcal{L}}{\partial q_i } = Q_{NCi} \quad i=1,\dotsc,3N \label{eq47} \end{equation}

Once all derivatives of the Lagrangian function are calculated, this equation will be the equation of motion for each particle. If there are $N$ independent particles in a three-dimensional space, there will be $3N$ equations for the system.

The set of equations above for a system are known as Euler–Lagrange equations, or Lagrange's equations of the second kind.

Constraints¶

An important class of problems in mechanics, in which the Lagrangian equations are particularly useful, are composed of constrained systems. A constraint is a restriction on the freedom of movement of a particle or a system of particles (a constraint decreases the number of degrees of freedom of a system). A rigid body, or the movement of a pendulum, are examples of constrained systems. It can be shown, in a similar way, that the Lagrange equation, deduced here for a system of free particles, is also valid for a system of particles under the action of constraints. The Lagrange's equation, for a system of $3N$ particles and with $k$ constraints, is then defined as:

\begin{equation} \frac{\mathrm d }{\mathrm d t}\left( {\frac{\partial \mathcal{L}}{\partial \dot{q}_i}} \right)-\frac{\partial \mathcal{L}}{\partial q_i } = Q_{NCi} \quad i=1,\dotsc,3N-k \label{eq48} \end{equation}