# Projectile in Polar Coordinates

Why?  There is no why.

Suppose a ball is shot at an angle θ with an initial velocity v0.  What will the motion be like in polar coordinates?

First, let me start with Newton’s 2nd Law in polar coordinates (I derived this in class).

$F_r = m(\ddot{r}-r\dot{\theta}^2)$
$F_\theta = m(r\ddot{\theta}+2\dot{r}\dot{\theta})$

Once the ball is in the air (and ignoring air resistance) the only force on the ball is the gravitational force. Yes, this would be -mg in the y-direction, but we don’t have a y-direction. Instead, we have polar coordinates. Maybe this picture will help.

The r and θ components of the gravitational force will change as:

$F_r = -mg\sin\theta$
$F_\theta = -mg\cos\theta$

If I use these forces with Newton’s law in polar coordinates, I get:

$F_r = -mg\sin\theta=m(\ddot{r}-r\dot{\theta}^2)$
$F_\theta = -mg\cos\theta = m(r\ddot{\theta}+2\dot{r}\dot{\theta})$

Of course the mass cancels – but now I can solve the first equation for $\ddot{r}$ and the second equation for $\ddot{\theta}$.

$\ddot{r} = r\dot{\theta}^2-g\sin\theta$
$\ddot{\theta} = \frac{-2\dot{r}\dot{\theta}}{r} - \frac{g\cos\theta}{r}$

It doesn’t matter that these second derivatives depend on the other stuff – I can still calculate them. Once I have those, I can create a numerical calculation to update the velocities and positions. Suppose I have everything know at time(1), then the stuff at time(2) would be:

$\dot{r}_2 = \dot{r}_1 +\ddot{r}\Delta t$
$\dot{\theta}_2 = \dot{\theta}_1 +\ddot{\theta}\Delta t$
$r_2 = r_1+\dot{r}\Delta t$
$\theta_2 = \theta_1 +\dot{\theta}\Delta t$
$t_2 = t_1 +\Delta t$

Now I’m all set to do a numerical calculation. Well, I still need the initial conditions. I could use this:

$\dot{r}_0 = v_0$
$r_0 =0$
$\dot{\theta}_0 = 0$
$\theta_0 = \theta_0$

But wait! There’s a problem. The calculation for $\ddot{\theta}$ has a 1/r term. If r is zero the universe will explode. I can fix this by having the initial r a little bit bigger than zero. Problem solved.

Here is the program in Glowscript.

For the first run, I am going to calculate the x- and y-coordinates in each step and plot x vs y.  I know this should look like a parabola.

Boom.  That works.  Now for a plot of both r and theta as a function of time for a high launch angle.

Double boom.

# 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.

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.

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.

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.