org.apache.commons.math.analysis
Interface UnivariateRealSolver

All Known Implementing Classes:
UnivariateRealSolverImpl

public interface UnivariateRealSolver

Interface for (univariate real) rootfinding algorithms.

Implementations will search for only one zero in the given interval.

Version:
$Revision: 1.14 $ $Date: 2004/07/17 21:19:39 $

Method Summary
 double getAbsoluteAccuracy()
          Get the actual absolute accuracy.
 double getFunctionValueAccuracy()
          Get the actual function value accuracy.
 int getIterationCount()
          Get the number of iterations in the last run of the solver.
 int getMaximalIterationCount()
          Get the upper limit for the number of iterations.
 double getRelativeAccuracy()
          Get the actual relative accuracy.
 double getResult()
          Get the result of the last run of the solver.
 void resetAbsoluteAccuracy()
          Reset the absolute accuracy to the default.
 void resetFunctionValueAccuracy()
          Reset the actual function accuracy to the default.
 void resetMaximalIterationCount()
          Reset the upper limit for the number of iterations to the default.
 void resetRelativeAccuracy()
          Reset the relative accuracy to the default.
 void setAbsoluteAccuracy(double accuracy)
          Set the absolute accuracy.
 void setFunctionValueAccuracy(double accuracy)
          Set the function value accuracy.
 void setMaximalIterationCount(int count)
          Set the upper limit for the number of iterations.
 void setRelativeAccuracy(double accuracy)
          Set the relative accuracy.
 double solve(double min, double max)
          Solve for a zero root in the given interval.
 double solve(double min, double max, double startValue)
          Solve for a zero in the given interval, start at startValue.
 

Method Detail

setMaximalIterationCount

public void setMaximalIterationCount(int count)
Set the upper limit for the number of iterations.

Usually a high iteration count indicates convergence problems. However, the "reasonable value" varies widely for different solvers. Users are advised to use the default value supplied by the solver.

A ConvergenceException will be thrown if this number is exceeded.

Parameters:
count - maximum number of iterations

getMaximalIterationCount

public int getMaximalIterationCount()
Get the upper limit for the number of iterations.

Returns:
the actual upper limit

resetMaximalIterationCount

public void resetMaximalIterationCount()
Reset the upper limit for the number of iterations to the default.

The default value is supplied by the solver implementation.

See Also:
setMaximalIterationCount(int)

setAbsoluteAccuracy

public void setAbsoluteAccuracy(double accuracy)
Set the absolute accuracy.

The default is usually choosen so that roots in the interval -10..-0.1 and +0.1..+10 can be found with a reasonable accuracy. If the expected absolute value of your roots is of much smaller magnitude, set this to a smaller value.

Solvers are advised to do a plausibility check with the relative accuracy, but clients should not rely on this.

Parameters:
accuracy - the accuracy.
Throws:
IllegalArgumentException - if the accuracy can't be achieved by the solver or is otherwise deemed unreasonable.

getAbsoluteAccuracy

public double getAbsoluteAccuracy()
Get the actual absolute accuracy.

Returns:
the accuracy

resetAbsoluteAccuracy

public void resetAbsoluteAccuracy()
Reset the absolute accuracy to the default.

The default value is provided by the solver implementation.


setRelativeAccuracy

public void setRelativeAccuracy(double accuracy)
Set the relative accuracy.

This is used to stop iterations if the absolute accuracy can't be achieved due to large values or short mantissa length.

If this should be the primary criterion for convergence rather then a safety measure, set the absolute accuracy to a ridiculously small value, like 1E-1000.

Parameters:
accuracy - the relative accuracy.
Throws:
IllegalArgumentException - if the accuracy can't be achieved by the solver or is otherwise deemed unreasonable.

getRelativeAccuracy

public double getRelativeAccuracy()
Get the actual relative accuracy.

Returns:
the accuracy

resetRelativeAccuracy

public void resetRelativeAccuracy()
Reset the relative accuracy to the default. The default value is provided by the solver implementation.


setFunctionValueAccuracy

public void setFunctionValueAccuracy(double accuracy)
Set the function value accuracy.

This is used to determine whan an evaluated function value or some other value which is used as divisor is zero.

This is a safety guard and it shouldn't be necesary to change this in general.

Parameters:
accuracy - the accuracy.
Throws:
IllegalArgumentException - if the accuracy can't be achieved by the solver or is otherwise deemed unreasonable.

getFunctionValueAccuracy

public double getFunctionValueAccuracy()
Get the actual function value accuracy.

Returns:
the accuracy

resetFunctionValueAccuracy

public void resetFunctionValueAccuracy()
Reset the actual function accuracy to the default. The default value is provided by the solver implementation.


solve

public double solve(double min,
                    double max)
             throws ConvergenceException,
                    FunctionEvaluationException
Solve for a zero root in the given interval. A solver may require that the interval brackets a single zero 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:
ConvergenceException - if the maximum iteration count is exceeded or the solver detects convergence problems otherwise.
FunctionEvaluationException - if an error occurs evaluating the function
IllegalArgumentException - if min > max or the endpoints do not satisfy the requirements specified by the solver

solve

public double solve(double min,
                    double max,
                    double startValue)
             throws ConvergenceException,
                    FunctionEvaluationException
Solve for a zero in the given interval, start at startValue. A solver may require that the interval brackets a single zero 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:
ConvergenceException - if the maximum iteration count is exceeded or the solver detects convergence problems otherwise.
FunctionEvaluationException - if an error occurs evaluating the function
IllegalArgumentException - if min > max or the arguments do not satisfy the requirements specified by the solver

getResult

public double getResult()
Get the result of the last run of the solver.

Returns:
the last result.
Throws:
IllegalStateException - if there is no result available, either because no result was yet computed or the last attempt failed.

getIterationCount

public int getIterationCount()
Get the number of iterations in the last run of the solver.

This is mainly meant for testing purposes. It may occasionally help track down performance problems: if the iteration count is notoriously high, check whether the function is evaluated properly, and whether another solver is more amenable to the problem.

Returns:
the last iteration count.
Throws:
IllegalStateException - if there is no result available, either because no result was yet computed or the last attempt failed.


Copyright © 2003-2004 The Apache Software Foundation. All Rights Reserved.