Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Newton\'s Method using MatLab Write a program implementing Newton\'s method. The

ID: 3563415 • Letter: N

Question

Newton's Method using MatLab

Write a program implementing Newton's method. The program should be given as inputs a function, its derivative, a starting point, a tolerance, and a maximum number of iterations. Use it to find zeros of the functions below. For each function: i) Find a suitable initial guess. ii) Comment on how difficult this guess was to find. iii) Analyze the convergence by plotting the error as a function of the number of iteration on an appropriate graph. iv) Determine if the rate of convergence you find in iii) is consistent with theory. (a) f (x) = x^4 - 5x^3 + x + 1 = 0.

Explanation / Answer

f=@(x) x^4-5*x^3+x+1;
g=@(x) 4*x^3-15*x^2+1;

x1=2; %initial guess
err=1;
while err>=0.0001
x2=x1+((feval(g,x1))/(feval(f,x1)));
err=abs(x2-x1);
x1=x2;
end
x=['root is ',num2str(x1)];
disp(x)