Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def f(x):
- return x**2 - 5
- a = int(input())
- b = int(input())
- e = int(input())
- x = a
- f1 = f(a)
- h = b - a
- while abs(h) > e:
- h = h / 3
- x = x + h
- f2 = f(x)
- while f1 * f2 > 0:
- x = x + h
- f2 = f(x)
- x = x - h
- x = x - h / 2
- f1 = f(x)
- print(x, f1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement