Obtaining Equations of Motion: Newton vs Lagrange vs Hamilton

Note: This post is adapted from a lecture I gave to my undergrads. It’s focused on conveying the method and main idea behind the different formulations. This is not a rigorous treatment and in some locations, I have traded being technically correct for being clear. If you want a riggorous treatment of the material I suggest a textbook.

Newtonian Mechanics

Newtons second law in mathematical form is

\vec{F}=\frac{d\vec{p}}{dt} = \frac{d(m\vec{v})}{dt}

which states that the force is equal to the change in linear velocity (Note: this only holds in inertial reference frames). If mass is a constant then we can take it out of the derivative to obtain the familiar

\vec{F}=m\frac{dv}{dt} = m\dot{\vec{v}}

Lagrangian Mechanics

Newtonian mechanics is a great starting point for many problems and lends itself well to simple problems that can be expressed in a Cartesian form. But what if cartesian coordinates are not the most natural for a specific problem? You can still use Newtonian mechanics, but you’ll find yourself knee deep in transformation matrices. Picture a two element a robot arm.

(insert picture of robot arm)

You can describe this system with the Cartesian coordinate of every joint, but that would be tedious. Your first instinct would be to instead describe this system with the angle at every joint, and this is the idea behind Lagrangian mechanics, that through judicious selection of our coordinate systems we can make our lives easier. Restating that formally; Lagrangian mechanics is a reformulation of Newtonian mechanics that makes using mixed coordinate systems easier. Let’s first define the Lagrangian, L, as

L = T – V

where T is the total kinetic energy of the system, and V is the potential energy of the system. The system can then be described by j independent coordinates, which are labeled

\vec{q}=\{q_1,q_2,...q_j\},

and their time derivatives, which are labeled

\dot{\vec{q}}=\{\dot{q}_1,\dot{q}_2,...\dot{q}_j\},

for a total of 2j states. We can then obtain the equations of motion through

\frac{d}{dt}\bigg(\frac{\partial L}{\partial \dot{q}_i}\bigg) = \frac{\partial L}{\partial q_i}

We obtain this equation from the principle of least action, which in short says that if something happens in nature, it occurs along the path that minimizes the [energy]*[time] or the [momentum]*[distance]. Think about dropping a ball at rest from your hand, it will fall straight down. It will not first head up or create any intricate paths on it’s way down because any other path would increase the trajectories time/distance or momentum/energy. Nature always chooses the lowest stable energy configuration. If you want to see the derivation of this equation search “Euler-Lagrange derivation”. 

Hamiltonian Mechanics

If the though behind Lagrangian mechanics is that the dynamics can best be expressed through a generalized set of coordinates and velocities, the thought behind Hamiltonian mechanics is, what if the dynamics can best be expressed through a generalized set of coordinates and momenta. If we could find just the right coordinates and momenta then the equations of motion of the system boil down to

\frac{d\vec{p}}{dt}=-\frac{\partial \mathcal{H}}{\partial \vec{q}} \quad,\quad \frac{d\vec{q}}{dt}=\frac{\partial \mathcal{H}}{\partial \vec{p}},

where \vec{p} is the generalized momenta, and \mathcal{H} is the Hamiltonian. The Hamiltonian, and generalized momenta are a bit abstract, but can be obtained from the Lagrangian using the following relationships
p_i = \frac{\partial L}{\partial \dot{q}_i},
and
\mathcal{H}=\sum_{i}^{j}\dot{q}_i\frac{\partial L}{\partial \dot{q}_i} - L.

Are these it?

Although these are the three most common formulations of mechanics, and the only ones covered here there are also

  • Routhian Mechanics – Uses generalized velocities and generalized momenta (useful for cyclic coordinates)
  • Apellian Mechanics – Useful when non-holonomic constraints are involved. (Derived through Gauss’s principal of least constraint instead of the principal of least action)
  • Koopmanian/Neumannian Mechanics – Re-formulated classical mechanics into a quantum mechanical form 

You can generally ignore these formulations though.

Reasons to use each

Newtonian mechanics

  • Pro – Can easily handle dissipate forces like friction and drag (Called non-holonomic constraints)
  • Pro – Can easily handle additional, non-potentiality forces
  • Con – Derivation grows exponentially more difficult as constraints are added.

Lagrangian Mechanics

  • Pro – Can easily handle constraints (that don’t do work)
  • Con – Does not do well with dissipate forces like friction and drag

Hamiltonian Mechanics

  • Pro – Very good for numerical integration
  • Meh – Algebra is in obtaining the generalized momenta and Hamiltonian, not in obtaining the equations of motion
  • Con – Non-intuitive
  • Con – Does not do well with dissipate forces like friction and drag

Worked Example – Pendulum on a Cart

T_{cart}=.5M\dot{x}^2

T_{Pendulum}=.5m\dot{x}^2 - lm\dot{x}\dot{\theta}cos(\theta)-.5ml^2\dot{\theta}^2

V = mglcos(\theta)

\frac{d}{dt}\bigg(\frac{\partial L}{\partial \dot{x}}\bigg) - \frac{\partial L}{\partial x} = F

\frac{d}{dt}\bigg(\frac{\partial L}{\partial \dot{\theta}}\bigg) - \frac{\partial L}{\partial \theta} = 0

(M+m)\ddot{x}-ml\ddot{\theta}cos(\theta)+ml\dot{\theta}^2sin(\theta) = F

l\ddot{\theta}-gsin(\theta)=\ddot{x}cos(\theta)

\boxed{\ddot{x}=\frac{F+m sin(\theta)(gcos(\theta)+l\dot{\theta}^2)}{M+msin^2(\theta)}}

\boxed{\ddot{\theta}=-\frac{Fcos(\theta)+(M+m)gsin(\theta)+lm\dot{\theta}^2sin(\theta)cos(\theta)}{l(M+msin^2(\theta))}}

If you want to see how we can control the cartpole, I recomend this post.

Want More Gereshes?

If you want to receive the weekly Gereshes blog post directly to your email every Monday morning, you can sign up for the newsletter here! Don’t want another email? That’s ok, Gereshes also has a twitter account and subreddit!