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])
I tried to run this simple script and I get the error "IndexError: index out of bounds" ...
Please any idea to avoid this error? I understand that the error caused by the number 5, but I can't change that as the a2 array is loaded from a txt (a2= np.loadtxt('data.txt',unpack=True, usecols=[1]) which its length is 5
Please any idea?