Some Maple 18 short (and I believe elegant) code for doing gravitational simulations with N bodies in space:

 

N_body_problem.mw

 

Initial velocities have been tweaked to keep the system stable for the duration of the animation.

 

Please feel free to fiddle with its parameters, velocities and positions and/or N itself, to produce more interesting animations or re-use the code therein (You can safely ignore the (c), it's there just for archiving purposes).

 

The following are animations from three runs with N=4, N=3 and N=2, no other parameters changed.

 


Please Wait...