# How to use numerical analysis to calculate the motion of any planet?

I have just started reading the Feynman lectures and in chapter 9, he explains how one might use numerical analysis to calculate the motion of a spring which can be extended to calculate the motion of earth around the sun ( assuming the sun is fixed ).

Feynman states that one may calculate the motion of Neptune or Jupiter or whatever even if the sun is not taken to be stationary. These are the equations he states:

Now let us see how we can calculate the motion of Neptune, Jupiter, Uranus, or any other planet. If we have a great many planets, and let the sun move too, can we do the same thing? Of course we can. We calculate the force on a particular planet, let us say planet number i, which has a position $x_i,y_i,z_i$ (i=1 may represent the sun, i=2 Mercury, i=3 Venus, and so on). We must know the positions of all the planets. The force acting on one is due to all the other bodies which are located, let us say, at positions $x_j,y_j,z_j$. Therefore the equations are: \begin{align} m_i\,\frac{dv_{ix}}{dt}&= \sum_{j=1}^N-\frac{Gm_im_j(x_i-x_j)}{r_{ij}^3},\notag\\ \label{Eq:I:9:18} m_i\,\frac{dv_{iy}}{dt}&= \sum_{j=1}^N-\frac{Gm_im_j( y_i- y_j )}{r_{ij}^3},\\ m_i\,\frac{dv_{iz}}{dt}&= \sum_{j=1}^N-\frac{Gm_im_j( z_i- z_j )}{r_{ij}^3}.\notag \end{align} Where $$\label{Eq:I:9:19} r_{ij}=\sqrt{(x_i-x_j)^2+(y_i-y_j)^2+(z_i-z_j)^2}.$$

Then he states that,"Then when we have all initial positions and velocities we can calculate all the accelerations by first calculating all the distances". Alright, if we do have all initial velocities and distances of all the planets, how do we use that to calculate all future positions and velocities of planet $i$ as the positions and velocities of planet $j$ will be affected by planet $i$ as well! ?

Here is the link to the chapter:http://www.feynmanlectures.caltech.edu/I_09.html

• Would Computational Science be a better home for this question? – Qmechanic Apr 2 '18 at 5:49
• Qmechanic , I really don't know what computational science is. If you think, this question belongs there, please shift it to its required place. – Aaryan Dewan Apr 2 '18 at 6:50
• Have you tried googling your title? ... Feynman discusses how to solve the motion numerically in sections 9-6 and 9-7. – sammy gerbil Apr 2 '18 at 12:52
• @Sammy, i read those sections but I did not understand them. That's why I provided the link! – Aaryan Dewan Apr 2 '18 at 13:44
• Feynman explains the procedure in detail for one planet, in his usual simple style, giving an example of the calculations. What is it that you do not understand about this explanation? – sammy gerbil Apr 2 '18 at 14:36

The idea behind numerically solving differential equations is to repeatedly calculate what happens over small successive steps. You take the state of the system at one time, use that to calculate the state of the system at the next step. Rinse and repeat.

Let's use a simpler example: a single mass on a spring in one dimension.

$$m\frac{\mathrm d^2x}{\mathrm dt^2}=-kx$$

We can break this up into first order equations

$$\frac{\mathrm dx}{\mathrm dt}=v\\ \frac{\mathrm dv}{\mathrm dt}=-\frac{k}{m}x$$

Next, we can turn this differential equation into a difference equation

$$x_{i+1}-x_i=v_i\Delta t\\ v_{i+1}-v_i=-\frac{k}{m}\Delta t$$

If you start with a given $x_0$, $v_0$, and $\Delta t$, you can then calculate $x_1$ and $v_1$.

This is only the simplest method of numerically solving a differential equation. There are some drawbacks to this method, namely that it tends to overshoot. More advanced methods exist.

• "More advanced methods" include Runge-Kutta. Any resource discussing it is likely to review alternatives as well. – J.G. Apr 2 '18 at 9:16
• Thanks for your answer but this does not answer me question. – Aaryan Dewan Apr 2 '18 at 10:19
• @aaryan Why doesn't this answer work for you? We don't need to worry much that planet j is also affected by planet i because we use a small time step $\Delta t$, so the position and velocity of each planet doesn't change very much over a single time step. FWIW, when doing numerical integration for gravitational motion it's important to use a symplectic integrator, eg Leapfrog or Verlet, so that energy is conserved. – PM 2Ring Apr 2 '18 at 12:36