Franz J. Vesely > CompPhys Tutorial > Differential Equations 
 
 





 



Lagrangean and Hamiltonian Mechanics

(Sidetrack from Sec. 4.2.5 - Symplectic Algorithms)

In order to discuss symplectic algorithms we have to explain what "symplectic" actually means. Let us therefore delve shortly into the beauty of generalized dynamical equations.

Langrange:

Newton's intent was to describe the motion of heavenly bodies. His equations of motion in their original formulation are best suited for interacting point masses - even if those "points" are actually planets or suns. There are two good reasons to desire a more general formulation of Newtonian mechanics. Firstly, the symmetry of the physical system may be such that a set of generalized coordinates would capture this symmetry better than the usual Cartesian coordinates. Secondly, there may be constraints such that some of the coordinates, generalized or not, are actually constant - just think of a pendulum where the length $r$ of the string has a trivial equation of motion: $d^{2}r/dt^{2}=0$.

Facing these two challenges Lagrange came up with two approaches which are usually dubbed Lagrangean equations of the first and second kind.
  • Lagrange I:
    Here we deal with constraints, still relying on Cartesian coordinates. Suitable "constraint forces" are introduced and added to the "physical" forces present in the system. In this way the system is forced to obey the constraints, without the need to change the Newtonian equations.

    EXAMPLE: Planar pendulum
    Writing Newton's equation as
    $\ddot{\vec{r}}= \frac{\textstyle 1}{\textstyle m}(\vec{K}+\vec{Z}) \;\;\;\;\;\;\;\;\;\; (1) $

    with the gravitational force $K=-mg \vec{e}_{z}$ and the constraint force $\vec{\textstyle Z}$ we are confronted with the task of determining $\vec{Z}$. Lagrange taught us to argue thus: the constraint $\sigma \equiv |\vec{r}^{2}|-l^{2} = 0$ is to be enforced; a suitable force can only be perpendicular to the lines of equal $\sigma$ - in other words, it must be proportional to the gradient of $\sigma$:

    $ \vec{Z} = - \lambda \, \nabla \sigma = - 2 \, \lambda \, \vec{r} $

    with a still undetermined $\lambda$. To find the right value of $\lambda$ we take the second time derivative of $\sigma$ and require it to be zero:

    $ \dot{\sigma} = 2 \, \vec{r} \cdot \dot{\vec{r}} \;\;\;\;\; \Longrightarrow \;\;\;\;\; \ddot{\sigma} = 2 \, |\dot{\vec{r}}|^{2} + 2 \, \vec{r} \cdot \ddot{\vec{r}} = 0 \;\;\;\;\; \Longrightarrow \;\;\;\;\; \vec{r} \cdot \ddot{\vec{r}} = - |\dot{\vec{r}}|^{2} $

    From this and eq. 1 we find

    $ \vec{K} \cdot \vec{r} - 2 \, \lambda |\vec{r}|^{2} = - m \, |\dot{\vec{r}}|^{2} \;\;\;\;\; \Longrightarrow \;\;\;\;\; \lambda = [ \vec{K} \cdot \vec{r} + m \, |\dot{\vec{r}}|^{2} ] / 2 \, r^{2} $

    Inserting this in (1) we have

    $ \ddot{\vec{r}} = - g \, \vec{e}_{z} + [\frac{\textstyle r}{\textstyle r^{2}} (\vec{e}_{z} \cdot \vec{r}) - \frac{\textstyle |\dot{\vec{r}}|^{2}}{\textstyle r^{2}} ] \, \vec{r} $

    Now, this is a rather clumsy way to describe a pendulum. But the idea of constraint forces was brought to fruition in the 1970s in the SHAKE algorithm of Ryckaert et al.; see here.

  • Lagrange II:
    A more profound reformulation of the mechanical equations makes use of generalized coordinates. Introducing the set $\vec{q} \equiv \{q_{1} \dots q_{n} \}$ of coordinates and the corresponding generalized velocities $\dot{\vec{q}} \equiv \{\dot{q}_{1} \dots \dot{q}_{n} \}$ Lagrange wrote the kinetic energy $T$ and the potential energy $U$ in terms of these new coordinates and introduced the function $L \equiv T - U$. He then showed that the dynamics of the system follows the "Lagrange equations of the second kind",

    $ \frac{\textstyle d}{\textstyle d t} \frac{\textstyle \partial L}{\textstyle \partial \dot{\vec{q}}} - \frac{\textstyle \partial L}{\textstyle \partial \vec{q}} =0 $


    EXAMPLE: Planar pendulum
    The obvious choice for generalized coordinates is $(r,\phi)$, where $r=l$ is the distance of the pendulum mass from the axis, and $\phi$ is the angle between the string and the (negative) $z$-axis. Since $r$ is constant we have to address only $\phi$ and $\dot{\phi}$. The potential energy is $U(\phi)=mgl (1-cos \phi)$, and the kinetic energy is $T(\dot{\phi})=ml^{2}\dot{\phi}^{2}/2$. Thus $\partial L / \partial \dot{\phi}=ml^{2} \dot{\phi}$ and $\partial L / \partial \phi=-mgl sin \, \phi$. Inserting this in the Lagrange equation we have

    $ \frac{\textstyle d}{\textstyle d t} m l^{2} \dot{\phi} + m g l sin \, \phi =0 \;\;\;{\rm or}\;\;\; \ddot{\phi} = - \frac{\textstyle g}{\textstyle l} sin \, \phi $

    Well, we knew that all along, didn't we? But Lagrange gave us the means to derive the equation of constrained motion in a very general manner.


    EXAMPLE: Harmonic oscillator
    Of course, Lagrange II must work also in the simple Cartesian case, and without constraints. Putting $q=x$ and $\dot{q}=\dot{x}$ we have $T=m \dot{q}^{2}/2$, $U=k q^{2}/2$. Thus $\partial L / \partial \dot{q}=m \dot{x}$ and $\partial L / \partial q= - k x$. Therefore, $ \ddot{x} = - (k/m) x$. Again, no surprises.

