Metodos numericos

Páginas: 2 (387 palabras) Publicado: 8 de diciembre de 2010
PRIMERA UNIDAD

clc , clear all,
disp(' METODO DE LA BISECCION ');
a=input('valor de a: ');
b=input('valor de b: ');
tol=input('Tolerancia: ');
c=(a+b)/2;
MEP=(b-a)/2;
cont=0;disp(' a b c MEP ')
disp(' =======================================');
fprintf('\n n=%d %3.6f %3.6f %3.6f %3.8f \n',cont,a,b,c,MEP),
while (MEP>tol)cont=cont+1;
if f(a)*f(c)<0;
b=c;
else
a=c;
end
c=(a+b)/2;
MEP=(b-a)/2;
fprintf('\n n=%d %3.6f %3.6f %3.6f %3.8f\n',cont,a,b,c,MEP),
end;
disp(' ======================================');
disp('SoluCion');
fprintf('c=%3.6f MEP=%3.8f ',c,MEP)

clc, clear all
disp(' METODO DE LA FALSA POSICION ');
a=input('valorde a: ');
b=input('valor de b: ');
tol=input('Tolerancia: ');
c=(b*f(a)-a*f(b))/(f(a)-f(b));
error=abs(f(c));
cont=0;
disp(' a b medio error ')
disp('=======================================');
fprintf('\n\tn = %d %8.6f %8.6f %8.6f %10.8f \n',cont,a,b,c,error);
while (error>tol)
cont=cont+1;
if f(a)*f(c)<0;
b=c;
elsea=c;
end
c=(b*f(a)-a*f(b))/(f(a)-f(b));
error=abs(f(c));
fprintf('\n\tn = %d %8.6f %8.6f %8.6f %10.8f \n',cont,a,b,c,error),
end;
disp('=======================================');
disp('SoluCion');
fprintf(' c=%3.6f error=%3.8f ',c,error)

MÉTODOS DE OPTIMIZACION

clc , clear all,
disp(' ***METODO DE LA SEC DORADA MAX / MIN***’ );
a=input('valor de a: ');b=input('valor de b: ');
R=0.618;
x1=a+R*(b-a);
x2=b-R*(b-a);
tol=input('Tolerancia: ');
MEP=(1-R)*(b-a);
cont=0;
disp(' n x1 x2 MEP ')
disp('========================================');
fprintf('\n n=%d %3.6f %3.6f %3.8f \n',cont,x1,x2,MEP),
while (MEP>tol)
cont=cont+1;
if (z(x1)>z(x2));
Xmax=x1; % Para mínimo...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Metodos numericos
  • Métodos Numéricos
  • Metodos numericos
  • Metodos numericos
  • Metodos numericos
  • Metodos Numericos
  • Metodos Numericos
  • metodos numericos

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS