Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Codigo en Matlab
Codigo en Matlab
clc
clear
f=input('Ingrese la funcion:\n','s');;
f=inline(f);
xra=0;
xr=0;
tol=0.00000001;
i=1;
error_aprox=1;
error=0;
fx1=f(x1);
fx0=f(x0);
xr=x1-((x1-x0)/(fx1-fx0))*fx1;
xra=xr;
x1=xr;
fx1=f(x1);
fx0=f(x0);
xr=x1-((x1-x0)/(fx1-fx0))*fx1;
error_aprox = error;
i=i+1;
fprintf('%2d \t %11.7f \t %11.7f \t %11.7f \t %11.7f \n',i,x0,x1,xr,error_aprox);
end
corrida
Ingrese la funcion:
(x*x)-(2*x)-1
2.6
2.5
Segundo ejercicio
Ingrese la funcion:
(x*x)-x-3
1.7
1.67
Tercer ejercicio
Ingrese la funcion:
(x*x*x)-x+2
1.5
-1.52