Documentos de Académico
Documentos de Profesional
Documentos de Cultura
end
Desarrollo
Ingrese función a evaluar:'0.95*x^3-5.9*x^2+10.9*x-6'
Ingrese tolerancia:0.0000001
Ingrese un valor inicial:3
n xi eroor
0 3.00000 50.000000
1 3.65217 0.750000
2 3.41318 1.390647
3 3.34926 0.244563
4 3.34467 0.015388
5 3.34465 0.000077
>>
d) Método de la secante (cinco interaciones 𝑥0 = 3 𝑥1 = 3.3)
Programa
% método de la secante
clear, clc
cf=input('Ingrese funcion:');
f=inline(cf);
x0=input('ingrese primer valor:');
x1=input('ingrese segundo valor:');
tol=input('ingrese la tolerancia:');
error=100;
n=0;
fprintf('n x0 x1 x2 error\n');
fprintf('%i %4.5f %4.5f ---- ----\n', n, x0, x1);
while (error>tol)
n=n+1;
x2=x1-((x1-x0)*f(x1)/f(x1)-f(x0));
error=abs(f(x2));
fprintf('%i %4.5f %4.5f %4.5 %4.5\n', n, x0, x1, error);
x0=x1;
x1=x2;
end
desarrollo
Ingrese funcion:'0.95*x^3-5.9*x^2+10.9*x-6'
ingrese primer valor:3
ingrese segundo valor:3.3
ingrese la tolerancia:0.0000001
n x0 x1 x2 error
0 3.00000 3.30000 ---- ----
1 3.00000 3.30000 2 3.30000 2.25000 3 2.25000 3.15915 4 3.15915 1.72734 5 1.72734
2.66312