Guest User

Untitled

a guest
Apr 25th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.23 KB | None | 0 0
  1. from math import log
  2. def f(x):
  3. return x*x*(x+2)+log(x) -4
  4.  
  5. epsilon = 1.0e-8
  6. x=[1,1.5]
  7. while abs(x[-1]-x[-2])> epsilon:
  8. x1,x2 = x[-2], x[-1]
  9. x.append(x2-f(x2)*(x2-x1)/(f(x2)-f(x1)))
  10.  
  11. print(x[-1])
  12.  
  13. 1.117033697609942
Add Comment
Please, Sign In to add comment