- #1
ver_mathstats
- 260
- 21
Code:
import numpy as np
def num_int(f,a,b,n):
dx=(b-a)/n
x=np.arange(a,b,step=dx)
y=f(x)
return y.sum()*dx
def rational_func(x):
return 1/(1+x**2)
print(num_int(rational_func,2,5,10))
Here is my code for the left endpoint, I know this code works because I compared it to an actual calculator the two values and they ended up being the same, however I am struggling to figure out how to do the right endpoint code, I'm not exactly sure what to change.
Thank you.