Intro to Chaos in Mechanics

This is really just for me so that I won’t forget.  I mean, I will forget—but then I can look back at this post and remember stuff.  Here’s to you Future Rhett.

What is a chaotic system?  Really, that’s the question—isn’t it?  There is the classic example of the double pendulumHere is some code for a double pendulum. And this is what it looks like.

Nov-11-2018 15-57-59.gif

But this isn’t the best system.  The problem is that there are two coordinates—the angle for the top bar and the angle for the bottom bar.  Sure, it’s cool—but what if you want to plot angle vs. time or something.  You have to plot both angles vs. time and that’s a bummer.

OK, how about a model of bounded population growth?  That’s just one dimensional, right?  Actually, it doesn’t even have to be population, it’s just an equation—something like this.

x_{n+1} = 4rx_n(1-x_n)

In this expression, r is some parameter—it really doesn’t matter what.  Let’s just model this expression for different values of r.  I’ll use a starting x value of 0.1 and r values of 0.7 and 0.9.   Here is the code.

GlowScript IDE 2018-11-11 17-55-15.png

Notice that when r = 0.7, the population reaches some stable value—but this is not true for r = 0.9.

Bifurcation Diagram

Now for another way to look at a chaotic systems—the bifurcation diagram.  Honestly, I didn’t really understand these things until I made one.  Here’s what we are going to do.

  • Start with some initial value of x (just pick something—I’m going to use 0.5).  Pick a value for r also.  Let’s just start at 0.1.
  • Run the model for 200 iterations and throw out that data.  This should allow us to look at the long term behavior for that particular value of r (throws out the transient behavior).
  • Now run the model for 100 additional iterations and save these.
  • Create a plot of these final x values vs. r.
  • Next increase the r value a little bit (I will increase it by 0.001)
  • Repeat until you get bored.

So if the model is stable after the initial stuff, then it will just keep plotting the same value of x after the first 200 iterations and you will just get a dot.  If it’s not stable after the first stuff, then you will get a bunch of dots with different x values.

OK, let’s do it.  Here is the code.  Oh, I made a function to iterate the model.  I probably should put more comments in there.

This is what it looks like.

GlowScript IDE 2018-11-12 09-08-29.png

Up to an r value of about 0.75, you only get one final x value.  After that, you get two different values . With r over 0.9, it gets crazy.

OK, that’s enough for now.  I just want to make sure future Rhett knows how to make a bifurcation diagram.

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.