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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started