Question: Modify this function a. Modify the algorithm to take the approximate error and the maximum number of iterations in consideration b. code the false-position algorithm
Modify this function a. Modify the algorithm to take the approximate error and the maximum number of iterations in consideration b. code the false-position algorithm
def bisect_naive(func, xl, xu, maxit = 20): ''' Input: func = main function we want to compute the roots xl = lower bound --> guess xu = upper bound --> guess Output: xr = root estimate or error message if initail guess [xl, xu] is not good --> does not bracket the solution ''' if func(xl) * func(xu) > 0: return 'Initial guess [xl, xu] does not bracket the solution' for i in range(maxit): xr = (xl + xu)/2 if func(xr)*func(xl) >0: xl = xr else: xu = xr return xr
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
