title: integrate 3 body system in python
body: <p>This is more mathemathical question.</p>
  
  <p>We have 3 body system, with known initial parametrs like positions, masses, velocityes. This make system like <br>
  <a href="https://i.stack.imgur.com/VyZjB.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VyZjB.gif" alt="enter image description here"></a></p>
  
  <p>i and j  = 1,2,3  <br>
  So question is how to deal with this, to feed this system to <strong>scipy odeint</strong> ?</p>
  
  <p><strong>UPDATE</strong><br>
   I wrote code</p>
  
  <pre><code>from scipy import linspace
  from scipy.integrate import odeint
  
  def rf(i, j, r):
      x1, y1, z1 = r[0]
      x2, y2, z2 = r[1]
      x3, y3, z3 = r[2]
      r12 = ((x1-x2)**2+(y1-y2)**2+(z1-z2)**2)**2
      r13 = ((x1-x3)**2+(y1-y3)**2+(z1-z3)**2)**2
      r23 = ((x2-x3)**2+(y2-y3)**2+(z2-z3)**2)**2
      if i == 1:
          if j == 2:
              r = r12
          elif j == 3:
              r = r13
      if i == 2:
          if j == 1:
              r = r12
          elif j == 3:
              r = r23
      if i == 3:
          if j == 1:
              r = r13
          elif j == 2:
              r = r23
      return r
  
  
  def dotf(r, t0):
      x1, y1, z1 = r[0]
      x2, y2, z2 = r[1]
      x3, y3, z3 = r[2]
      x = [x1, x2, x3]
      y = [y1, y2, y3]
      z = [z1, z2, z3]
  
      k2 = 6.67e-11
      m = [2e6, 2.2e7, 0.1e3]
  
      for i in range(1, 3, 1):
          xs, ys, zs = 0, 0, 0
          for j in range(1, 3, 1):
              if i != j:
                  r = rf(i, j, r)
                  xs = xs + m[j]*(x[i]-x[j])/r
                  ys = ys + m[j]*(y[i]-y[j])/r
                  zs = zs + m[j]*(z[i]-z[j])/r
          x[i] = -1 * k2 * xs
          y[i] = -1 * k2 * ys
          z[i] = -1 * k2 * zs
      return [[x1,y1,z1], [x2,y2,z2], [x3,y3,z3]]
  
  
  t = linspace(0, 50, 1e4)
  r1 = [1, 2, 1]
  r2 = [0.5, 0.1, 3]
  r3 = [0.6, 1, 1.5]
  r = [r1, r2, r3] 
  
  u = odeint(dotf, r, t)
  </code></pre>
  
  <p><br>
  and get output error: <br></p>
  
  <pre><code>Traceback (most recent call last):
    File "3b.py", line 73, in &lt;module&gt;
      u = odeint(dotf, r, t)
    File "/usr/local/lib/python2.7/dist-packages/scipy/integrate/odepack.py", line 148, in odeint
      ixpr, mxstep, mxhnil, mxordn, mxords)
  ValueError: object too deep for desired array
  </code></pre>