Is there a bisection method I can find online, specifically for python?
For example, given these equations how can I solve them using the bisection method?
x^3 = 9
3 * x^3 + x^2 = x + 5
cos^2x + 6 = x
Using scipy.optimize.bisect:
import scipy.optimize as optimize
import numpy as np
def func(x):
return np.cos(x)**2 + 6 - x
# 0<=cos(x)**2<=1, so the root has to be between x=6 and x=7
print(optimize.bisect(func, 6, 7))
# 6.77609231632
optimize.bisect
calls _zeros._bisect
, which is implemented in C.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With