the bisection method single function call ( ( )is required in each iteration since ( becomes the "oldf( and may simply be copied as f_x f_x (the exception is the very first iteration where two function evaluations are neededrunning secant_method pygives the following printout on the screennumber of function calls solution is as with the function newtonwe place secant in the file nonlinear_solvers py for easy import and use later the bisection method neither newton' method nor the secant method can guarantee that an existing solution will be found (see exercises and the bisection methodhoweverdoes that howeverif there are several solutions presentit finds only one of themjust as newton' method and the secant method the bisection method is slower than the other two methodsso reliability comes with cost of speed to solve oe with the bisection methodwe reason as follows the first key idea is that if xd is continuous on the interval and the function values for the interval endpoints (xl xr have opposite signsf xmust cross the axis at least once on the interval that iswe know there is at least one solution the second key idea comes from dividing the interval in two equal partsone to the left and one to the right of the midpoint xm by evaluating the sign of xm /we will immediately know whether solution must exist to the left or right of xm this is sosince if xm we know that xhas to cross the axis between xl and xm at least once (using the same argument as for the original intervallikewiseif instead xm we know that xhas to cross the axis between xm and xr at least once in any casewe may proceed with half the interval only the exception is if xm in which case solution is found such interval halving can be continued until solution is found "solutionin this caseis when jf xm / is sufficiently close to zeromore precisely (as before)jf xm / where is small number specified by the user the sketched strategy seems reasonableso let us write reusable function that can solve general algebraic equation xd (bisection_method py)def bisection(fx_lx_repsreturn_x_list=false)f_l (x_lif f_l* (x_r print "errorfunction does not have opposite signs at interval endpoints!sys exit( x_m float(x_l x_r)/ f_m (x_miteration_counter