I’m celebrating tonight. I’m delighted.
When I was aged about 17, I wondered if it would be possible to figure out where an orbiting rock went, by calculating its motion step by step over short intervals of time. But I couldn’t see how to do it, and it would be pretty laborious to calculate it all using a slide rule (remember them?) even if I did. But I never forgot the idea. There’s a book of mine somewhere which has got a curve drawn in it made up of straight line segments.
Go forward 30 years, and I was sitting with a physicist friend of mine in a pub in Bristol, smoking and drinking. And I asked him how easy it would be to write a computer programme to do that. “It’s quite straightforward,” he said. I asked him to explain. And there and then in the pub he sketched out how to do it on the back of an envelope.
I started work on it the very next day. And within a few hours, I had a rock going round a central sun. The only trouble was that, instead of going in a circle or ellipse, it slowly spiralled outwards (or maybe inwards, I can’t remember). So I went back to my physicist friend, and asked him why it was happening. He was puzzled, and went away to think about it. He even wrote his own simulation model. And he got the same result. But a few days later he came back and said, “I know what the problem is. I told you that in order to calculate the distance a body travels, you have to use the equation s = u.t + ½.a.t2. Well, that’s wrong. And it’s wrong because that equation is an integral. But our model is doing the integration as it goes along. So we’re integrating twice. It should just be s = u.t.” And after that the rocks started going round in circles and ellipses.
Wind forward another 20 years. I’ve now built up that same simulation model to include the entire solar system, and I’m able to get the positions of rocks from NASA, and I’ve even got a little spinning Earth with a map of the world drawn on it. But now I was finding that my model wasn’t really very accurate. The Earth went round the Sun in anything between 364 and 366 days. About right, but not very accurate. I’d been using a simple Euler approximation, and it was very approximate. But there was another way of calculating the motion which effectively entailed doing several approximations, and using each one to generate a more accurate curve. A couple of mathematicians called Runge and Kutta had developed a method of doing it in the early 20th century.
So I got hold of that, and added RK4 code into my simulation model. In tests, it looked fabulously accurate when I first tried it a couple of years ago. But somehow or other, when it came to the solar system, it was still pretty inaccurate. And I didn’t know why. I wondered if I’d have to increase the accuracy of my mathematics. Or use an even more detailed variant of RK4, like RK7 or RK10.
But in the last couple of months, I’ve begun to realise that the problem lay in the data I was using. The force acting on a body with mass M1 by another body with mass M2 is given by F = G. M1. M2 / r2, where G is the gravitational constant. It’s a constant you find in books. It’s given as 6.674×10−11 N⋅m2/kg2 in Wikipedia. But I gradually begun to realise that, wherever I looked, I’d find different values of it. For example today on one NASA website, Planet Physical Parameters, they say that G=6.67428 ×10−11 N⋅m2/kg2. But on another page, Astrodynamic Constants, they say gravitational constant G = 6.67259 ×10−11 N⋅m2/kg2. And on a third page, Horizons, the implicit value of G is 6.673849813830591 ×10−11 N⋅m2/kg2. They’re all different. And it’s the same for the masses of the Sun and planets: they’re all different too!
And the result of using various different values of G and various different masses of the planets, was that they’d end up thousands of kilometres away from where they should have been. But today I finally managed to cut through the fog, and found in the Horizons website a set of numbers that worked.
And now, when my Earth goes 4 times around the Sun, it ends up just 36 km from where it’s supposed to be. That’s an error of less than 10 km per year, or 10 km in every thousand million km travelled.
It’s like a camera coming into sharp focus. Everything is almost crystal clear.
And that’s why I’m celebrating with a bottle of Strathisla. That’s why I’m delighted. It’s taken me 50 years, but I got there in the end.
Only 36 more km to go.