Advertisement
calcpage

2016AB2c.py

Jun 23rd, 2016
1,098
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.27 KB | None | 0 0
  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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement