Ariana1729

newton rhapson

Jun 17th, 2019
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.21 KB | None | 0 0
  1. def f(x):
  2.     return x**x-10.
  3. def NR(x):
  4.     e=10**-10#make this smaller to be more accurate
  5.     return x-e*f(x)/(f(x+e)-f(x))
  6. s=2
  7. for i in range(10):
  8.     print str(i)+"th interation, x="+str(s)
  9.     s=NR(s)
Add Comment
Please, Sign In to add comment