Newtons Method (Receiving multiple errors)

11 vues (au cours des 30 derniers jours)
Danielle Garcia
Danielle Garcia le 12 Sep 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.

Réponses (0)

Catégories

En savoir plus sur Software Development Tools dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by