ContinuedFraction (Apache Commons Math 3.6.1 API)

org.apache.commons.math3.util

## Class ContinuedFraction

- java.lang.Object
- - org.apache.commons.math3.util.ContinuedFraction

-     public abstract class ContinuedFraction
      extends Object

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

  References:

  - Continued Fraction

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `ContinuedFraction()` Default constructor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `double` | `evaluate(double x)` Evaluates the continued fraction at the value x.
    `double` | `evaluate(double x, double epsilon)` Evaluates the continued fraction at the value x.
    `double` | `evaluate(double x, double epsilon, int maxIterations)` Evaluates the continued fraction at the value x.
    `double` | `evaluate(double x, int maxIterations)` Evaluates the continued fraction at the value x.
    `protected abstract double` | `getA(int n, double x)` Access the n-th a coefficient of the continued fraction.
    `protected abstract double` | `getB(int n, double x)` Access the n-th b coefficient of the continued fraction.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ContinuedFraction

          protected ContinuedFraction()

      Default constructor.

  - ### Method Detail

    - #### getA

          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` - the coefficient index to retrieve.
        `x` - the evaluation point.
      Returns:
        the n-th a coefficient.

    - #### getB

          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` - the coefficient index to retrieve.
        `x` - the evaluation point.
      Returns:
        the n-th b coefficient.

    - #### evaluate

          public double evaluate(double x)
                          throws ConvergenceException

      Evaluates the continued fraction at the value x.
      Parameters:
        `x` - the evaluation point.
      Returns:
        the value of the continued fraction evaluated at x.
      Throws:
        `ConvergenceException` - if the algorithm fails to converge.

    - #### evaluate

          public double evaluate(double x,
                        double epsilon)
                          throws ConvergenceException

      Evaluates the continued fraction at the value x.
      Parameters:
        `x` - the evaluation point.
        `epsilon` - maximum error allowed.
      Returns:
        the value of the continued fraction evaluated at x.
      Throws:
        `ConvergenceException` - if the algorithm fails to converge.

    - #### evaluate

          public double evaluate(double x,
                        int maxIterations)
                          throws ConvergenceException,
                                 MaxCountExceededException

      Evaluates the continued fraction at the value x.
      Parameters:
        `x` - the evaluation point.
        `maxIterations` - maximum number of convergents
      Returns:
        the value of the continued fraction evaluated at x.
      Throws:
        `ConvergenceException` - if the algorithm fails to converge.
        `MaxCountExceededException` - if maximal number of iterations is reached

    - #### evaluate

          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:

      - I. J. Thompson, A. R. Barnett. "Coulomb and Bessel Functions of Complex Arguments and Order." http://www.fresco.org.uk/papers/Thompson-JCP64p490.pdf
      Note: the implementation uses the terms ai and bi as defined in Continued Fraction @ MathWorld.
      Parameters:
        `x` - the evaluation point.
        `epsilon` - maximum error allowed.
        `maxIterations` - maximum number of convergents
      Returns:
        the value of the continued fraction evaluated at x.
      Throws:
        `ConvergenceException` - if the algorithm fails to converge.
        `MaxCountExceededException` - if maximal number of iterations is reached

Copyright © 2003–2016 The Apache Software Foundation. All rights reserved.