three-body - Perl script to illustrate Math::RungeKutta
This script uses Math::RungeKutta integrate Newton's inverse-square law of gravity for three objects moving in a two-dimensional plane.
It uses rk4_auto to adjust the step-size automatically, and rk4_auto_midstep for a smoother display.
The display assumes you are running something sufficiently vt100-compatible to understand moveto and reverse. It looks best if you run a large square window with a tiny font, perhaps somewhere round 118x80.
You can experiment with changing the masses @m of the objects or their initial positions and velocities @y, and you will probably discover how sensitive three-body motion is, and explore some of the many things that can go wrong during numerical integration :-)
Peter J Billam www.pjb.com.au/comp/contact.html
Based on Math::RungeKutta