Advertisement
Guest User

Untitled

a guest
Jan 15th, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.28 KB | None | 0 0
  1. def f(x):
  2.     return()
  3. a = float(input())
  4. b = float(input())
  5. eps = float(input())
  6. while abs(b - a) > eps:
  7.         x = (a + b) / 2.0
  8.         fx = f(x)
  9.         fa = f(a)
  10.         if (fx < 0 and fa < 0) or (fx > 0 and fa > 0):
  11.             a = x
  12.         else:
  13.             b = x
  14. print(x)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement