org.apache.commons.math.analysis
Interface UnivariateRealSolver

All Known Implementing Classes:
UnivariateRealSolverImpl

public interface UnivariateRealSolver

Provide an interface to algorithms for solving for zeros of real univariate functions. An implementation will only search for one zero in the given interval.

Version:
$Revision: 1.8 $ $Date: 2003/11/14 22:22:17 $

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. An exception will be thrown if the 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)
                         throws MathException
Set the absolute accuracy. The default is usually choosen so taht roots in the interval -10..-0.1 and +0.1..+10 can be found wit 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:
MathException - 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)
                         throws MathException
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 criterium 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:
MathException - 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)
                              throws MathException
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:
MathException - 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 MathException
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:
MathException - if the iteration count was exceeded or the solver detects convergence problems otherwise.

solve

public double solve(double min,
                    double max,
                    double startValue)
             throws MathException
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:
MathException - if the iteration count was exceeded or the solver detects convergence problems otherwise.

getResult

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

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

getIterationCount

public int getIterationCount()
                      throws MathException
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:
MathException - if there is no result available, either because no result was yet computed or the last attempt failed.


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