Вы находитесь на странице: 1из 1

METODO DE NEWTON RAPSON

Variables de entrada
clear
clc
syms x
fprintf('METODO DE NEWTON RAPHSON\n')
f=input('Ingrese la funcion: ');
xi=input('Ingrese el valor inicial: ');
tol=input('Ingrese la tolerancia: ');
df=diff(f); % PERMITE OBTENER LA DERIVADA DE LA FUNCION
f=inline(f);
df=inline(df);

Grafica de la función
ezplot(f)
grid on

Inicialización de la Variables para el análisis


N=0;
e=1;
er=0;

Desarrollo del método


while e>tol
xf=xi-(f(xi)/df(xi));
er=abs((xf-xi)/xf)*100;
e=abs(xf-xi);
xi=xf;
N=N+1;
end
fprintf('\nLa raiz es %.8f, y se consigio en %d iteraciones',xi,N)

Published with MATLAB® R2013a

Вам также может понравиться