# How can I call the Boost C++ odeint Runge-Kutta integrator for a system of ODEs?

I would like to use Boost C++ odeint Runge-Kutta integrator on a system that looks like this :

$$\ddot x = - \frac A{||x||^3} * x$$

$x$ is a vector in 3D space, so basicaly $x(i, j, k)$
$\ddot x$ is its second derivative
${||x||^3}$ is magnitude cubed of $x$
$A$ is a constant

I know the initial conditions of the problem, namely $\dot x(t=0)$ and $x(t=0)$ .

I have checked this example in the odeint documentation, as well as the full code here. Examples show use of odeint with a single ODE. But my problem would have to be split into 6 ODE.

Can I use odeint Runge Kutta method for such a system ( 6 ODEs ) and if yes, is there any example that I can follow to help me implement my problem ?

In theory, sure, although I'd be wary of your particular ODE system for a couple reasons: (1) the right-hand side is undefined when $x = 0$, which will trip up any integrator in the Boost C++ suite, (2) based on its similarity to functions known to be non-Lipschitz in neighborhoods of the origin, even existence of solutions is unclear.
• @JamesC: You would introduce an auxiliary variable, say, $y$ and set $\dot{x} = y$, and $\ddot{x} = \dot{y} = -Ax/\|x\|^{3}$. At that point, the abstraction is basically that you have a vector of six state variables $x[i]$, $x[j]$, $x[k]$, $y[i]$, $y[j]$, $y[k]$, so if you want to think of these as being x through x, you're representing the same quantities, just relabeled so that they're in a form convenient for use in an ODE solver. – Geoff Oxberry Nov 18 '14 at 3:17