Bara223
Using the bisection method estimate the root of
g(x)= 2+x-e^{x}
between 1 and 2 within 0.05 of accuracy
Using the bisection method estimate the root of
g(x)= 2+x-e^{x}
between 1 and 2 within 0.05 of accuracy
Great Question!
Using the bisection code, what you can do is edit the while loop to return the value when the error meets the 0.05 requirement instead of machine precision so that
while abs(a-b) > 0.05 and cnt < 100:
Running the code with
def f(x): return 2+x-np.exp(x)
bisection(f,1,2, True)
will give you the output of the value 1.15625 after 5 iterations