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

This question already has an answer here:

• Radial fall in a Newtonian gravitational field [duplicate] 1 answer

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?

-

– Qmechanic♦ Feb 27 at 10:26

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

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

## 1 Answer

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.

-
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 8, "mathjax_display_tex": 7, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "github"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "english_confidence": 0.9466270208358765, "perplexity_flag": "head"}