Newtons Method (Receiving multiple errors)

13 ビュー (過去 30 日間)
Danielle Garcia
Danielle Garcia 2019 年 9 月 12 日
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.

回答 (0 件)

カテゴリ

Help Center および File ExchangeSoftware Development Tools についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by