Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. def f(x):
  2. return np.e**(.2*x)
  3.  
  4. a=-2
  5. b=3
  6. n=4
  7. h=(b-a)/n
  8.  
  9. def BoolesRule(h,f):
  10. w=np.array([a,a+h,a+2*h,a+3*h,b])
  11. return (2/45)*h*(7*f(w[0])+32*f(w[1])+12*f(w[2])+32*f(w[3])+7*f(w[4]))
  12.  
  13.  
  14. print(BoolesRule(h,f))
  15. #5.75899
  16. print("error:", 5.75899-BoolesRule(h,f))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement