Class NewtonRaphsonSolver
- java.lang.Object
-
- org.apache.commons.math4.legacy.analysis.solvers.BaseAbstractUnivariateSolver<UnivariateDifferentiableFunction>
-
- org.apache.commons.math4.legacy.analysis.solvers.AbstractUnivariateDifferentiableSolver
-
- org.apache.commons.math4.legacy.analysis.solvers.NewtonRaphsonSolver
-
- All Implemented Interfaces:
BaseUnivariateSolver<UnivariateDifferentiableFunction>,UnivariateDifferentiableSolver
public class NewtonRaphsonSolver extends AbstractUnivariateDifferentiableSolver
Implements Newton's Method for finding zeros of real univariate differentiable functions.- Since:
- 3.1
-
-
Constructor Summary
Constructors Constructor Description NewtonRaphsonSolver()Construct a solver.NewtonRaphsonSolver(double absoluteAccuracy)Construct a solver.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected doubledoSolve()Method for implementing actual optimization algorithms in derived classes.doublesolve(int maxEval, UnivariateDifferentiableFunction f, double min, double max)Find a zero near the midpoint ofminandmax.-
Methods inherited from class org.apache.commons.math4.legacy.analysis.solvers.AbstractUnivariateDifferentiableSolver
computeObjectiveValueAndDerivative, setup
-
Methods inherited from class org.apache.commons.math4.legacy.analysis.solvers.BaseAbstractUnivariateSolver
computeObjectiveValue, getAbsoluteAccuracy, getEvaluations, getFunctionValueAccuracy, getMax, getMaxEvaluations, getMin, getRelativeAccuracy, getStartValue, incrementEvaluationCount, isBracketing, isSequence, solve, solve, verifyBracketing, verifyInterval, verifySequence
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.commons.math4.legacy.analysis.solvers.BaseUnivariateSolver
getAbsoluteAccuracy, getEvaluations, getFunctionValueAccuracy, getMaxEvaluations, getRelativeAccuracy, solve, solve
-
-
-
-
Constructor Detail
-
NewtonRaphsonSolver
public NewtonRaphsonSolver()
Construct a solver.
-
NewtonRaphsonSolver
public NewtonRaphsonSolver(double absoluteAccuracy)
Construct a solver.- Parameters:
absoluteAccuracy- Absolute accuracy.
-
-
Method Detail
-
solve
public double solve(int maxEval, UnivariateDifferentiableFunction f, double min, double max) throws TooManyEvaluationsException
Find a zero near the midpoint ofminandmax.- Specified by:
solvein interfaceBaseUnivariateSolver<UnivariateDifferentiableFunction>- Overrides:
solvein classBaseAbstractUnivariateSolver<UnivariateDifferentiableFunction>- Parameters:
f- Function to solve.min- Lower bound for the interval.max- Upper bound for the interval.maxEval- Maximum number of evaluations.- Returns:
- the value where the function is zero.
- Throws:
TooManyEvaluationsException- if the maximum evaluation count is exceeded.NumberIsTooLargeException- ifmin >= max.
-
doSolve
protected double doSolve() throws TooManyEvaluationsException
Method for implementing actual optimization algorithms in derived classes.- Specified by:
doSolvein classBaseAbstractUnivariateSolver<UnivariateDifferentiableFunction>- Returns:
- the root.
- Throws:
TooManyEvaluationsException- if the maximal number of evaluations is exceeded.
-
-