Documentos de Académico
Documentos de Profesional
Documentos de Cultura
EJERCICIOS
Fecha:13/03/2024
Nombre del estudiante: Erick Ivan Barrios Dominguez
Nombre del docente: Omar Amaya Molina
Con base en el siguiente material consultado, replica los ejercicios indicados para cada método y realiza
pruebas con dos ecuaciones aleatorias a resolver:
function [xr]=biseccion(xi,xs)
iteracion = 0;
e = 1;
et = 1e-8;
format1 = '%.8f';
format2 = '%.4e';
while e > et
iteracion = iteracion+1;
xr = (xi+xs)/2;
x = [xi,xr] ;
fx = x.^3-x-100;
if fx(1)*fx(2) < 0
xs = xr;
else
xi = xr;
end
e = abs((xs-xi)/(xs+xi));
end
disp ('RESULTADOS: ')
disp ([' La raiz calculada es: ', num2str(xr,format1)])
disp ([' Numero de Iteraciones: ',num2str(iteracion)])
disp ([' Error: ',num2str(e,format2)])
function [xr]=biseccion(xi,xs)
iteracion = 0;
e = 1;
et = 1e-8;
format1 = '%.8f';
format2 = '%.4e';
while e > et
iteracion = iteracion+1;
xr = (xi+xs)/2;
x = [xi,xr] ;
fx =x.^4+3*x.^3-2; %funcion x
if fx(1)*fx(2) < 0
xs = xr;
else
xi = xr;
end
e = abs((xs-xi)/(xs+xi));
end
disp ('RESULTADOS: ')
disp ([' La raiz calculada es: ', num2str(xr,format1)])
disp ([' Numero de Iteraciones: ',num2str(iteracion)])
disp ([' Error: ',num2str(e,format2)])
• Figura 5.11 Pag 132 (Método de la falsa posición)
function [xr]=Falsap(xi,xs,N)
format1 = '%.8f';
format2 = '%.4e';
for iteracion=1:N
x = [xi,xs];
fx = x.^3-x-100; %funcion x
xr = x(2)-(fx(2)*(x(1)-x(2)))/(fx(1)-fx(2));
if fx(1)*fx(2) < 0
xs = xr;
else
xi = xr;
end
e = abs((xs-xi)/(xs+xi));
disp (['i: ',num2str(iteracion),' xr: ',num2str(xr), ' Error: ',num2str(e)])
end
function NewtonR(xi,N)
format1 = '%.8f';
for iteracione=0:N
xf= xi-((xi.^3-xi-100)/(3*xi^2-1));
error= xf -xi;
xi=xf;
end
x=4.5:10;
y=x.^3-x-100;
plot(x,y,'b');
grid on
disp ([' Iteraciones: ', num2str(iteracione)])
disp ([' Raiz calculada: ', num2str(xi,format1)])
disp ([' Error: ',num2str(error,format1)])
function NewtonR(xi,N)
format1 = '%.8f';
for iteracione=0:N
xf= xi-((xi.^4+3*xi.^3-2)/(4*xi.^3+9*xi.^2));
error= xf -xi;
xi=xf;
end
x=4.5:10;
y=x.^3-x-100;
plot(x,y,'b');
grid on
disp ([' Iteraciones: ', num2str(iteracione)])
disp ([' Raiz calculada: ', num2str(xi,format1)])
disp ([' Error: ',num2str(error,format1)])
• Programa el algoritmo para ejecutar el método de la secante (ejemplo 6.6)
Referencias:
Chapra, S. y Canale, R. (2007). Métodos numéricos para ingenieros [Versión electrónica]. Recuperado de
https://www.academia.edu/35215572/Metodos_Numericos_Aplicados_a_La_Ingenieria_4a_Nieves
Goldberg, D. (1991). What Every Computer Scientist Should Know About Floating-Point
Arithmetic. ACM Computing Surveys, 23(1), 5-48.
Press, W. H., Teukolsky, S. A., Vetterling, W. T., & Flannery, B. P. (2007). Numerical Recipes:
The Art of Scientific Computing. Cambridge University Press.