use of org.hipparchus.analysis.solvers.SecantSolver in project symja_android_library by axkr.
the class FindRoot method findRoot.
private double findRoot(ISymbol method, int maxIterations, IAST list, ISignedNumber min, ISignedNumber max, IExpr function, EvalEngine engine) {
ISymbol xVar = (ISymbol) list.arg1();
function = engine.evaluate(function);
UnivariateFunction f = new UnaryNumerical(function, xVar, engine);
BaseAbstractUnivariateSolver<UnivariateFunction> solver = null;
if (method.isSymbolName("Bisection")) {
solver = new BisectionSolver();
} else if (method.isSymbolName("Brent")) {
solver = new BrentSolver();
// } else if (method.isSymbolName("Laguerre")) {
// solver = new LaguerreSolver();
} else if (method.isSymbolName("Muller")) {
solver = new MullerSolver();
} else if (method.isSymbolName("Ridders")) {
solver = new RiddersSolver();
} else if (method.isSymbolName("Secant")) {
solver = new SecantSolver();
} else if (method.isSymbolName("RegulaFalsi")) {
solver = new RegulaFalsiSolver();
} else if (method.isSymbolName("Illinois")) {
solver = new IllinoisSolver();
} else if (method.isSymbolName("Pegasus")) {
solver = new PegasusSolver();
} else {
// default: NewtonSolver
DifferentiableUnivariateFunction fNewton = new UnaryNumerical(function, xVar, engine);
BaseAbstractUnivariateSolver<DifferentiableUnivariateFunction> solver2 = new NewtonSolver();
if (max == null) {
return solver2.solve(maxIterations, fNewton, min.doubleValue());
}
return solver2.solve(maxIterations, fNewton, min.doubleValue(), max.doubleValue());
}
if (max == null) {
return solver.solve(maxIterations, f, min.doubleValue());
}
return solver.solve(maxIterations, f, min.doubleValue(), max.doubleValue());
}
Aggregations