Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from math import log
- def f(x):
- return x*x*(x+2)+log(x) -4
- epsilon = 1.0e-8
- x=[1,1.5]
- while abs(x[-1]-x[-2])> epsilon:
- x1,x2 = x[-2], x[-1]
- x.append(x2-f(x2)*(x2-x1)/(f(x2)-f(x1)))
- print(x[-1])
- 1.117033697609942
Add Comment
Please, Sign In to add comment