Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- delta = 1e-6
- def f(x): return 2 * 0.26459 * x + 0.89861 - math.cosh(x)
- def bisection_method(a, b):
- i = 0
- while abs(b - a) > 2 * delta:
- z = 0.5 * (a + b)
- if f(a) * f(z) < 0:
- b = z
- else:
- a = z
- i += 1
- return (a + b) / 2.0
- print "first point - %f" % bisection_method(0.0, 0.5)
- print "second point - %f" % bisection_method(0.5, 1.0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement