org.apache.commons.math.analysis
Class UnivariateRealSolverUtils

java.lang.Object
  extended byorg.apache.commons.math.analysis.UnivariateRealSolverUtils

public class UnivariateRealSolverUtils
extends Object

Utility routines for UnivariateRealSolver objects.

Version:
$Revision: 1.5 $ $Date: 2003/11/14 22:22:18 $

Method Summary
static double[] bracket(UnivariateRealFunction function, double initial, double lowerBound, double upperBound)
          For a function, f, this method returns two values, a and b that bracket a root of f.
static double[] bracket(UnivariateRealFunction function, double initial, double lowerBound, double upperBound, int maximumIterations)
          For a function, f, this method returns two values, a and b that bracket a root of f.
static double solve(UnivariateRealFunction f, double x0, double x1)
          Method to solve for zeros of real univariate functions.
static double solve(UnivariateRealFunction f, double x0, double x1, double absoluteAccuracy)
          Convience method to solve for zeros of real univariate functions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

solve

public static double solve(UnivariateRealFunction f,
                           double x0,
                           double x1)
                    throws MathException
Method to solve for zeros of real univariate functions. A default solver is created and used for solving.

Parameters:
f - the function.
x0 - the lower bound for the interval.
x1 - 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 static double solve(UnivariateRealFunction f,
                           double x0,
                           double x1,
                           double absoluteAccuracy)
                    throws MathException
Convience method to solve for zeros of real univariate functions. A default solver is created and used for solving.

Parameters:
f - the function.
x0 - the lower bound for the interval.
x1 - the upper bound for the interval.
absoluteAccuracy - the accuracy to be used by the solver.
Returns:
a value where the function is zero.
Throws:
MathException - if the iteration count was exceeded or the solver detects convergence problems otherwise.

bracket

public static double[] bracket(UnivariateRealFunction function,
                               double initial,
                               double lowerBound,
                               double upperBound)
                        throws MathException
For a function, f, this method returns two values, a and b that bracket a root of f. That is to say, there exists a value c between a and b such that f(c) = 0.

Parameters:
function - the function
initial - midpoint of the returned range.
lowerBound - for numerical safety, a never is less than this value.
upperBound - for numerical safety, b never is greater than this value.
Returns:
a two element array holding {a, b}.
Throws:
MathException - if a root can not be bracketted.

bracket

public static double[] bracket(UnivariateRealFunction function,
                               double initial,
                               double lowerBound,
                               double upperBound,
                               int maximumIterations)
                        throws MathException
For a function, f, this method returns two values, a and b that bracket a root of f. That is to say, there exists a value c between a and b such that f(c) = 0.

Parameters:
function - the function
initial - midpoint of the returned range.
lowerBound - for numerical safety, a never is less than this value.
upperBound - for numerical safety, b never is greater than this value.
maximumIterations - to guard against infinite looping, maximum number of iterations to perform
Returns:
a two element array holding {a, b}.
Throws:
MathException - if a root can not be bracketted.


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