Newtons Method (Receiving multiple errors)

14 visualizzazioni (ultimi 30 giorni)
Danielle Garcia
Danielle Garcia il 12 Set 2019
function root = newtons(fun,dfun,x0)
format long
x = fzero(fun,x0);
xi = x0;
count = 0;
fprintf('The MATLAB approximation of the real zero of the function is %s\n',x)
while abs(xi - x) > 10^(-12)
xj = xi - ((fun(xi))/(dfun(xi)));
xi = xj;
count = count + 1;
end
fprintf('Number of iterations: %s \n',count)
root = xi;
end
I am trying to perform the newtons method and have been receiving this error in my code when i try to run "root = newtons(fun,dfun,0.5)" in my livescript. I could really use some help as this is beginning to drive me crazy and im not sure what is wrong with my code. My project is asking for the amount of iterations and the original approximation.

Risposte (0)

Categorie

Scopri di più su Software Development Tools in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by