Está en la página 1de 10

UNIVERSIDAD POLITECNICA SALESIANA

METODOS NUMERICOS
NOMBRE: BRAYAN CARDENAS
NIVEL: CUARTO G1
METODOS NUMERICOS EN MATLAB
MENU DE OPCIONES

VISUALIZACION
 METODO DE LA BISECCION
clc
clear all

disp('Ingrese la funcion de una variable independiente')


f=input('Puede ser cualquier otro literal. f(x)=','s');
alto=0;
while alto==0
a=input('Ingrese el intervalo inferior de la raiz: ');
b=input('Ingrese el intervalo superior de la raiz: ');
ea=subs(f,a);
eb=subs(f,b);
if ea*eb>0
disp('Los intervalos encierran cero o mas de una raiz');
disp('Ingrese otros intervalos');
else
alto =1;
end
end
alto=0;
while alto==0
disp('Seleccione 1 para seleccionar el criterio de error relativo
entre aproximaciones o 2 para seleccionar por numero')
s=input('numero de interaciones: ');
switch s
case 1
epsilon=input('Ingrese maximo error relativo: ');
alto=1;
case 2
maxit=input('Ingrese maximo numero de iteraciones: ');
alto=1;
otherwise
disp('Opcion no valida, Ingrese 1 o 2: ')
end
end
it=1;
alto=0;
while alto==0
r=(a+b)/2;
er=subs(f,r);
if it>1
err=abs((b-a)/2*r);
if s==1
if epsilon>=err
alto=1;
end
end
if s==2
if maxit<=it
alto=1;
end
end
end
disp(['-----Iteracion numero ' num2str(it) '------'])
disp(['La aproximación es: ' num2str(r)])
if it>1
disp(['El error relativo es: ' num2str(err)])
end
disp(['La aproximacion esta entre: ' num2str(a) 'y' num2str(b)])
if er==0
alto=1;
elseif eb*er>0
b=r;
else
a=r;
end
it=it+1;
end

VISUALIZACION

 METODO DE LA FALSA POSICION


clc
clear all

disp('Ingrese la funcion de una variable independiente')


f=input('Puede ser cualquier otro literal. f(x)=','s');
alto=0;
while alto==0
a=input('Ingrese el intervalo inferior de la raiz: ');
b=input('Ingrese el intervalo superior de la raiz: ');
ea=subs(f,a);
eb=subs(f,b);
if ea*eb>0
disp('Los intervalos encierran cero o mas de una raiz');
disp('Ingrese otros intervalos');
else
alto =1;
end
end
alto=0;
while alto==0
disp('Seleccione 1 para seleccionar el criterio de error relativo
entre aproximaciones o 2 para seleccionar por numero')
s=input('numero de interaciones: ');
switch s
case 1
epsilon=input('Ingrese maximo error relativo: ');
alto=1;
case 2
maxit=input('Ingrese maximo numero de iteraciones: ');
alto=1;
otherwise
disp('Opcion no valida, Ingrese 1 o 2: ')
end
end
it=1;
alto=0;
while alto==0
ea=subs(f,a);
eb=subs(f,b);
r=b-((eb*(b-a))/(eb-ea));
er=subs(f,r);
if it>1
err=abs((r-mr)/(r));
if s==1
if epsilon >= err
alto=1;
end
end
if s==2
if maxit<=it
alto=1;
end
end
end
mr=r;
disp(['-----Iteracion numero ' num2str(it) '------'])
disp(['La aproximacion es: ' num2str(r)])
if it>1
disp(['El error relativo es: ' num2str(err)])
end
disp(['La aproximacion esta entre: ' num2str(a) 'y' num2str(b)])
if er==0
alto=1;
elseif eb*er>0
b=r;
else
a=r;
end
it=it+1;
end
VISUALIZACION

 METODO DEL PUNTO FIJO

clc
clear all
disp('Ingrese la funcion de iteracion g(x) para encontrar la raiz de
otra funcion')
g=input('Puede ser otro literal. f(x)=','s');
r=input('Ingrese el punto inicial: ');
alto=0;
while alto==0
disp('Seleccione 1 para el criterio de error relativo o 2 para
seleccionar por numero de iteraciones')
s=input('escoja la opcion: ');
switch s
case 1
epsilon=input('Ingrese maximo error relativo: ');
alto=1;
case 2
maxit=input('Ingrese maximo numero de iteraciones');
alto=1;
otherwise
disp('Ocion no valida, Seleccione 1 o 2: ')
end
end
it=1;
alto=0;
while alto==0
gr=subs(g,r);
err=abs((gr-r)/(gr));
if s==1
if epsilon >= err
alto=1;
end
end
if s==2
if maxit<=it
alto=1;
end
end
disp(['--------Iteracion numero ' num2str(it) '------'])
disp(['La aproximacion es: ' num2str(gr)])
disp(['El error relativo es: ' num2str(err)])
r=gr;
it=it+1;
end

EJECUCION DEL PROGRAMA


 METODO DE NEWTON RAPHSON

clc
clear all
disp('Ingrese una funcion derivable dependiente de x')
f=input('Ingrese la funcion para analizar. f(x)=','s');
r=input('Ingrese el punto inicial: ');
df=diff(f,sym('x'));
alto=0;
while alto ==0
disp('Seleccione 1 para seleccionar el criterio relativo o 2 para
seleccionar el numero de iteraciones')
s=input('Escoja la opcion deseada: ');
switch s
case 1
epsilon=input('Ingrese maximo error relativo: ');
alto=1;
case 2
maxit=input('Ingrese maximo numero de iteraciones: ');
alto=1;
otherwise
disp('Opcion no valida, Ingrese 1 o 2: ')
end
end
it=1;
alto=0;
while alto==0
evf=subs(f,r);
evdf=subs(df,r);
if evdf==0
disp('Derivada evualada igual a cero en alguna iteracion')
return
end
r1=r-(evf/evdf);
err=abs((r1-r)/(r1));
if s==1
if epsilon >=err
alto=1;
end
end
if s==2
if maxit <= it
alto=1;
end
end
raiz = num2str(r1);
error = num2str(err);
disp(['-------Iteracion numero' num2str(it) '--------'])
disp('La aproximacion es',raiz)
disp('El error relativo es',error)
r=r1;
it=it+1;
end
EJECUCION DEL PROGRAMA

 METODO DE LA SECANTE
clear all
clc
disp('Ingrese una funcion derivable dependiente de x')
f=input('Ingrese la funcion para analizar. f(x)=','s');
r=input('Ingrese el punto inicial: ');
df=diff(f,sym('x'));
alto=0;
while alto ==0
disp('Seleccione 1 para seleccionar el criterio relativo o 2 para
seleccionar el numero de iteraciones')
s=input('Escoja la opcion deseada: ');
switch s
case 1
epsilon=input('Ingrese maximo error relativo: ');
alto=1;
case 2
maxit=input('Ingrese maximo numero de iteraciones: ');
alto=1;
otherwise
disp('Opcion no valida, Ingrese 1 o 2: ')
end
end
it=1;
alto=0;
while alto==0
evf=subs(f,r);
evfc=subs(f,r+0.001);
r1=r-((0.001*evfc)/(evfc-evf));
err=abs((r1-r)/(r1));
if s==1
if epsilon >= err
alto =1;
end
end
if s==2
if maxit <= it
alto = 1;
end
end
disp(['-------Iteracion numero' num2str(it) '--------'])
disp(['La aproximacion es: ' num2str(r1)])
disp(['El error relativo es: ' num2str(err)])
r=r1;
it=it+1;
end

EJECUCION DEL PROGRAMA

 CONCLUCIONES

1. El método de la Bisección converge lentamente, lo que genera la propagación de error


por la cantidad de operaciones e iteraciones necesaria para que el método converja.

2. Cuando se plantean problemas y de ellos se sabe el número de multiplicidad, si este


número es impar no es difícil de resolver y podría resolverse con diferentes métodos,
mientras que si el número de multiplicidad es par es necesario el uso de métodos más
complejos y su análisis es más difícil.

3. El método de la secante es un método simple y muy utilizado, gracias a su rapidez y al


hecho de que no hay que hallar derivas como en el de Newton.
4. En el método de Newton Raphson, cuando se tiene un máximo o mínimo local la
tendencia del método será oscilar alrededor del máximo o mínimo local,
desenfocándose de la raíz y perdiendo el efecto de búsqueda de raíces del método

5. El método de punto fijo busca hallar las raíces en funciones de la forma, a través de
aproximaciones sucesivas que convergen a la solución de la ecuación.

 BIBLIOGRAFIA

An Introduction to Numerical Analysis for Electrical and Computer Engineers, Chistopher J.


Zarowski, Editorial Wiley, ISBN 0-471-46737-5.
http://www.mathworks.com/help (Sitio de ayuda oficial de Matlab)

También podría gustarte