daily pastebin goal
10%
SHARE
TWEET

2016AB2c.py

calcpage Jun 23rd, 2016 740 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/python
  2. #MrG 2016.0621 2016AB2
  3. #2c) x(0)=-3.815
  4. import math
  5. def f(t):
  6.     return 1+2*math.sin(t**2/2)
  7.  
  8. a=float(0)
  9. b=float(4)
  10. for x in range(5):
  11.     h=(b-a)/10**x
  12.     l=sum([f(a+i*h)*h for i in range(10**x)])
  13.     r=l-f(a)*h+f(b)*h
  14.     print 2-(l+r)/2
RAW Paste Data
Top