The motion of planets is described by Newton's law of motion and Newton's law of gravitation. It is also a kind of trajectory problem, so we can get the trajectory of a planet through an ODE. The Inverse-Square law of the gravitation keeps the planet move stably, this law is also applied in electric field. In this program, I confirmed the Inverse-Square law keeps the motion stable, and plot a simple configuration of three planets' orbits. Also, a gif figure was plotted as an 3_D model of the motion of planets.
The psudocode:
Since this is a periodic problem, so we use the Euler-Cromer method to solve it. As all the trajectory problems, we use the velocity and position of step to calculate that of step . The looping statement are as follows:
This is a single planet motion equation, we can use this class and define different object as different 'Planets'. As for the motion of planet that different obey the Inverse-Square law, we just change the number 3 to other numbers.
The result:
First, a configuration was plotted as follows:
The green line motion as a circle, and the others motion as an ellipse, that is exactly what Kepler told us.
As a practice, I also drawed the three dimentional configuration of the motions through the program, that really look beautiful:
Second, I also change the value of the index of the Newton's law of gravitation, and research the motion of the planet:
We can find that when the index is exactly 2, the trajectory is exactly an ellipse. When the changes are small, such as 0.01, the orbit can keep stable ellipse with a little disturbance. When the change is as large as 0.5, the change of the orbit is so large that cannot keep stable. Well, now that the earth is stable, we must sdmit the Inverse-Square law.
The conclusion:
In this program, some configurations are drawn, and the Inverse-Square law is proved.