**Pre Reqs:** [Kinematics](http://scienceblogs.com/dotphysics/2008/09/basics-kinematics.php), [Momentum Principle](http://scienceblogs.com/dotphysics/2008/10/basics-forces-and-the-momentum-principle.php)
What are “numerical calculations”? Why are they in the “basics”? I will give you really brief answer and then a more detailed answer. Numerical calculations (also called many other things – like computational physics) takes a problem and breaks into a WHOLE bunch of smaller easier problems. This is great for computers ([or a whole bunch of 8th graders](http://scienceblogs.com/dotphysics/2008/09/computational-physics-and-a-group-of-1000-8th-graders/)) because computers don’t mind doing lots of little problems. Why are they “basic”? Well, most text would say they are not basic. I disagree. I think this is a legitimate method for solving problems. In particular, this is a great way of solving problems that can not be solved analytically (meaning solving one hard problem).
**Numerical Calculations are Theoretical Calculations**
Let me just get this out of the way. Numerical calculations and analytical calculations are really in the same “class”. Often people will lump numerical in with “computational experiment” but that is a really bad thing to do. Some others will claim that there are three different “paths” to discover stuff in science: theory, experiment, and simulations. Simulations are the same thing as numerical calculations which are the same as theory. ([I wrote a letter about this in the American Journal of Physics](http://scitation.aip.org/getabs/servlet/GetabsServlet?prog=normal&id=AJPIAS000076000009000797000001&idtype=cvips&gifs=yes))
Let me start with a problem that can be solved analytically. Suppose I have a ball of mass 0.5 kg and I throw this straight up with a speed of 10 m/s. How high will it go?
First, let me draw a free body diagram for the ball while it is in the air.
Yes, this is correct. Even though the ball is moving up, or if it is at the highest point, or if it is on the way down, there is only one force on it (neglecting air resistance, we can add that later). Remember your training. What is touching the ball? Nothing. What long range forces are on the ball? Just the gravitational force of the Earth. If you were in class with Aristotle, he would probably come up with something like *”If it is moving up, it still has some of the force of the hand on the ball.”* Don’t listen to him. He thinks he is a Jedi.
Ok, so how do you find out how high this will go? I am not going to do this the obvious way. The obvious way is to use the kinematics equations and assume that the acceleration is 9.8 m/s2 in the downward direction. Not going to do that. I am going to start with the momentum principle. I will write it as:
Since the only motion and only force are in the y-direction (I am calling up as the positive y direction) I can write the following scalar equation:
Notice that I went ahead and put the gravitational force as -mg where g is the local gravitational field (that is what I like to call it) and has a value of 9.8 Newtons/kg. So, what do I do with this equation? Well, there is something I know. I know the initial momentum (it was shot up at 10 m/s) AND I know the final momentum at the highest point is 0 kgm/s (because at the highest point, it stops for an instant). I can use this to find the time it take to get to the highest point.
First, this is clearly going to be a positive value (good for time). I am calling the initial velocity and momentum by putting a subscript (1). Yes, I should have put units on the zero final momentum, but I am lazy. Ok. So, I have the TIME it takes to get to the highest point, but that is not what the question asked. Here I can use a small “trick”. If the force is constant, the momentum (and thus velocity) change at a constant rate. Then:
If I choose the ground to be the origin so that the initial y is zero, then solving for the final y (y2)
Now putting in what I found for the change in time from above:
Now, if I want to put in some numbers, I can:
I know what you are going to say: “you are doing it wrong. That is way more difficult than it needs to be. Just use the kinematic equation.” Well, there is nothing wrong with this method. I like it, it starts from more fundamental ideas than the kinematic equation you are referring to (I know the one).
What if I wanted to do this numerically? Well, the key is to break this into a whole bunch of little steps. This is such an easy example that anything can be used. I am going to show how to do this in a spreadsheet – though typically I like to use [vpython](http://www.vpython.org). I am not going to give a real intro to spreadsheets, but if you are not familiar with them maybe this will help.
First, I am going to set up my constants and variables:
A couple of notes on this first step.
- Computers are stupid. I am sorry, but it is true. They really don’t know much. They don’t know the units. I wrote them down on the side, but the computer is just going to crunch the numbers. It is my (the human) responsibility to make sure the units are correct. I wrote them to the side, just for us humans.
- The momentum is actually calculated as 10*mass (it is good to get in a practice of calculating everything that you can).
- There are only 3 variables. Time, momentum (in the y-direction), and y position. You might need more for more complicated problems.
- What is “dt”? dt is the “time step” this is how long in time each step is. You will see.
Now, I will calculate the times. To do this, I will enter “0” for the first time cell (in my example, the first time cell is A7). The next time (cell A8) will be the time before plus “dt”. Here is the expression I entered in Excel.
Instead of entering “0.1” for cell A8, I entered “=A7+B$4″. If you are not familiar with spreadsheets, the $ sign in front of the 4 means “don’t change this”. Now I will copy this formula to the cells below A8. In Excel you can do this by highlighting cell A8 and dragging the small box at the lower left hand of the cell:
How far down do you copy? It really doesn’t matter, you can change this later.
Now, what about y? What is the first value? I already said that I would like the origin to be on the ground. This would mean the first value is 0. What about the value after that? I can use the following formula:
Great, but I don’t know what the average velocity is. That is ok. I know what the initial velocity is, and that is good enough.
**This is the secret of numerical calculations**
It is not technically correct to use the initial velocity for the average velocity. However, if my time interval is short, it won’t really matter much. So, I will enter the following for the second value of y:
Notice that instead of vy, I put py/m – this will matter in the future (I am being prepared). Also, notice that I called the momentum C7, but dt as B$4 and mass as B$2. I am going to want to change the momentum, but not the time step nor the mass.
Finally, for the momentum. I will use the momentum principle:
Here I am referring to p1 and p2. These refer to the momentum for the first and second calculations, You can see that generically, the following is true:
Where *n* can be any integer. Here is the formula entered in Excel for the momentum:
Copying down some, you should have something that looks like this:
Here you can already see your answer. What is the highest the ball goes? Well, you can look at the y positions and see that 5.61 is the highest. You also know this is the highest because it occurs when the momentum (and thus velocity) is around zero. I can also plot the position as a function of time:
I know what you are thinking. I am a cheater and I am wrong. When I solved this problem analytically, I found the ball went 5.1 meters. With this method, the highest point is 5.256 meters (according to Excel). This problem is easily fixed. What if I go and change dt from 0.1 to 0.01? Try it. The first thing you will find is that you don’t have enough data. You will need to copy your calculations down around 100 cells. Now looking for the highest point, I find:
Now I get on the order of 5.15 meters. What do you think would happen if I made dt = 0.001? Well, I would definitely need more Excel cells to find the answer.
I know this is long, but I want to show you another way of doing this numerical calculation.
It is useful to realize that with a spreadsheet, each row was a different time. Spreadsheets are nice in that people typically feel more comfortable with them than with a programming language.
What is [VPython?](http://www.vpython.org) VPython is a set of modules for python (the programming language) that does a lot of the hard work in 3-D graphics for you. In this case, you wouldn’t REALLY need vpython because you don’t really need a visual representation of the ball going up. Oh – vpython (and python) are FREE and run on Mac OS X, Windows, and Linux.
Let me go ahead and show you the vpython program
- Notice the vector nature of stuff. VPython likes vectors and so should you. Even though this problem does not require vectors, it is good to get in the habit.
- Do not be afraid of the “sphere” function. It is part of the visual module and it will make a nice and pretty sphere.
- There are more sophisticated ways of getting the highest point, I could even make a graph, but printing out all the values is the clearest way.
Here is part of the output that was printed:
Here also the highest point is 5.15 meters. One of the cool things about a program vs. a spreadsheet is that it is very easy to decrease the time steps. What if I re-run the program, but change dt to 0.001? The first thing you will notice is that the program takes longer to run (because it is printing out a lot more stuff). If you remove the “print” statements, it goes blazingly fast still. Looking at the output, I get the max height as 5.11 meters.
Ok. That is good enough for now. I still need to show you some more things with numerical calculations, but this is a good start. The next thing I need to show is a case where it is not so easy to do an analytical calculation.