Somebody asked me this week whether we can model everything in the real world yet. No, and the reasons are more fun to play with than to read about. So here are ten toys. Each one runs on our own engine, powered by rainshower, and each one prints the number that would catch it lying.
Throw something
Pick a ball, a speed and an angle. The dashed arc is the throw with no air, and the solid one goes through sea-level air.
The no-air throw is checked against the formula every physics class uses, and at 30 m/s and 30 degrees they agree to a centimetre: 82.48 m. That check matters because it is the only thing on the panel you can prove from a pencil.
The air is where it gets interesting. Thrown at 30 m/s, a ping-pong ball loses 86 percent of its range to air, and a shot put loses 2.9 percent. Same air, same throw. The difference is how much mass sits behind each square centimetre of the front. Drop a ping-pong ball from high enough and it settles at 8.3 m/s, its terminal speed, and the simulation lands on that number to within half a percent.
Two pendulums
Two double pendulums, one gold and one blue, let go from the same place except for a gap of a billionth of a radian. That is far smaller than anything you could set up by hand. For a while they are one pendulum. Then they are not.
At the "wild" start, they come a tenth of a radian apart after 19.6 seconds. Make the gap a thousand times smaller and they still part, only a little later. That is chaos: the equations are exact, nothing random is added, and the future still runs out.
The meter says whether to believe it. The energy of a frictionless pendulum cannot change, and over thirty seconds it drifts by three parts in a billion. So the parting is the physics and not the arithmetic. Run two identical starts and they stay identical to the last digit, which rules out the other suspect, noise.
This is the real reason nobody models everything. Not a lack of computers: a lack of starting conditions measured to the billionth decimal place, and a world that needs them. Light between two black holes does the same thing, at every scale we looked.
Orbit
This is my favourite, because it is wrong on purpose.
One moon, one start, flown three ways at once. Each way is a method for stepping forward in time, the same choice every simulation makes somewhere inside.
- Euler takes the direction the moon is heading now and steps along it. It is the first method anyone learns.
- RK4 tries four slopes per step and averages them.
- Verlet is built so that energy stays put.
The same moon flown three ways, 6.1 orbits in at 200 steps an orbit. Red is Euler, which has invented 50.4 percent more energy by now. Green is Verlet and the blue ring is RK4, both still on the circle. A frame from the toy above.
Watch the red one. It draws a smooth, calm, believable orbit that grows. Nothing on the picture says it is wrong. On a curve, a straight step always lands a little outside the curve, so every step adds a little energy, and in ten orbits at 200 steps each, Euler invents 58 percent more energy than the moon started with. RK4, same start and same step, holds the energy to five millionths of a percent, and Verlet to a ten-billionth.
That is the thesis of this whole blog in one toy: a well formed answer is not a true one. The red orbit is well formed and false, and the only thing that catches it is the number beside it. Push the steps up to 1,000 an orbit and Euler behaves better, 33 percent in ten orbits instead of 58, but it never stops drifting. It only drifts slower.
Bounce
Drop a ball from a metre onto a floor that gives back a fraction e of its speed each time. Each bounce is e squared as high as the last, so there are infinitely many bounces, and the times still add up to a finite sum. At e = 0.8 the ball is at rest after 4.06 seconds, having bounced infinitely often. The test suite checks that closed form against adding up 400 bounces one at a time.
The right-hand ball is how most games do it: step time forward by 1/60 of a second, and if the ball is found below the floor, flip its speed. It looks fine for the first few bounces. Then the bounces get shorter than a step, and it never stops. Twenty seconds in, at e = 0.8, it has "bounced" 174 times and still holds 1 percent of its energy, sixteen seconds after the real ball went still. At e = 0.5 it is 564 bounces and 0.21 percent, and at e = 0.9 it is 745 bounces and 0.10 percent. The buzzing on the floor reads as settling down. It is a step size pretending to be a floor: the same lesson as the Euler orbit above it, a smooth, believable picture of the wrong answer.
Counting pi
A small block sits between a wall and a big block sliding towards it. Every collision is perfectly elastic, with no friction. Count the collisions. With equal masses it is 3. Make the big block 100 times heavier and it is 31, then 314, then 3,141 at a million times, and 31,415 at a hundred million. The engine's tests go on to 314,159 at ten billion.
It is a known result, which I remember as Gregory Galperin's from 2003. That credit is from memory, not from the paper. The reason is geometry: drawn in the right coordinates, every collision turns the state by the same small angle, and the count is how many of those angles fit in a half turn. That gives a closed form, and it is the check. The simulation and the closed form agree at every mass ratio tried, and energy holds to within two parts in 10^14. Nothing here is stepped: each collision is solved exactly, which is why a hundred million to one works at all.
Rope
A rope made the way game physics has made it since 2001: points joined by links, pulled back to length a few times a frame. The dashed curve behind it is where a real chain hangs, from its exact formula. Give it one pass a frame and the rope ends up 75 percent longer than it is. A Game Rope Is Only as Stiff as Its Solver has the rest, including why adding links makes it worse.
Orbit Golf
The last tab is a game. Drag back, let go, and every planet on the board pulls on the ball. It has its own post, with a map of all 273,600 shots it allows and the two level hints that map caught lying.
Foucault
A pendulum on a long wire, seen from above, with the Earth turning under it. Nothing in the code tells the swing to turn, and it turns at the textbook rate anyway: 11.3 degrees an hour in Paris, not at all on the equator. Then give it an ellipse half a millimetre wide and watch it fake the whole effect. The full story, with the numbers, is in Foucault's pendulum, and the half millimetre that can fake it.
Archimedes
A ship on greased timbers, one person, and a chain of block and tackles between them. With perfect pulleys any force moves any weight, as Plutarch has Archimedes claim. With friction at every sheave, one tackle hits a ceiling, and only tackles in series get the ship moving, slowly. The whole story is in can any force move any weight?
Little Rocket
Build a rocket from a few parts and try to get it into orbit round a small made-up planet. The ledger in the readout accounts for every metre per second the engines give, which is how the game shows that orbit costs about a thousand metres per second more than orbital speed. How to fly it, and where the speed goes, is in Little Rocket.
What is and is not modelled
The toys run on a small module of our engine, tested against the closed forms quoted above: the no-air range, the textbook pendulum period (to a hundredth of a percent), the Kepler period of a circular orbit, a terminal speed, the bounce's finite sum, the collision count's closed form, and conservation of energy. The air is the same standard atmosphere the engine uses for falling rocks.
The ball sizes, masses and drag coefficients are reference values I typed from memory and have not checked against a primary source, and the drag coefficient is held constant, where a real ball's changes with speed and spin. Everything else is physics rather than data, and the panel shows the check that would fail if it were wrong.