solving nonlinear algebraic equations comparing ( to the graph in fig we see how two chosen starting points ( and corresponding function valuesare used to compute once we have we similarly use and to compute as with newton' methodthe procedure is repeated until xn is below some chosen limit valueor some limit on the number of iterations has been reached we use an iteration counter here toobased on the same thinking as in the implementation of newton' method we can store the approximations xn in an arraybut as in newton' methodwe notice that the computation of xnc only needs knowledge of xn and xn not "olderapproximations thereforewe can make use of only three variablesx for xnc for xn and for xn note that and must be given (guessedfor the algorithm to start program secant_method py that solves our example problem may be written asdef secant(fx eps)f_x ( f_x ( iteration_counter while abs(f_x eps and iteration_counter trydenominator float(f_x f_x )/( float(f_x )/denominator except zerodivisionerrorprint "errordenominator zero for " sys exit( abort with error f_x f_x f_x ( iteration_counter + hereeither solution is foundor too many iterations if abs(f_x epsiteration_counter - return xiteration_counter def ( )return ** solutionno_iterations secant(fx eps= - if no_iterations solution found print "number of function calls% ( no_iterationsprint " solution is% (solutionelseprint "solution not found!the number of function calls is now related to no_iterationsi the number of iterationsas no_iterationssince we need two function calls before entering the while loopand then one function call per loop iteration note thateven though we need two points on the graph to compute each updated estimateonly