Beispiel #1
0
 public double biseccion() {
   double c = 0;
   double f = da.f(a);
   double f_actual = f;
   if (no_cero) return 0;
   while (Math.abs(f_actual) > error) {
     if (cant1 > Constantes.MAX_ITERACIONES_MIN) {
       error();
       return 0;
     }
     c = (a + b) / 2;
     f_actual = da.f(c);
     cant1++;
     System.out.println("iteracion " + cant1 + " c= " + c + " | biss");
     if (f_actual * da.f(a) < 0) {
       b = c;
     } else {
       a = c;
     }
     ;
   }
   a = aux1;
   b = aux2;
   return c;
 }
Beispiel #2
0
 public double regulamodificada() {
   if (no_cero) return 0;
   double g = da.f(b);
   double f = da.f(a);
   double c = 0;
   double f_actual = f;
   double f_old = f;
   while (Math.abs(f_actual) > error) {
     cant4++;
     System.out.println("iteracion " + cant4 + " c= " + c + " | regula m");
     c = ((a * g - b * f) / (g - f));
     f_actual = da.f(c);
     if (f_actual * f > 0) {
       b = c;
       g = f_actual;
       if (f_actual * f_old > 0) f = f / 2;
     } else {
       a = c;
       f = f_actual;
       if (f_actual * f_old > 0) g = g / 2;
     }
     f_old = f_actual;
   } // end of while
   a = aux1;
   b = aux2;
   return c;
 }
Beispiel #3
0
 public double puntoFijo() {
   double c = a;
   cant5 = 0;
   while ((Math.abs(da.f(c)) > error) && (cant5 < Constantes.MAX_ITERACIONES_MIN)) {
     c = da.g(c);
     cant5++;
   }
   return c;
 }
Beispiel #4
0
 public double regula() {
   if (no_cero) return 0;
   double c = a;
   double f = da.f(a);
   double g = da.f(b);
   double f_actual = f;
   while (Math.abs(f_actual) > error) {
     cant3++;
     System.out.println("iteracion " + cant3 + " c= " + c + " | regula");
     c = ((a * g - b * f) / (g - f));
     f_actual = da.f(c);
     if ((f_actual * f) < 0) {
       b = c;
       g = f_actual;
     } else {
       a = c;
       f = f_actual;
     }
   }
   a = aux1;
   b = aux2;
   return c;
 }
Beispiel #5
0
 public double newton() {
   if (no_cero) return 0;
   double c, c1;
   if (da.f(a) * da.fd2(a) > 0) {
     c = a;
   } else if (da.f(b) * da.fd2(b) > 0) {
     c = b;
   } else { //
     double a1 = a + 0.1;
     while ((da.f(a1) * da.fd2(a1) < 0) & (a1 < (b + 0.3))) {
       a1 += 0.1;
     }
     if (a1 > b) {
       System.out.println("ERROR!!!!!" + a1);
       return a - 100;
     } else c = a1;
   }
   c1 = c - (da.f(c) / da.fd1(c));
   while (Math.abs(da.f(c1)) > error) {
     cant2++;
     if (cant2 > Constantes.MAX_ITERACIONES_MIN) {
       error();
       return 0;
     }
     c = c1;
     System.out.println("iteracion " + cant2 + " c= " + c + " | newton ");
     c1 = c - (da.f(c) / da.fd1(c));
   }
   a = aux1;
   b = aux2;
   return c1;
 }
Beispiel #6
0
 public void setG(String g) {
   da.setG(g);
 }