Esempio n. 1
0
 public static double SecantMethod(nonLinearEquationFunction f, double a, double b, double epsilon)
 {
     double x1 = a;
     double x2 = b;
     double fb = f(b);
     while (Math.Abs(f(x2)) > epsilon)
     {
         double mpoint = x2 - (x2 - x1) * fb / (fb - f(x1));
         x1 = x2;
         x2 = mpoint;
         fb = f(x2);
     }
     return x2;
 }
Esempio n. 2
0
 public static double NewtonRaphsonMethod(nonLinearEquationFunction f, nonLinearEquationFunction fprime, double x0, double epsilon)
 {
     double f0 = f(x0);
     double x = x0;
     while (Math.Abs(f(x)) > epsilon)
     {
         x -= f0/fprime(x);
         f0 = f(x);
     }
     return x;
 }