daily pastebin goal
10%
SHARE
TWEET

2016AB2b.py

calcpage Jun 23rd, 2016 779 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/python
  2. #MrG 2016.0622 2016AB2
  3. #2b) v(2.707)==0
  4. import math
  5.  
  6. def f(t):
  7.     return 1+2*math.sin(t**2/2)
  8. print f(4)
  9.  
  10. def diff(t,h=10**-6):
  11.     return (f(t+h)-f(t))/h
  12.  
  13. def newton(g):
  14.     return g-f(g)/diff(g)
  15.  
  16. g=2.5
  17. for x in range(5):
  18.     print g
  19.     g=newton(g)
RAW Paste Data
Top