title: Different result with vectorized code to standard loop in numpy
body: <p>I have the following two functions:</p>
  
  <pre><code>def loop(x):
      a = np.zeros(10)
      for i1 in range(10):
          for i2 in range(10):
              a[i1] += np.sin(x[i2] - x[i1])
      return a
  </code></pre>
  
  <p>and</p>
  
  <pre><code>def vectorized(x):    
      b = np.zeros(10)
      for i1 in range(10):
          b += np.sin(np.roll(x, i1) - x)
      return b
  </code></pre>
  
  <p>However, when I run both, I find that their results slightly differ:</p>
  
  <pre><code>x = np.arange(10)
  a, b = loop(x), vectorized(x)
  print b - a
  </code></pre>
  
  <p>I get:</p>
  
  <pre><code>[  2.22044605e-16   0.00000000e+00   0.00000000e+00   6.66133815e-16
    -2.22044605e-16   2.22044605e-16   0.00000000e+00   2.22044605e-16
     2.22044605e-16   2.22044605e-16]
  </code></pre>
  
  <p>which is very small, but in my case, affects the simulation. If I remove the np.sin from the functions, the difference disappears. Alternatively the difference also goes away if use np.float32 for x, but this is part of an ode which is being solved by by a solver that uses float64. Is there a way to resolve this difference?</p>