algoritmos unidad ii métodos numéricos
TRANSCRIPT
-
7/21/2019 Algoritmos Unidad II Mtodos Numricos
1/6
Mtodo de la Biseccin
Inicio
ouble x ,xi,fx ,fxi,xm,fxm,n;
int a,b,c, ,i,iant;
escribir "Inserta el valor de A:";
lee A;
escribir "Inserta el valor de B:";
lee B;
escribir "Inserta el valor de C:";
lee C;
escribir "Inserta el valor de D:";
lee D;
escribir "Inserta el valor de xd:";
lee xd;
escribir "Inserta el valor de xi:";
lee xi;
n=(Math.log(xi-xd)-Math.log(0.0001))/Math.log(2);
imprimir "Existen" + n + "Aproximaciones";
fxd = (a*(Math.pow(xd,3))) + (b*(Math.pow(xd,2))) + (c*(xd)) + (d);
fxi = (a*(Math.pow(xi,3))) + (b*(Math.pow(xi,2))) + (c*(xi)) + (d);
imprimir xd= " + xd + "xi="+ xi;
imprimir fxd=" + fxd + "fxi="+ fxi;
para(i=1 hasta i
-
7/21/2019 Algoritmos Unidad II Mtodos Numricos
2/6
sino
xi=xm;
fxi=fxm;
finsi
imprimir x =" + x + "xi="+ xi;
imprimir fxd=" + fxd + "fxi=" fxi;
si ((yd==xd && fyd==fxd) && (yi==xi && fyi==fxi)) entonces
iant=i-1;
imprimir "Convergen en la aproximacion" +iant+ "y en la
aproximacion " + i;
salir;
finsi
i=i+1;
fin paraFin
-
7/21/2019 Algoritmos Unidad II Mtodos Numricos
3/6
Mtodo de la Secante
Inicio
ouble x ,xi,xi1,fx ,fxi,fxi1;
int a,b,c, ,i,iant;
escribir "Inserta el valor de A:";
lee A;
escribir "Inserta el valor de B:";
lee B;
escribir "Inserta el valor de C:";
lee C;
escribir "Inserta el valor de D:";
lee D;
escribir "Inserta el valor de x0:";
lee xd;
escribir "Inserta el valor de x1:";
lee xi;
fxd = (a*(Math.pow(xd,3))) + (b*(Math.pow(xd,2))) + (c*(xd)) + (d);
fxi = (a*(Math.pow(xi,3))) + (b*(Math.pow(xi,2))) + (c*(xi)) + (d);
imprimir "x0=" +xd + "x1="+ xi;imprimir "fx0=" + fxd + "fx1="+ fxi;
para(i=1hasta i
-
7/21/2019 Algoritmos Unidad II Mtodos Numricos
4/6
si ((xi==x && fxi==fx )) entonces
iant=i-1;
imprimir "\nConvergen en la aproximacion " +iant+ " y en la
aproximacion " + i;
salir;
finsi
i=i+1;
fin para
Fin
-
7/21/2019 Algoritmos Unidad II Mtodos Numricos
5/6
Mtodo de Newton-Raphson
inicio
ouble x ,fx, fx,xi,y =0;
int a,b,c, ,i,iant;;
escribir "Inserta el valor de A: ";
lee A;
escribir "Inserta el valor de B: ";
lee B;
escribir "Inserta el valor de C: ";
lee C;
escribir "Inserta el valor de D: ";
lee D;
escribir "Inserta el valor de x0: ";
lee x0;
fx = (a*(Math.pow(xd,3))) + (b*(Math.pow(xd,2))) + (c*(xd)) + (d);
dfx = ((a*3)*(Math.pow(xd,2))) + ((b*2)*(xd)) + (c);
imprimir "f(x)=" + fx + "f'(x)="+dfx;
para (i=1 hasta i
-
7/21/2019 Algoritmos Unidad II Mtodos Numricos
6/6
si (x ==xi) entonces
iant=i-1;
imprimir "Convergen en la aproximacion " +iant+ " y en la
aproximacion " + i;
salir;
finsi
fin para
i=i+1;
Fin