Problema con codigo de Newton Rapson
Publicado por Oscar (2 intervenciones) el 02/04/2017 01:03:19
Ayuda por favor no logro que funcione.
Acá esta el codigo
Estes es el error que me sale
>> newton('1+sin((3.*x)/5)-((5.*x)./3)',0,0.00000001)
Error using diff
Difference order N must be a positive integer scalar.
Error in newton (line 3)
Acá esta el codigo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function newton(f,x0,tol)
sym x;
df=diff(f,'x');
f=inline(f);
df=inline(char(df));
fprintf('\n it. x f(x) \n')
i=0;
fprintf('%3.0f %10.10f %10.10f \n',i,x0,f(x0))
x1=x0-(f(x0)/df(x0));
while (abs(x0-x1))/x0 >tol;
i=i+1;
fprintf('%3.0f %10.10f %10.10f \n',i,x1,f(x1))
x0=x1;
x1=x0-(f(x0)/df(x0));
end
fprintf('\n La aproximación de la raíz es: %3.10f \n\n',x1)
Estes es el error que me sale
>> newton('1+sin((3.*x)/5)-((5.*x)./3)',0,0.00000001)
Error using diff
Difference order N must be a positive integer scalar.
Error in newton (line 3)
1
df=diff(f,'x');
Valora esta pregunta


0