This here beneath is what I have so far:
There is an error on the last line of the code which gives no further indication:
import org.apache.commons.math3.analysis.solvers.AllowedS olution;
import org.apache.commons.math3.analysis.solvers.Bracketi ngNthOrderBrentSolver;
import org.apache.commons.math3.analysis.solvers.BrentSol ver;
import org.apache.commons.math3.analysis.solvers.PegasusS olver;
import org.apache.commons.math3.analysis.solvers.Univaria teSolver;
import org.apache.commons.math3.analysis.solvers.Univaria teSolverUtils;
public class test {
static class MyFunction implements UnivariateFunction {
public double value(double x) {
double y = hugeFormula(2);
// if (somethingBadHappens) {
// throw new LocalException(x);
// }
return y;
}
private double hugeFormula(double x) {
// TODO Auto-generated method stub
return x*x+2;
}
}
public static void main(String [] Args){
UnivariateFunction function= new MyFunction();
final double relativeAccuracy = 1.0e-12;
final double absoluteAccuracy = 1.0e-8;
final int maxOrder = 5;
UnivariateSolver solver = new BracketingNthOrderBrentSolver(relativeAccuracy, absoluteAccuracy, maxOrder);
double c = solver.solve(100, function, 1.0, 5.0, AllowedSolution.LEFT_SIDE);
}
}