public double derivative (final double x) {
return 2*x;
}
};
final Newton newt = new Newton();
double root = newt.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, newt.getMaxEvaluations());
if(newt.getMaxEvaluations() != 100){
fail("expected: 100" + " but was: " + newt.getMaxEvaluations());
}
root = newt.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);
}
//assertEquals(10, newt.getNumEvaluations());
if(newt.getNumEvaluations() != 10){
fail("expected: 10" + " but was: " + newt.getNumEvaluations());
}
}