solving nonlinear algebraic equations f_value (xf_norm np linalg norm(f_valueord= norm of vector iteration_counter while abs(f_normeps and iteration_counter delta np linalg solve( ( )-f_valuex delta f_value (xf_norm np linalg norm(f_valueord= iteration_counter + hereeither solution is foundor too many iterations if abs(f_normepsiteration_counter - return xiteration_counter we can test the function newton_system with the system ( )-( )def test_newton_system ()from numpy import cossinpiexp def ( )return np array[ [ ]** [ [ ]*cos(pi* [ ]) [ ]* [ exp(- [ ] [ ]**(- )]def ( )return np array[[ * [ cos(pi* [ ]pi* [ ]*sin(pi* [ ])- ][ [ [ ]**(- ) [ exp(- [ ])]]expected np array([ ]tol - xn newton_system(fjx=np array([ - ])eps= print nx error_norm np linalg norm(expected xord= assert error_norm tol'norm of error =%gerror_norm print 'norm of error =%gerror_norm herethe testing is based on the norm of the error vector alternativelywe could test against the values of that the algorithm findswith appropriate tolerances for exampleas chosen for the error normif eps= tolerance of can be used for [ and [ exercises exercise understand why newton' method can fail the purpose of this exercise is to understand when newton' method works and fails to this endsolve tanh by newton' method and study the intermediate details of the algorithm start with : plot the tangent in each iteration of newton' method then repeat the calculations and the plotting when : explain what you observe filenamenewton_failure