solving nonlinear algebraic equations while abs(f_valueeps and iteration_counter tryx float(f_value)/dfdx(xexcept zerodivisionerrorprint "errorderivative zero for " sys exit( abort with error f_value (xiteration_counter + if return_x_listx_list append(xhereeither solution is foundor too many iterations if abs(f_valueepsiteration_counter - lack of convergence if return_x_listreturn x_listiteration_counter elsereturn xiteration_counter the function is found in the file nonlinear_solvers py we can now make call xiter newton(fdfdxx= eps= - return_x_list=trueand get list returned with knowledge of the exact solution of xd we can compute all the errors en and all the associated qn values with the compact function def rate(xx_exact) [abs(x_ x_exactfor x_ in xq [log( [ + ]/ [ ])/log( [ ]/ [ - ]for in range( len( )- )return the error model ( works well for newton' method and the secant method for the bisection methodhoweverit works well in the beginningbut not when the solution is approached we can compute the rates qn and print them nicelydef print_rates(methodxx_exact) [' fq_ for q_ in rate(xx_exact)print method ':for q_ in qprint q_print the result for print_rates('newton' is newton