title: Python numpy loop index out of bounds error
body: <pre><code>a1 = np.random.random_sample(10)
  
  a2 = np.random.random_sample(5)
  
  a3 = np.zeros([10])
  
  
  for i in range(0,9):
  
      a3[i] = ((a2[i]+a2[i+1])/2.) * ((a1[i+1]-a1[i])/2.) * (a1[i]*a2[i])
  
      print(i, a3[i])
  </code></pre>
  
  <p>I tried to run this simple script and I get the error <code>"IndexError: index out of bounds"</code> ...
  Please any idea to avoid this error? I understand that the error caused by the number <code>5</code>,  but I can't change that as the <code>a2</code> array is loaded from a txt <code>(a2= np.loadtxt('data.txt',unpack=True, usecols=[1])</code> which its length is <code>5</code>
  Please any idea?</p>