# Distance traveled in a simple two body problem [duplicate]

I'm trying to program an $N$-body simulation and I'd like to be able to test it with a known solution to a simple, two-body problem. I've looked at multiple sources, but I just don't know how to apply it to my simple test case.

Two objects at rest placed 10 meters apart with mass of 1. The force between them is a modified gravitational force of F = 10 * m1 * m2 / r^2. How long will it take for each object to travel 4 meters?

-

## marked as duplicate by Qmechanic♦Feb 27 '13 at 10:26

Possible duplicates: physics.stackexchange.com/q/19388/2451 and links therein. – Qmechanic Feb 27 '13 at 10:26

First of all, this is by no means a trivial problem. The usual method goes something like the following. The force from mass 2 on mass 1 is:

$$F_{21} = G\frac{m_1 m_2}{(x_2 - x_1)^2} = m_1 \ddot{x}_1$$

Similarly:

$$F_{12} = -F_{21} = -G\frac{m_1 m_2}{(x_2 - x_1)^2} = m_2 \ddot{x}_2$$

Canceling masses and subtracting the equations from each other gives:

$$\ddot{x}_2 - \ddot{x}_1 = \frac{d^2}{dt^2}(x_2 - x_1) = -G\frac{m_1 + m_2}{(x_2 - x_1)^2}$$

If we define $~r=x_2-x_1$ as the separation between the masses, then our equation becomes:

$$\ddot{r} = -G\frac{m_1 + m_2}{r^2}$$

Now it gets a bit trickier. We use the fact that $\ddot{r}=\dot{r}~d\dot{r}/dr$ to separate the differential equation:

$$\dot{r}~d\dot{r}=-G\frac{m_1 + m_2}{r^2}~dr$$

For $\dot{r}=0$ at $r_0$ (they're initially at rest), the integral of the above yields:

$$\frac{dr}{dt} = \sqrt{ \frac{2 G (m_1 + m_2)}{r} - \frac{2 G (m_1 + m_2)}{r_0}} = \sqrt{ \frac{2 G r_0 (m_1 + m_2) - 2 G r (m_1 + m_2)} {r\ r_0}}$$

So then:

$$\Delta t=\sqrt{\frac{r_0}{2 G (m_1 + m_2)}}~\int_{r_0}^{r} \sqrt{\frac{r}{r_0 - r}}~dr$$

In your case you've set $G=10$, $r_0=10$, and the masses each to one. When they've each traveled four meters, $r=2$. So you need to integrate the above from 10 to 2.

-