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

MatLab Problem Problem1 Use the Newton-Raphson method to find the solutions to t

ID: 3690207 • Letter: M

Question

MatLab Problem

Problem1 Use the Newton-Raphson method to find the solutions to the non-linear equations defined in sections (a)-(c), below. For each problem, the initial guess is given. As you write youir program, for each problem, use subplot and plot commands first to plot the left hand side of the equation over the range of x specified for each case and then use hold on and plot commands to show the root of the equation on the same graph. In the other panel of the figure, use semilogy command to plot log of the absolute value of the error versus the iteration number. A typical output is shown in Figure 1 511 3 50 3 561 2 549 297 1005-11r4 500 x E -0.4,0.4] xo -0.5 5000 25000 b) Repeat part (a) for the following initial guesses: Co-0.2 0 200.28

Explanation / Answer

Answer:)

Code for newton-raphson's algorithm:

function [x,iter]=newton(x0,f,fp)
% newton-raphson algorithm
N = 100; eps = 1.e-5; % define max. no. iterations and error
maxval = 10000.0; % define value for divergence
xx = x0;
while (N>0)
xn = xx-f(xx)/fp(xx);
if abs(f(xn))<eps
x=xn;iter=100-N;
return;
end;
if abs(f(xx))>maxval
disp(['iterations = ',num2str(iter)]);
error('Solution diverges');
break;
end;
N = N - 1;
xx = xn;
end;
error('No convergence');
break;
% end function