I have
y1=[ 9.49110000e-004 4.74145420e-004 1.41847155e-008 3.33228420e-028
3.76352289e-081 4.48206815e-193 0.00000000e+000 0.00000000e+000
0.00000000e+000 0.00000000e+000 0.00000000e+000]
x=[ 112. 111.97667396 111.90666665 111.78989038 111.62619837
111.41538384 111.15717866 110.85125168 110.49720654 110.09457901
109.64283388]
All the y
values are positive, so the area under the curve should be positive. But when I try to use Simpson's rule to integrate
from scipy.integrate import simps
b= simps(y1, x)
print b
I am getting -2.45630795891e-05
as the answer. What am I doing wrong?
x
is decreasing, so you're integrating from right to left. This flips the sign of the result.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With