227k views
2 votes
Here you will program the Newton-Raphson root finding method with details specified as fol-lows. Your code will continue performing iterations of this root finding method until it hasfound the root within the given tolerance. The function should return when it has found aroot for whichf(rt)is withintolof 0 (inclusive), or aftermaxiteriterations have beenperformed.

User ScottTx
by
3.4k points

1 Answer

2 votes

Answer:

function [rt,n_iter]=newtonsMethod(f,df,x0,tol,max_iter)

rt=x0;

if(abs(f(rt))<tol)

n_iter=0;

return;

end

for i=1:max_iter

rt=x0-f(x0)/df(x0);

if(abs(f(rt))<tol)

break;

end

x0=rt;

end

n_iter=i;

end

Step-by-step explanation:

Here you will program the Newton-Raphson root finding method with details specified-example-1
User Aamir
by
3.2k points