1

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 ?

David Ketcheson
  • 16,522
  • 4
  • 54
  • 105
James C
  • 277
  • 2
  • 8

1 Answers1

4

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.

Implementing your system should be straightforward. Transform your system into first-order form, and then model your implementation after the Lorenz system attractor example on the odeint website.

Geoff Oxberry
  • 30,394
  • 9
  • 64
  • 127
  • Thank you for your answer, especially the warnings. I wouldn't worry about x=0 too much, because given what I know about the system I am solving, I believe this state cannot occur, at least not in a reasonable interval of integration that I want to observe. I would like to ask a thing about Lorenz system example. Are dxdt[0], dxdt[1] and dxdt[2] the "equivalent" for the IJK coordinates in my system ? Thank you. – James C Nov 18 '14 at 03:12
  • 1
    @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[0] through x[5], 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 03:17