# Classical Mechanics: Newtonian, Lagrangian, and Hamiltonian

In classical mechanics, there are three common approaches to solving problems.  I’m going to solve the same situation three different ways.  It’s going to be fun.  Trust me.

Here is the problem.  A ball is at ground level and tossed straight up with an initial velocity.  The only force on the ball while it is in the air is the gravitational force.  Oh, the ball has a mass of “m”.

Newtonian Mechanics

First, let’s get this out of the way.  It wasn’t just Newton that did this stuff.  Also, please don’t lecture me on “Newton’s Three Laws of Eternal Motion and the Rules of the Universe”.  Yes, I think everyone spends too much time on “the three laws”.

In short, Newtonian mechanics works for cases in which we know the forces and we have a reasonable coordinate system.  Yes, it’s true that we can use unreasonable coordinate systems and still have this stuff work.  Also, it’s possible to deal with unknown forces (like the tension in a string with a swinging pendulum).  But Newtonian mechanics works best if we know the forces.

If you know the forces (or just one force), then the following is true (in one dimension):

$F_\text{net} = m\ddot{x}$

Honestly, I prefer to write the momentum principle—but let’s just go with this for now.  Oh, in case you didn’t notice, I am using the “dot-notation” for derivatives.  A single dot means:

$\dot{y} = \frac{dy}{dt}$

The double dot means a second derivative (with respect to time).

Back to the tossed ball.  The only force on the ball is the gravitational force.  Also, I am going to use “y” for the position.  This gives us:

$-mg=m\ddot{y}$

$-g=\ddot{y}$

That’s just a second order differential equation (and not a very difficult one).  If I integrate both sides with respect to time, I get:

$\dot{y} = \dot{y_0} -gt$

Integrating again, I get:

$y=y_0 +\dot{y_0}t - \frac{1}{2}gt^2$

Boom. That’s your equation of motion for a tossed ball.

Lagrangian Mechanics

I’m not going to go over the whole theory behind the Lagrangian.  Here is the short answer (super short).  If you define something called the Lagrangian as:

$L = T-U$

Where T is the “generalized” kinetic energy and U is the potential energy, then the path a particle will take will be such that the integral over time of L is stationary (which is like minimized).  When you need to find a function that minimizes an integral, you can use the Euler-Lagrange equation to get the following (in 1 dimension for simplicity):

$\frac{\partial L}{\partial y} - \frac{d}{dt} \frac{\partial L}{\partial \dot{y}}=0$

The best part of Lagrangian mechanics is that you don’t have to use normal coordinate systems.  If you have a bead moving along a wire, the coordinate system can be defined as the distance along the wire.  Also, since the Lagrangian depends on kinetic and potential energy it does a much better job with constraint forces.

OK, let’s do this for the ball example.  I’m going to assume the ball has a position y as measured from the ground and a velocity $\dot{y}$.  That gives the following:

$T = \frac{1}{2}m\dot{y}^2$

$U = mgy$

$L = T-U = \frac{1}{2}m\dot{y}^2 - mgy$

To get the equation of motion, I need to first take the partial derivative of L with respect to y:

$\frac{\partial L}{\partial y}=-mg$

Also, I need that second term with the derivative of the partial with respect to $\dot{y}$.  It doesn’t matter in this problem—but here is where I caution students to be careful of the difference between a derivative and a partial derivative.

$\frac{d}{dt}\frac{\partial L}{\partial \dot{y}} = m\ddot{y}$

Yes, I skipped a step in there because it was trivial.  Putting this together, I get:

$-mg-m\ddot{y}=0$

$\ddot{y} = -g$

Now we are at the same place as the Newtonian method.  I could integrate twice, but I would clearly get the same thing.

Hamiltonian Mechanics

I’ll be honest.  I sort of suck at Hamiltonian mechanics.  Oh sure—it’s super important.  However, for just about every problem in classical mechanics it’s going to be easier to use either Newtonian mechanics or Lagrangian.

Then why do the Hamiltonian?  The first reason is for quantum mechanics.  Yes, in quantum mechanics we use the Hamiltonian operator.  It’s probably a good idea to understand just what the heck that means.  The second reason is statistical mechanics.  The Hamiltonian turns up there too.  Oh, and other places.

Let’s get started though. I am again skipping the derivation of the Hamiltonian.  This is a blog post, not a textbook.

In one dimension (and for one particle) the Hamiltonian is defined as:

$H = p\dot{y}-L$

Yes, you have to find the Lagrangian first.  Oh, the p is momentum.  However, once you get the Hamiltonian you get the two following equations:

$\dot{y} = \frac{\partial H}{\partial p}$

$\dot{p} = -\frac{\partial H}{\partial y}$

OK, let’s do this.  I already have the Lagrangian.  I can write the Hamiltonian as:

$H = m\dot{y}\dot{y} - \frac{1}{2}m\dot{y}^2+mgy =\frac{1}{2}m\dot{y}^2+mgy$

Since the Hamiltonian really depends on position and momentum, I need to get this in terms of y and p.  Note: I am using $p = m\dot{y}$ for the momentum.  This is not always the case—it depends on your choice of coordinate system.  But anyway, I will proceed.  This makes the Hamiltonian:

$H=\frac{p^2}{2m}+mgy$

Yes. In this case, this is the total energy.  It doesn’t have to be the total energy—it just works in this case.

Now I can use the two partials to get two equations:

$\dot{y} = \frac{\partial H}{\partial p} = \frac{p}{m}$

$\dot{p}=-\frac{\partial H}{\partial y} = -mg$

Here is a major point about Hamiltonian: using this method, I get two first order differential equations instead of one second order differential equation.  That might be important in some cases.

In order to get the equation of motion, I’m going to take the derivative of $\dot{y}$.

$\ddot{y} = \frac{d}{dt} \left( \frac{p}{m} \right) = \frac{\dot{p}}{m}$

Fortunately, I already have an expression for $\dot{p}$.  Putting this together, I get:

$\ddot{y} = \frac{-mg}{m} = -g$

Boom.  Back to that same equation as in the other two methods.

The end.