#include <continuedfraction.h>
Public Member Functions | |
continued_fraction (A &coefA, B &coefB, unsigned int iterations=100, double relative_error=1.0e-15) | |
~continued_fraction () | |
double | evaluate (double x) |
continued_fraction
and provide a
and b
coefficient functors. For example, this is the continued fraction for the exponential function defined by (2):
double exponential_a(unsigned int n, double x) { if (n == 0) { return 1.0; } else if (n % 2 == 0) { // even return 2.0; } else { // odd return n; } }
double exponential_b(unsigned int n, double x) { if (n % 2 == 0) { // even return x; } else { // odd return -x; } }
num::continued_fraction<num::continued_fraction_coefficient, num::continued_fraction_coefficient> exponential(exponential_a, exponential_b);
double x = exponential.evaluate(2.0); // std::exp(2.0) x = exponential.evaluate(4.0); // std::exp(4.0)
References:
continued_fraction< A, B >::continued_fraction | ( | A & | coefA, | |
B & | coefB, | |||
unsigned int | iterations = 100 , |
|||
double | relative_error = 1.0e-15 | |||
) | [inline] |
Create a continued fraction with the given coefficient functors.
coefA | the a coefficient functor. | |
coefB | the b coefficient functor. | |
iterations | the maximum number of iterations. | |
relative_error | the maximum allowable relative error. |
continued_fraction< A, B >::~continued_fraction | ( | ) | [inline] |
Destructor.
double continued_fraction< A, B >::evaluate | ( | double | x | ) | [inline] |
Evaluate this continued fraction at the given value.
x | the point of evalutation. |
x
.