I am trying to model planetary orbits, and have hit a snag. I get the orbits almost perfect, but every loop, it gets slightly out, which, I have been told, is due to rounding errors, which would make sense.
I am further told that the rounding errors lie where I work out the distance between the bodies. I am using Pythagoras' theorem:
sqrt(dx^2 + dy^2), where dx and dy are delta x and delta y respectively.
Apparently this is likely to give me rounding errors. Bare in mind that this is done 30 times every seconds, for an indefinite period of time, so even the smallest rounding errors become significant.
Thanks in advance for any advice.