Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def f(x):
- return np.e**(.2*x)
- a=-2
- b=3
- n=4
- h=(b-a)/n
- def BoolesRule(h,f):
- w=np.array([a,a+h,a+2*h,a+3*h,b])
- return (2/45)*h*(7*f(w[0])+32*f(w[1])+12*f(w[2])+32*f(w[3])+7*f(w[4]))
- print(BoolesRule(h,f))
- #5.75899
- print("error:", 5.75899-BoolesRule(h,f))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement