I'm learning about using simpson's method for integration. I've been reading material to learn the basis of using it but I am still having trouble even getting it to work
import numpy as np
import scipy.integrate as integrate
x = np.array[0.1,50]
y = 0.04*(x**(0.2*x))
result = integrate.simps(y,x)
print result
My problems with the above code are:
1) The first issue has been solved and edited
2) I don't fully understand how the integrate command should work. I know that in integrate.simps(y,x) y represents my function/polynomial to be integrated and x represents the points at which y is evaluated.
3) I do not understand how or where to adjust the number of intervals (N) for my integral
4) my x = np.array[] produces an error message 'builtin_function_or_method' object has no attribute ' getitem '
The function i'm trying to integrate is:
∫x*(0.4x^(.2x))
upper limit : 50.0
lower limit : 0.1
对于您的第二个问题,请为 array() 使用括号
x = np.array( [0.1,50] )
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.