SHARE
TWEET

Untitled

a guest Apr 18th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top