Aaron Gruberg

N-Body Simulation using a 2nd order Leap Frog algorithm

I wrote a program that models the gravitational acceleration for any number of bodies(N-bodies) in a vacuum. I used 9 bodies, the Sun and 8 planets.
Only the Sun, Earth, Mars, and Jupiter were included in the video below. I did this so I could include a display of coordinates in the figure to illustrate
the precision of each data point. It can be seen that while Earth completes 1 orbital period around the Sun, Jupiter has only completed 1/12 of an orbital
period. My code uses an initial set of position and velocity coordinates taken from the NASA Ephemeris on November 1st, 1988. The final calculated positions
are for April 2014. A there is a time step of 20 hours between each new position coordinate that was caculated. Only every 50th position coordinate was used
in the animation. A 2nd order Leap Frog algorithm was written to compute the acceleration that one mass experiences due to another. These accelerations were
used to find the new positions of each mass. A text file was created and filled with columns of x, y, and z coordinates for each mass. Data from this text
file was animated in MatLab.

View my C and MatLab code.
View a brief explanation of my method.