Class NewtonSolver
- java.lang.Object
-
- org.apache.commons.math.ConvergingAlgorithmImpl
-
- org.apache.commons.math.analysis.solvers.UnivariateRealSolverImpl
-
- org.apache.commons.math.analysis.solvers.NewtonSolver
-
- All Implemented Interfaces:
UnivariateRealSolver,ConvergingAlgorithm
public class NewtonSolver extends UnivariateRealSolverImpl
Implements Newton's Method for finding zeros of real univariate functions.The function should be continuous but not necessarily smooth.
-
-
Constructor Summary
Constructors Constructor Description NewtonSolver()Deprecated.in 2.2 (to be removed in 3.0).NewtonSolver(DifferentiableUnivariateRealFunction f)Deprecated.as of 2.0 the function to solve is passed as an argument to thesolve(UnivariateRealFunction, double, double)orUnivariateRealSolver.solve(UnivariateRealFunction, double, double, double)method.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description doublesolve(double min, double max)Deprecated.doublesolve(double min, double max, double startValue)Deprecated.doublesolve(int maxEval, UnivariateRealFunction f, double min, double max)Find a zero near the midpoint ofminandmax.doublesolve(int maxEval, UnivariateRealFunction f, double min, double max, double startValue)Find a zero near the valuestartValue.doublesolve(UnivariateRealFunction f, double min, double max)Deprecated.in 2.2 (to be removed in 3.0).doublesolve(UnivariateRealFunction f, double min, double max, double startValue)Deprecated.in 2.2 (to be removed in 3.0).-
Methods inherited from class org.apache.commons.math.analysis.solvers.UnivariateRealSolverImpl
getFunctionValue, getFunctionValueAccuracy, getResult, resetFunctionValueAccuracy, setFunctionValueAccuracy
-
Methods inherited from class org.apache.commons.math.ConvergingAlgorithmImpl
getAbsoluteAccuracy, getIterationCount, getMaximalIterationCount, getRelativeAccuracy, resetAbsoluteAccuracy, resetMaximalIterationCount, resetRelativeAccuracy, setAbsoluteAccuracy, setMaximalIterationCount, setRelativeAccuracy
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.commons.math.ConvergingAlgorithm
getAbsoluteAccuracy, getIterationCount, getMaximalIterationCount, getRelativeAccuracy, resetAbsoluteAccuracy, resetMaximalIterationCount, resetRelativeAccuracy, setAbsoluteAccuracy, setMaximalIterationCount, setRelativeAccuracy
-
-
-
-
Constructor Detail
-
NewtonSolver
@Deprecated public NewtonSolver(DifferentiableUnivariateRealFunction f)
Deprecated.as of 2.0 the function to solve is passed as an argument to thesolve(UnivariateRealFunction, double, double)orUnivariateRealSolver.solve(UnivariateRealFunction, double, double, double)method.Construct a solver for the given function.- Parameters:
f- function to solve.
-
NewtonSolver
@Deprecated public NewtonSolver()
Deprecated.in 2.2 (to be removed in 3.0).Construct a solver.
-
-
Method Detail
-
solve
@Deprecated public double solve(double min, double max) throws MaxIterationsExceededException, FunctionEvaluationExceptionDeprecated.Solve for a zero root in the given interval.A solver may require that the interval brackets a single zero root. Solvers that do require bracketing should be able to handle the case where one of the endpoints is itself a root.
- Parameters:
min- the lower bound for the interval.max- the upper bound for the interval.- Returns:
- a value where the function is zero
- Throws:
FunctionEvaluationException- if an error occurs evaluating the functionMaxIterationsExceededException
-
solve
@Deprecated public double solve(double min, double max, double startValue) throws MaxIterationsExceededException, FunctionEvaluationExceptionDeprecated.Solve for a zero in the given interval, start at startValue.A solver may require that the interval brackets a single zero root. Solvers that do require bracketing should be able to handle the case where one of the endpoints is itself a root.
- Parameters:
min- the lower bound for the interval.max- the upper bound for the interval.startValue- the start value to use- Returns:
- a value where the function is zero
- Throws:
FunctionEvaluationException- if an error occurs evaluating the functionMaxIterationsExceededException
-
solve
public double solve(int maxEval, UnivariateRealFunction f, double min, double max) throws MaxIterationsExceededException, FunctionEvaluationExceptionFind a zero near the midpoint ofminandmax.- Overrides:
solvein classUnivariateRealSolverImpl- Parameters:
f- the function to solvemin- the lower bound for the intervalmax- the upper bound for the intervalmaxEval- Maximum number of evaluations.- Returns:
- the value where the function is zero
- Throws:
MaxIterationsExceededException- if the maximum iteration count is exceededFunctionEvaluationException- if an error occurs evaluating the function or derivativejava.lang.IllegalArgumentException- if min is not less than max
-
solve
@Deprecated public double solve(UnivariateRealFunction f, double min, double max) throws MaxIterationsExceededException, FunctionEvaluationException
Deprecated.in 2.2 (to be removed in 3.0).Find a zero near the midpoint ofminandmax.- Parameters:
f- the function to solvemin- the lower bound for the intervalmax- the upper bound for the interval- Returns:
- the value where the function is zero
- Throws:
MaxIterationsExceededException- if the maximum iteration count is exceededFunctionEvaluationException- if an error occurs evaluating the function or derivativejava.lang.IllegalArgumentException- if min is not less than max
-
solve
public double solve(int maxEval, UnivariateRealFunction f, double min, double max, double startValue) throws MaxIterationsExceededException, FunctionEvaluationExceptionFind a zero near the valuestartValue.- Overrides:
solvein classUnivariateRealSolverImpl- Parameters:
f- the function to solvemin- the lower bound for the interval (ignored).max- the upper bound for the interval (ignored).startValue- the start value to use.maxEval- Maximum number of evaluations.- Returns:
- the value where the function is zero
- Throws:
MaxIterationsExceededException- if the maximum iteration count is exceededFunctionEvaluationException- if an error occurs evaluating the function or derivativejava.lang.IllegalArgumentException- if startValue is not between min and max or if function is not aDifferentiableUnivariateRealFunctioninstance
-
solve
@Deprecated public double solve(UnivariateRealFunction f, double min, double max, double startValue) throws MaxIterationsExceededException, FunctionEvaluationException
Deprecated.in 2.2 (to be removed in 3.0).Find a zero near the valuestartValue.- Parameters:
f- the function to solvemin- the lower bound for the interval (ignored).max- the upper bound for the interval (ignored).startValue- the start value to use.- Returns:
- the value where the function is zero
- Throws:
MaxIterationsExceededException- if the maximum iteration count is exceededFunctionEvaluationException- if an error occurs evaluating the function or derivativejava.lang.IllegalArgumentException- if startValue is not between min and max or if function is not aDifferentiableUnivariateRealFunctioninstance
-
-