Top Description Fields Constructors Methods
org.apache.commons.math3.util

public abstract Class ContinuedFraction

extends Object
Class Inheritance
Imports
org.apache.commons.math3.exception.ConvergenceException, .MaxCountExceededException, org.apache.commons.math3.exception.util.LocalizedFormats

Provides a generic means to evaluate continued fractions. Subclasses simply provided the a and b coefficients to evaluate the continued fraction.

References:

Field Summary

Modifier and TypeField and Description
private static final double
DEFAULT_EPSILON

Maximum allowed numerical error.

Constructor Summary

AccessConstructor and Description
protected
ContinuedFraction()

Default constructor.

Method Summary

Modifier and TypeMethod and Description
public double

Returns:

the value of the continued fraction evaluated at x.
evaluate
(double
the evaluation point.
x
)

Evaluates the continued fraction at the value x.

public double

Returns:

the value of the continued fraction evaluated at x.
evaluate
(double
the evaluation point.
x
,
double
maximum error allowed.
epsilon
)

Evaluates the continued fraction at the value x.

public double

Returns:

the value of the continued fraction evaluated at x.
evaluate
(double
the evaluation point.
x
,
int
maximum number of convergents
maxIterations
)

Evaluates the continued fraction at the value x.

public double

Returns:

the value of the continued fraction evaluated at x.
evaluate
(double
the evaluation point.
x
,
double
maximum error allowed.
epsilon
,
int
maximum number of convergents
maxIterations
)

Evaluates the continued fraction at the value x.

protected abstract double

Returns:

the n-th a coefficient.
getA
(int
the coefficient index to retrieve.
n
,
double
the evaluation point.
x
)

Access the n-th a coefficient of the continued fraction.

protected abstract double

Returns:

the n-th b coefficient.
getB
(int
the coefficient index to retrieve.
n
,
double
the evaluation point.
x
)

Access the n-th b coefficient of the continued fraction.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_EPSILONback to summary
private static final double DEFAULT_EPSILON

Maximum allowed numerical error.

Constructor Detail

ContinuedFractionback to summary
protected ContinuedFraction()

Default constructor.

Method Detail

evaluateback to summary
public double evaluate(double x) throws ConvergenceException

Evaluates the continued fraction at the value x.

Parameters
x:double

the evaluation point.

Returns:double

the value of the continued fraction evaluated at x.

Exceptions
ConvergenceException:
if the algorithm fails to converge.
evaluateback to summary
public double evaluate(double x, double epsilon) throws ConvergenceException

Evaluates the continued fraction at the value x.

Parameters
x:double

the evaluation point.

epsilon:double

maximum error allowed.

Returns:double

the value of the continued fraction evaluated at x.

Exceptions
ConvergenceException:
if the algorithm fails to converge.
evaluateback to summary
public double evaluate(double x, int maxIterations) throws ConvergenceException, MaxCountExceededException

Evaluates the continued fraction at the value x.

Parameters
x:double

the evaluation point.

maxIterations:int

maximum number of convergents

Returns:double

the value of the continued fraction evaluated at x.

Exceptions
ConvergenceException:
if the algorithm fails to converge.
MaxCountExceededException:
if maximal number of iterations is reached
evaluateback to summary
public double evaluate(double x, double epsilon, int maxIterations) throws ConvergenceException, MaxCountExceededException

Evaluates the continued fraction at the value x.

The implementation of this method is based on the modified Lentz algorithm as described on page 18 ff. in:

Note

the implementation uses the terms ai and bi as defined in Continued Fraction @ MathWorld.

Parameters
x:double

the evaluation point.

epsilon:double

maximum error allowed.

maxIterations:int

maximum number of convergents

Returns:double

the value of the continued fraction evaluated at x.

Exceptions
ConvergenceException:
if the algorithm fails to converge.
MaxCountExceededException:
if maximal number of iterations is reached
getAback to summary
protected abstract double getA(int n, double x)

Access the n-th a coefficient of the continued fraction. Since a can be a function of the evaluation point, x, that is passed in as well.

Parameters
n:int

the coefficient index to retrieve.

x:double

the evaluation point.

Returns:double

the n-th a coefficient.

getBback to summary
protected abstract double getB(int n, double x)

Access the n-th b coefficient of the continued fraction. Since b can be a function of the evaluation point, x, that is passed in as well.

Parameters
n:int

the coefficient index to retrieve.

x:double

the evaluation point.

Returns:double

the n-th b coefficient.