public double derivative (final double x) {
return 2*x;
}
};
final FalsePosition falsePosition = new FalsePosition();
double root = falsePosition.solve(f, accuracy, guess, xMin, xMax);
if (Math.abs(1.0-root)> accuracy) {
fail("expected: 1.0" + " but root is: " + root);
}
if(falsePosition.getMaxEvaluations() != 100){
fail("expected: 100" + " but was: " + falsePosition.getMaxEvaluations());
}
root = falsePosition.solve(f, accuracy, 0.01, 0.1);
if (Math.abs(1.0-root)> accuracy) {
fail("expected: 1.0" + " but root is: " + root);
}
}