SHARE
TWEET

Untitled

a guest Jan 15th, 2020 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top