JMSLTM Numerical Library 4.0

com.imsl.math
Class ZeroSystem

java.lang.Object
  extended bycom.imsl.math.ZeroSystem
All Implemented Interfaces:
Cloneable, Serializable

public class ZeroSystem
extends Object
implements Serializable, Cloneable

Solves a system of n nonlinear equations f(x) = 0 using a modified Powell hybrid algorithm.

ZeroSystem is based on the MINPACK subroutine HYBRD1, which uses a modification of M.J.D. Powell's hybrid algorithm. This algorithm is a variation of Newton's method, which uses a finite-difference approximation to the Jacobian and takes precautions to avoid large step sizes or increasing residuals. For further description, see More et al. (1980).

A finite-difference method is used to estimate the Jacobian. Whenever the exact Jacobian can be easily provided, objectF should implement ZeroSystem.Jacobian.

See Also:
Example, Serialized Form

Nested Class Summary
static class ZeroSystem.DidNotConvergeException
          The iteration did not converge.
static interface ZeroSystem.Function
          Public interface for user supplied function to ZeroSystem object.
static interface ZeroSystem.Jacobian
          Public interface for user supplied function to ZeroSystem object.
static class ZeroSystem.ToleranceTooSmallException
          Tolerance too small
static class ZeroSystem.TooManyIterationsException
          Too many iterations.
 
Constructor Summary
ZeroSystem(int n)
          Creates an object to find the zeros of a system of n equations.
 
Method Summary
 void setGuess(double[] xguess)
          Sets the initial guess for the array x.
 void setMaxIterations(int maxIterations)
          Sets the maximum number of iterations allowed.
 void setRelativeError(double errorRelative)
          Sets the relative error tolerance.
 double[] solve(ZeroSystem.Function objectF)
          Solve a system of nonlinear equations using the Levenberg-Marquardt algorithm
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZeroSystem

public ZeroSystem(int n)
Creates an object to find the zeros of a system of n equations.

Parameters:
n - is the number of equations that the solver handles
Method Detail

setGuess

public void setGuess(double[] xguess)
Sets the initial guess for the array x. The default is to set x to all zeros.

Parameters:
xguess - a double array containing the initial guess

setMaxIterations

public void setMaxIterations(int maxIterations)
Sets the maximum number of iterations allowed. The default value is 200.

Parameters:
maxIterations - an int specifying the maximum number of iterations allowed
Throws:
IllegalArgumentException - is thrown if maxIterations is less than or equal to zero.

setRelativeError

public void setRelativeError(double errorRelative)
Sets the relative error tolerance. The root is accepted if the relative error between two successive approximations to this root is within errorRelative. The default is the square root of the precision, about 1.0e-08.

Parameters:
errorRelative - a double specifying the relative error tolerance
Throws:
IllegalArgumentException - is thrown if errorRelative is less than 0 or greater than 1.

solve

public double[] solve(ZeroSystem.Function objectF)
               throws ZeroSystem.TooManyIterationsException,
                      ZeroSystem.ToleranceTooSmallException,
                      ZeroSystem.DidNotConvergeException
Solve a system of nonlinear equations using the Levenberg-Marquardt algorithm

Parameters:
objectF - defines the function whose zero is to be found. If objectF implements a Jacobian then its Jacobian is used. Otherwise a finite difference is computed.
Returns:
a double array containing the solution
Throws:
ZeroSystem.TooManyIterationsException - is thrown if the maximum number of iterations is exceeded
ZeroSystem.ToleranceTooSmallException - is thrown if the error tolerance is too small
ZeroSystem.DidNotConvergeException - is thrown if the algorithm does not converge
See Also:
ZeroSystem.Jacobian

JMSLTM Numerical Library 4.0

Copyright 1970-2006 Visual Numerics, Inc.
Built June 1 2006.