title: Is there a matrix (numpy) equivalent to these recursive equations?
body: <p>I have the following recursive equations I want to implement in Python<br />
  (the background is financial markets):</p>
  <p><img src="https://i.stack.imgur.com/cF2Pu.png" alt="" /></p>
  <p>This is easily done sequentially, using a loop:</p>
  <pre><code>def compute(x, y, χ, γ, a0, b0):
      a = [a0]
      b = [b0]
  
      α = [a[0]]
      β = [b[0]]
  
      for i in range(len(x)):
          a.append(-α[i]*x[i] + β[i]*y[i]*γ[i])
          b.append(-β[i]*y[i] + α[i]*x[i]*χ[i])
  
          α.append(α[-1] + a[-1])
          β.append(β[-1] + b[-1])
      return α, β
  </code></pre>
  <p>A small-arrays example:</p>
  <pre><code>x = np.array([0.6, 0.4, 0., 0., 0.9])
  y = np.array([0., 0., 0.3, 0.9, 0.])
  
  χ = np.arange(100., 105., 1.)
  γ = 1. / (χ - 1.)
  
  print(np.array(compute(x, y, χ, γ, 1., 0.)))
  </code></pre>
  <p>would produce</p>
  <pre><code>&gt;&gt;&gt; [[ 1.          0.4         0.24        0.46621782  0.93661782  0.09366178]  
       [ 0.         60.         76.16       53.312       5.3312     92.99862812]]
  </code></pre>
  <p>is there a way to do it in NumPy (which I expect to significantly speed up the computation)?</p>
  <p>In other words: to compute the whole a and b vectors without using a loop, just NumPy functions?</p>