Question: Write a Matlab function, called Newtons method that inputs a function, f, it's derivative f', an initial guess x 0, an error tolerance, tol, and

Write a Matlab function, called Newtons method that inputs a function, f, it's derivative f', an initial guess x 0, an error tolerance, tol, and a maximum number of iterations, N, and outputs the root of f obtained using Newton's method (denoted by c), starting with x_0. Your function should have an error defined by err lfx_n-x fn-1, and stop when the error is less than the tolerance, or if the number of iterations exceeds N - whichever happens first. Your function header should look something like function [c,nerr-Newtons-method(f.fp.xO.tol.N n is the last iteration when you stop. Use the function you created to find the root of the equation larctan(x)-1 with initial guess x o 2, to an accuracy of less than tol -104-8 Did your method converge, and if so, how many iterations did it take? If not, why didn't it converge, and what happened--did it diverge, or end up in an infinite loop?Plot on the same graph the function and the axis Sy-0S. Test with x,0 =-2. What is happening
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
