|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.math.analysis.UnivariateRealSolverImpl
org.apache.commons.math.analysis.LaguerreSolver
public class LaguerreSolver
Implements the Laguerre's Method for root finding of real coefficient polynomials. For reference, see A First Course in Numerical Analysis, ISBN 048641454X, chapter 8.
Laguerre's method is global in the sense that it can start with any initial approximation and be able to solve all roots from that point.
Field Summary | |
---|---|
private PolynomialFunction |
p
polynomial function to solve |
private static long |
serialVersionUID
serializable version identifier |
Fields inherited from class org.apache.commons.math.analysis.UnivariateRealSolverImpl |
---|
absoluteAccuracy, defaultAbsoluteAccuracy, defaultFunctionValueAccuracy, defaultMaximalIterationCount, defaultRelativeAccuracy, f, functionValueAccuracy, iterationCount, maximalIterationCount, relativeAccuracy, result, resultComputed |
Constructor Summary | |
---|---|
LaguerreSolver(UnivariateRealFunction f)
Construct a solver for the given function. |
Method Summary | |
---|---|
PolynomialFunction |
getPolynomialFunction()
Returns a copy of the polynomial function. |
protected boolean |
isRootOK(double min,
double max,
Complex z)
Returns true iff the given complex root is actually a real zero in the given interval, within the solver tolerance level. |
Complex |
solve(Complex[] coefficients,
Complex initial)
Find a complex root for the polynomial with the given coefficients, starting from the given initial value. |
double |
solve(double min,
double max)
Find a real root in the given interval. |
double |
solve(double min,
double max,
double initial)
Find a real root in the given interval with initial value. |
Complex[] |
solveAll(Complex[] coefficients,
Complex initial)
Find all complex roots for the polynomial with the given coefficients, starting from the given initial value. |
Complex[] |
solveAll(double[] coefficients,
double initial)
Find all complex roots for the polynomial with the given coefficients, starting from the given initial value. |
Methods inherited from class org.apache.commons.math.analysis.UnivariateRealSolverImpl |
---|
clearResult, getAbsoluteAccuracy, getFunctionValueAccuracy, getIterationCount, getMaximalIterationCount, getRelativeAccuracy, getResult, isBracketing, isSequence, resetAbsoluteAccuracy, resetFunctionValueAccuracy, resetMaximalIterationCount, resetRelativeAccuracy, setAbsoluteAccuracy, setFunctionValueAccuracy, setMaximalIterationCount, setRelativeAccuracy, setResult, verifyBracketing, verifyInterval, verifySequence |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final long serialVersionUID
private PolynomialFunction p
Constructor Detail |
---|
public LaguerreSolver(UnivariateRealFunction f) throws java.lang.IllegalArgumentException
f
- function to solve
java.lang.IllegalArgumentException
- if function is not polynomialMethod Detail |
---|
public PolynomialFunction getPolynomialFunction()
public double solve(double min, double max, double initial) throws ConvergenceException, FunctionEvaluationException
Requires bracketing condition.
min
- the lower bound for the intervalmax
- the upper bound for the intervalinitial
- the start value to use
ConvergenceException
- if the maximum iteration count is exceeded
or the solver detects convergence problems otherwise
FunctionEvaluationException
- if an error occurs evaluating the
function
java.lang.IllegalArgumentException
- if any parameters are invalidpublic double solve(double min, double max) throws ConvergenceException, FunctionEvaluationException
Despite the bracketing condition, the root returned by solve(Complex[], Complex) may not be a real zero inside [min, max]. For example, p(x) = x^3 + 1, min = -2, max = 2, initial = 0. We can either try another initial value, or, as we did here, call solveAll() to obtain all roots and pick up the one that we're looking for.
min
- the lower bound for the intervalmax
- the upper bound for the interval
ConvergenceException
- if the maximum iteration count is exceeded
or the solver detects convergence problems otherwise
FunctionEvaluationException
- if an error occurs evaluating the
function
java.lang.IllegalArgumentException
- if any parameters are invalidprotected boolean isRootOK(double min, double max, Complex z)
min
- the lower bound for the intervalmax
- the upper bound for the intervalz
- the complex root
public Complex[] solveAll(double[] coefficients, double initial) throws ConvergenceException, FunctionEvaluationException
coefficients
- the polynomial coefficients arrayinitial
- the start value to use
ConvergenceException
- if the maximum iteration count is exceeded
or the solver detects convergence problems otherwise
FunctionEvaluationException
- if an error occurs evaluating the
function
java.lang.IllegalArgumentException
- if any parameters are invalidpublic Complex[] solveAll(Complex[] coefficients, Complex initial) throws MaxIterationsExceededException, FunctionEvaluationException
coefficients
- the polynomial coefficients arrayinitial
- the start value to use
MaxIterationsExceededException
- if the maximum iteration count is exceeded
or the solver detects convergence problems otherwise
FunctionEvaluationException
- if an error occurs evaluating the
function
java.lang.IllegalArgumentException
- if any parameters are invalidpublic Complex solve(Complex[] coefficients, Complex initial) throws MaxIterationsExceededException, FunctionEvaluationException
coefficients
- the polynomial coefficients arrayinitial
- the start value to use
MaxIterationsExceededException
- if the maximum iteration count is exceeded
or the solver detects convergence problems otherwise
FunctionEvaluationException
- if an error occurs evaluating the
function
java.lang.IllegalArgumentException
- if any parameters are invalid
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |