Package org.jquantlib.math.solvers1D

Examples of org.jquantlib.math.solvers1D.Bisection


      public double derivative (final double x) {
        return 2*x;
      }
    };

    final Bisection bisection = new Bisection();

    double root = bisection.solve(f, accuracy, guess, xMin, xMax);

    // assertEquals(1.0, root, accuracy);
    if (Math.abs(1.0-root)> accuracy) {
      fail("expected: 1.0" + " but root is: " + root);
    }

    // assertEquals(100, bisection.getMaxEvaluations());
    if(bisection.getMaxEvaluations() != 100){
      fail("expected: 100" + " but was: " + bisection.getMaxEvaluations());
    }

    root = bisection.solve(f, accuracy, 0.01, 0.1);

    // assertEquals(1.0, root, accuracy);
    if (Math.abs(1.0-root)> accuracy) {
      fail("expected: 1.0" + " but root is: " + root);
    }

    // TODO Check why getNumEvalutions is 56 with guess = 0.01 and step = 0.1
    //assertEquals(56, bisection.getNumEvaluations());
    if(bisection.getNumEvaluations() != 56){
      fail("expected: 56" + " but was: " + bisection.getNumEvaluations());
    }

  }
View Full Code Here

TOP

Related Classes of org.jquantlib.math.solvers1D.Bisection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.