Looking back at part I of this idea, I don’t think I did a very good job. Let me summarize the key things I wanted to say:

- Normally, there are two ways of modeling the motion of an object:
- Calculating the forces on the object and using the momentum principle or Newton’s second law (which are the same thing). I called this the Newtonian way. The problem with this method is forces that constrain the motion (like the normal force). These forces have a variable magnitude to make the object stay on a particular surface.
- Defining some variables that describe the system as it is constrained. Then finding the kinetic and potential energy in these variables and using Lagrange’s equations. I called this the Lagrangian way. The trouble with this method is that if there are dissipative forces (like friction) things get weird.

Either one of the above ways essentially gets you the same equation of motion. For a pendulum, here is the setup:

And here is the equation of motion:

Note: this is not your normal text-book pendulum equation. In the simple form, it is assumed that the angle is small. With this approximation, it could be written as:

Textbooks like it this way because now it looks like the equation for a simple harmonic oscillator. However, for the rest of this post, I am going to use the better version of the equation of motion. Ok, one last point. How do I know that equation is good to use? Simple – it agrees with experimental evidence. So, for the rest of this post, I am going to use that equation of motion as though it were a real pendulum.

### Another method

If you think about the pendulum, what makes it tricky? It is not gravity, that is simple. The tension in the string is the problem because it is one of these forces that changes to make the mass stay in the path it stays in. How does the string know exactly how much force to exert on the mass? Think about it. What if the string pulled too much on the mass. If this happened, the radial acceleration would be greater than needed to move in a circle of radius *R*.

How does the string do that? Is it magic? Does it have a super computer in it? Clearly, not. I think the simplest answer is that the string is like a spring. The greater you pull on it, the more it stretches. When it stretches, it acts like a spring. Springs are awesome. I can model springs. What if I model a mass on a spring with a really high spring constant? That is what I am going to do in vpython. Here is a picture.

It turns out that I don’t want to do this in vpython. The problem is that vpython doesn’t make pretty graphs. Instead, I will use python and use the matplotlib module to make graphs. Here is the game plan for the numerical model:

Calculate the forces on the mass – the gravitational force and the force due to the “spring-string”. I could write this as:

- g vector is the gravitational field
- r is a vector from the pivot point to the mass
- R is the length of the “string” or the unstretched length of the spring
- k is the spring constant of the string

Next, I can use the net force to find the change in momentum of the mass:

And the position (new position) can be determined by:

After this, update the time and keep repeating everything. Of course, this is the basic idea behind a numerical calculation. I usually write pretty messy code, but if you want it, you can have it.

How well does it do? Here is a plot of the y-position of the spring mass. In this first plot, I intentionally set the spring constant sort of small. In this plot, I set the following:

- mass = 0.1 kg
- k = 500 N/m
- dt = 0.01 seconds

Kind of shaky – this can be fixed. I will increase the spring constant to 5000 N/m and decrease the time interval (dt) to 0.001 seconds. This produces:

How well does this compare to the equation of motion? Here is a plot of the numerical solution of the original equation of motion (from the Lagrangian way) and a plot of the motion of the spring-pendulum. In order to see these two functions, I off-set the values of one of the plots.

There is actually a difference between these two plots. If I remove the off-set and zoom in, it looks like this:

I could get rid of these squiggles by increasing the spring constant and/or decreasing the time interval.

So, I claim this works. Does it work well? That is debatable. In order to get good results, the time interval must be pretty small. As computers get faster, this is less of a big deal. Actually, treating stuff as springs is how many of the computer games model physic-y stuff. For them (game programmers), the world is a spring.