elsea ( + )/ return #call the method for ( ) ** - * +exp(-xf lambda xx** - * +exp(-xsol bisection( ,- , , - print( ' {sol:gis an approximate rootf({sol: }{ (sol): }'we see that the bisection function takes four argumentsthe mathematical function (ximplemented as python functionthe bounds for our initial intervaland the tolerance for the approximate solution the first if-test of the function simply checks that changes sign in [ab]which ensures that the function has at least one root on the interval we then proceed to define the midpoint and enter the while-loopwhich forms the core of the algorithm this loop will continue running as long as abs( ( )tol (otherwise is our solution)repeatedly checking whether changes sign on [amor [mb]and then calculating new to repeat the process on an interval of half the size newton' method gives faster convergence the bisection method converges quite slowlyand other methods are far more popular for solving nonlinear equations in particularnumerous varieties of newton' method are widely used in practice newton' method is based on local linearization of the non-linear function (xstarting with an initial guess we replaces (xby linear function (xthat satisfies (xf (xin small interval around thenwe solve the equation ( to find an updated guess and repeat the process of linearization around that point repeated application of these steps converges quickly towards the true solutionprovided that the initial guess is sufficiently close in mathematicsone step of the algorithm looks like (xn xn+ xn (xn where xn is the solution after iterationsxn+ is the improved approximationand (xn is the derivative of in xn just as the bisection methodnewton' method is easy to implement in while loopand we can implement it as generic function that takes python function implementing (xas argument the function will also need ( )since this is used in the algorithmas well as an initial guess and tolerancefrom math import exp def newton(fdfdxx tol - ) ( while abs( tol