public class ContinuedFraction extends AbstractUnivariateRealFunction
Modifier and Type | Class and Description |
---|---|
static class |
ContinuedFraction.MaxIterationsExceededException
RuntimeException thrown when the continued fraction fails to converge for a given epsilon before a certain number of iterations. |
static interface |
ContinuedFraction.Partials
This interface defines a continued fraction in terms of
the partial numerators an, and the partial denominators bn.
|
Function.EvaluationException
Constructor and Description |
---|
ContinuedFraction(ContinuedFraction.Partials partials)
Construct a continued fraction.
|
ContinuedFraction(ContinuedFraction.Partials partials,
double epsilon,
int maxIterations)
Construct a continued fraction.
|
ContinuedFraction(ContinuedFraction.Partials partials,
int scale,
int maxIterations)
Construct a continued fraction.
|
Modifier and Type | Method and Description |
---|---|
BigDecimal |
evaluate(BigDecimal x)
Evaluate z.
|
double |
evaluate(double x)
Evaluate y = f(x).
|
evaluate
dimensionOfDomain, dimensionOfRange
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
dimensionOfDomain, dimensionOfRange
public ContinuedFraction(ContinuedFraction.Partials partials, double epsilon, int maxIterations)
partials
- the definition in terms of partial numerators and partial denominatorsepsilon
- a precision parameter: when a number |x| ≤ ε, it is considered 0maxIterations
- the maximum number of iterationspublic ContinuedFraction(ContinuedFraction.Partials partials, int scale, int maxIterations)
partials
- the definition in terms of partial numerators and partial denominatorsscale
- the accuracymaxIterations
- the maximum number of iterationspublic ContinuedFraction(ContinuedFraction.Partials partials)
partials
- the definition in terms of partial numerators and partial denominatorspublic double evaluate(double x)
double
arithmetics.
It is quick.
However, the precision is limited by the double precision of the intermediate results.
This (and probably other implementations using double precision math) may give poor results for some continued fraction.x
- xContinuedFraction.MaxIterationsExceededException
- if it does not converge before the maximum number of iterations;
repeat with a bigger epsilon, or use the BigDecimal version of the algorithmpublic BigDecimal evaluate(BigDecimal x)
BigDecimal
.x
- xContinuedFraction.MaxIterationsExceededException
- if it does not converge before the maximum number of iterations; repeat with a bigger epsilonCopyright © 2010-2020 NM FinTech Ltd.. All Rights Reserved.