# Runge kutta 4 & N-body problem

1. Aug 27, 2009

### albatros

Hello ppl,
I'm new here.

I'm trying to compute RK4 for N-body problem. But after computing I'm getting strange numbers. So here are the formulas for these problem.

Start from two differential equations of first order:

[1] d$$\vec{r}$$/dt = $$\vec{v_i}$$

[2] $$\frac{d\vec{v_i}}{dt}$$ = $$\gamma$$ $$\sum\frac{m_k}{r_i^{3}}$$ * $$\vec{r_i}$$

So steps are:

$$\vec{k1}$$ = $$\gamma$$ $$\sum \frac{m}{\left|r_ - r_[j]\right|^2}$$ * dt

$$\vec{l_{1}}$$ = $$\vec{v_{i}} * dt$$

$$\vec{k_{2}}$$ = $$\gamma$$ * $$\sum$$ $$\frac{m_{}}{\vec{(r_{} + \frac{\vec{l_{1}}}{2}}) - (r_{[j]} + \frac{\vec{l_{1}}}{2})} ^2$$ *dt

$$\vec{l_{2}}$$ = ( $$\vec{v_{i}} *\frac{\vec{k_{1}}}{2}$$) * dt

$$\vec{k_{3}}$$ = $$\gamma$$ * $$\sum$$ $$\frac{m_{}}{\vec{(r_{} + \frac{\vec{l_{2}}}{2}}) - (r_{[j]} + \frac{\vec{l_{2}}}{2})}$$ * dt

$$\vec{l_{3}}$$ = ( $$\vec{v_{i}} *\frac{\vec{k_{2}}}{2}$$) * dt

$$\vec{k_{4}}$$ = $$\gamma$$ * $$\frac{m_{}{|(\vec{r_{} + \vec{l_{3}})}) - \vec{r_{} + \vec{l_{3}})}$$

$$\vec{l_{4}}$$ = ( $$\vec{v_{i}} *\vec{k_{3}}$$) * dt