【发布时间】:2015-03-24 04:49:03
【问题描述】:
我正在尝试在 Scilab 中实现 Newton-Raphson 方法,其中输入必须是函数内部已经建立的方程的根点。然而,在对函数进行导数并输入根之后,我得到除以零。知道为什么输入 2 作为根点时导数等于 0 吗?
function y = fun(x)
y = -0.01 + (1/1+ x^2);
endfunction
function y= dfun(x)
y = (-2.00*x) / (1+x^2)^2
endfunction
No = 0;
x1 = 0;
x0 = input('Diga el valor inicial: ');
error = 1e^-10;
while (abs(fun(x0)) > error)
x1 = x0 - fun (x0) / dfun(x0);
x0 = x1;
No = No + 1;
end;
disp(x1, "Valor: ");
disp(No, "Numero de iteraciones: ")
ERROR HERE
Diga el valor inicial: 2
x1 = x0 - fun (x0) / dfun(x0);
!--error 27
Division by zero...
at line 12 of exec file called by :
exec('C:\Users\Silvestrini\Documents\Raphson.sci', -1)
【问题讨论】:
标签: scilab newtons-method