Computer Simulations

Giving the Problem to a Computer, to Work Out the Details

To take another example that might be familiar from high school — Physics class, this time — we look at the motion of an apple falling from a tree. First, imagine that the apple is set moving, but there is no gravity pulling it down. Newton says that its velocity would be a constant (if we ignore air resistance). Now we need to think carefully about what this means for the position of the apple at different instants of time. Velocity tells us how far something will move in a given amount of time. If we take some length of time, then the distance the apple will move in that length of time is just the velocity multiplied by the time:

distance = velocity × time.

This is a familiar formula, that we might use to figure out how far we can drive in a given amount of time, for example. But the formula assumes that the velocity is constant. To include gravity, we need to account for the changing velocity, which means that the formula above doesn't apply. Fortunately, there is a very similar formula for the accelerated case. To make it a little more clear, we just rewrite the formula above as

change in position = velocity × time.

Acceleration (Acceleration: Any change in the speed (Speed: For a wave, the speed of a particular point (such as its crest).) with which an object moves, or the direction in which it moves.) tells us how much the velocity changes in a given amount of time. By analogy, then, we can write

change in velocity = acceleration × time.

Now, because the acceleration is constant, there is a trick we can use to find the distance the apple falls in this amount of time: we need to use the average velocity. If the initial velocity was zero, and the final velocity is (acceleration × time), then the average velocity is (½ × acceleration × time), so

change in position = (½ × acceleration × time) × time.

In some sense, we have now solved this problem once and for all. Given a starting point, this formula shows us where the apple will be at any later time. We can show what the apple's path looks like: {First animation, showing the apple smoothly accelerating.}

Putting It On a Computer

This classic example from basic Physics is instructive in its own right. However, not all problems are quite so easy to solve. Imagine the we drop the apple a long distance from the Earth, and watch as it falls very far. We would see the force of gravity on the apple change, since gravity is stronger, the closer the apple comes to Earth. In this case, it would be much more difficult to write down a formula for the position of the apple, like the last one above. There are, in fact, tricks to figure out this problem, but suppose we are lazy, and just want a computer to do it for us. All we could tell the computer for sure would be the rule

change in velocity = acceleration × time.

Here, the acceleration depends on the apple's position, and — hence — on time. Notice that if the amount of time is very small, the change in velocity will be correspondingly very small, so the velocity would be approximately constant during that time period (Period: The length of time between two events. For a wave, this is usually the length of time it takes two successive peaks to pass a given point. This number is simply 1 divided by the Frequency of the wave.). In that case, we can use the rule that says

change in position = velocity × time.

The computer could start out at the initial velocity and the initial position, where it knows the acceleration. It could then move a tiny amount according to rule 2. Then, it could adjust the velocity according to rule 1, using the new position, and the new acceleration. Then repeat, over and over. This is just the same trick that we mentioned in the section on geodesics (Geodesic: Essentially the "straightest path" in a curved space or curved spacetime (Spacetime: A concept in physics which merges our usual notion of space with our usual notion of time.). This is the path followed by an object with no forces acting on it. In the curved spacetime of General Relativity (General Theory of Relativity: Einstein's version of the laws of physics, when there is gravity. Building on the Special Theory of Relativity (Special Theory of Relativity: Einstein's version of the laws of physics, when there is no gravity. The two fundamental concepts in the foundation of this theory are equality of observers, and the constancy of the speed of light. The first of these means that the laws of physics must be the same, no matter how quickly an observer is moving. The second means that everyone measures the exact same speed of light. This theory is useful whenever the effects of gravity can be ignored, but objects are moving at nearly the speed of light. It has been successfully tested many times in particle accelerators, and orbiting spacecraft. For objects moving much more slowly than light, Special Relativity (Special Theory of Relativity: Einstein's version of the laws of physics, when there is no gravity. The two fundamental concepts in the foundation of this theory are equality of observers, and the constancy of the speed of light. The first of these means that the laws of physics must be the same, no matter how quickly an observer is moving. The second means that everyone measures the exact same speed of light. This theory is useful whenever the effects of gravity can be ignored, but objects are moving at nearly the speed of light. It has been successfully tested many times in particle accelerators, and orbiting spacecraft. For objects moving much more slowly than light, Special Relativity becomes very nearly the same as Newton's theory, which is much easier to use. ) becomes very nearly the same as Newton's theory, which is much easier to use. ), this theory generalizes Einstein's work so that the laws of physics must be the same for all observers (Observer: A person or piece of equipment that measures something in physics. Frequently, we speak of an observer measuring time or a distance in a particular place. ), even in gravity. Einstein showed that gravity is best understood as a warping of the geometry of spacetime, rather than as a pulling of objects on each other. The crucial idea is that objects move along geodesics — which are determined by the warping of spacetime — while spacetime is warped by massive objects according to the formula \(G = 8 π T\). ), these paths may seem to be very curved — even appearing as circles or ellipses, for example. A geodesic is easily understood by looking at a very small region around the object. Even in highly curved spacetime, a small enough region will seem flat, so there is a natural idea of a "straight path". By following short segments, the whole geodesic is built up into one long path. ). If the path of the apple is smooth (which it is) we can just take many tiny, tiny steps, and end up at the right point.

There is just one problem with using this technique on a computer. If we take a large step, the velocity will be far from constant, so we will introduce some error by making this approximation. The larger the step is, the larger the error will be. To get exactly the right path, we need to take an infinite number of infinitely small steps. Computers may be much faster than humans at figuring these things out, but they're not infinitely fast. That means the computer's version of the path won't quite be the right one. The smaller the steps, the closer it will be. On the other hand, the smaller the steps, the longer it will take the computer to finish. This will always be a trade-off when giving this sort of problem to a computer.

We can try out this method. Click on the animation below to watch as the apple moves in discrete steps. As the computer computes where to put the apple, we can see the size of its errors by comparing to the correct solution, shown by the faint apples in the background. Move the slider around to adjust the size of the time steps. Note that making the time steps smaller brings the apples closer and closer to the correct solution. {Second, interactive animation, showing the apple moving in discrete steps.}

Simulating Relativity

Relativity provides us with perfect examples of problems that really are too difficult (as far as we can tell) to figure out with any clever tricks. In this case, the quantities in which we are interested are not the position or velocity of an apple, but the size of the numbers in the metric (Metric: A set of numbers which encodes information about the geometry of space or spacetime. Together with an understanding of how that information is encoded (using Coordinates) everything about the geometry can be understood.). For example, at a given point in space, the metric component \(g_{xx}\) will have a certain value. This value will change in time, just as the apple's position changes in time. Of course, the problem is not nearly so simple. At a given point in space, we have ten metric components, which is like having ten apples at each point in space. We also have many, many points in space, which leaves us with all ten components at each point in space — like having ten apples at every point in space, and trying to keep track of all of them. Each of these components has an effect on those near it. Using Einstein's Equations (Einstein's Equations: A set of "tensor" equations Einstein devised to describe how mass warps spacetime. The set of equations may be written as \(G = 8 π T\), where both \(G\) and \(T\) each represent a set of ten quantities. The \(G\) quantities represent the warping of spacetime, while the \(T\) quantities — the "Stress-Energy tensor" represent the mass.), we can take all these complications (and many more), and leave them to a computer to figure them out.