Hamilton:

Again, we define generalized coordinates suited to the mechanical system at hand. However, the generalized velocities are replaced by something much more elegant: the "conjugate momenta". These are defined by $p_{i} \equiv \partial L / \partial \dot{q}_{i}$. Conversely, we may now express the generalized velocities $\dot{q}_{i}$ in terms of $p_{i}$. With this in mind we define the Hamiltonian

$ H(\vec{q},\vec{p}) \equiv \sum \limits_{i=1} \dot{q}_{i} \, p_{i} - L(\vec{q},\vec{p}) = \dot{\vec{q}} \cdot \vec{p} - L(\vec{q},\vec{p}) $

The mechanical equations may now be expressed in the highly symmetric form

$ \dot{\vec{q}} = \nabla_{p} H(\vec{q},\vec{p}) \;\;\;\;\;\;\;\;\;\;\;\; \dot{\vec{p}} = -\nabla_{q} H(\vec{q},\vec{p}) $


Defining the phase space vector $\vec{z} \equiv \{ \vec{q}, \vec{p} \}$ we may combine the two Hamiltonian equations into one:

$ \frac{\textstyle d \vec{z}}{\textstyle dt} = J \cdot \nabla_{z} H(\vec{z}) $

where
$ J \equiv \left(\begin{array}{cc} 0 & I \\ - I & 0 \end{array} \right) $

is the "symplectic matrix". ("symplectic" means "intertwined").

EXAMPLE: Planar pendulum
Up to the definition of $T(\dot{q})$ and $U(q)$ we proceed as before. Again writing $L=T-U= ml^{2}\dot{q}^{2}/2 - mgl (1-cos \, q)$ we find for the conjugate momentum

$ p \equiv \frac{\textstyle \partial L}{\textstyle \partial \dot{q}} = m l^{2} \dot{q}$

Expressing $\dot{q}$ by $p$ we have $\dot{q}= p/ml^{2}$ and from that $L=p^{2}/2ml^{2}-mgl(1-cos \,q)$. The Hamiltonian then reads

$ H(q,p) \equiv \dot{q} \, p - L(q,p) = \frac{\textstyle p^{2}}{\textstyle m l^{2}} -L(q,p) = \frac{\textstyle p^{2}}{\textstyle 2 m l^{2}} + mgl(1-cos \, q) $
And so,

$ \dot{q} = \frac{\textstyle \partial H(q,p)}{\textstyle \partial p} = \frac{\textstyle p}{\textstyle ml^{2}} \;\;\;\;\;\;\;\;\;\;\;\; \dot{p} = - \frac{\textstyle \partial H(q,p)}{\textstyle \partial q} = -mgl \, sin \, q $



EXAMPLE: Harmonic oscillator:
As in Lagrange II, we put $q=x$ and $\dot{q}=\dot{x}$, with $T=m \dot{q}^{2}/2$, $U=k q^{2}/2$. Thus $p \equiv \partial L / \partial \dot{q}=m \dot{x}$, or $\dot{x} = p/m$. The Hamiltonian is then $H=p^{2}/m - L = p^{2}/2m + k q^{2}/2$, and indeed

$ \frac{\textstyle d q}{\textstyle dt} = \nabla_{p} H( q, p) = \frac{\textstyle p}{\textstyle m} \;\;\;\;\;\;\;\;\;\; \frac{\textstyle d p}{\textstyle dt} = -\nabla_{q} H( q, p) = - k \, q $

vesely 2007-12-1

Back to Ch.4 Sec.2