CONTINUED_FRACTION
Evaluation of Continued Fractions
CONTINUED_FRACTION
is a C++ library which
implements some simple algorithms for dealing with simple and
generalized continued fractions.
Mathematically, continued fractions are infinite sums. In general,
they are treated computationally as finite sums. Here we will assume
that all such sums terminate at index N.
A simple continued fraction (SCF) is a representation of a number
R as:
R = A0 + 1 / ( A1 + 1 / ( A2 + 1 / ( A3 + ... + 1 / AN )...)))
A generalized continued fraction (GCF) is a representation of a number
R as:
R = A0 + B1 / ( A1 + B2 / ( A2 + B3 / ( A3 + ... + BN / AN )...)))
For either form of continued fraction, there are two tasks:

Given a value R, determine an Nterm SCF or GCF which is equal to,
or approximates, R.

Given the coefficients of an SCF or GCF, determine the sequence
of rational values represented by computing the partial sums.
The final sum is the value R.
Licensing:
I don't care what you do with this code.
Languages:
CONTINUED_FRACTION is available in
a C version and
a C++ version and
a FORTRAN90 version and
a MATLAB version..
Related Software and Data:
SUBSET,
a C++ library which
enumerates, generates, randomizes, ranks and unranks combinatorial objects
including combinations, compositions, Gray codes, index sets, partitions,
permutations, polynomials, subsets, and Young tables. Backtracking
routines are included to solve some combinatorial problems. Some routines
for continued fractions are included.
Reference:

Norman Richert,
Strang's Strange Figures,
American Mathematical Monthly,
Volume 99, Number 2, February 1992, pages 101107.
Source Code:
Examples and Tests:
List of Routines:

I4CF_EVALUATE evaluates a continued fraction with I4 entries.

I4CF_EVALUATE_TEST tests I4CF_EVALUATE.

I4SCF_EVALUATE evaluates a simple continued fraction with I4 entries.

I4SCF_EVALUATE_TEST tests I4SCF_EVALUATE.

I4VEC_PRINT prints an I4VEC.

I8CF_EVALUATE evaluates a continued fraction with I8 entries.

I8CF_EVALUATE_TEST tests I8CF_EVALUATE.

I8SCF_EVALUATE evaluates a simple continued fraction with I8 entries.

I8SCF_EVALUATE_TEST tests I8SCF_EVALUATE.

I8VEC_PRINT prints an I8VEC.

R8_TO_I4SCF approximates an R8 with an I4 simple continued fraction.

R8_TO_I4SCF_TEST tests R8_TO_I4SCF.

R8_TO_I8SCF approximates an R8 with an I8 simple continued fraction.

R8_TO_I8SCF_EVALUATE_TEST tests R8_TO_I8SCF.

R8CF_EVALUATE evaluates a continued fraction with R8 entries.

R8CF_EVALUATE_TEST tests R8CF_EVALUATE.

R8SCF_EVALUATE evaluates a simple continued fraction with R8 entries.

R8SCF_EVALUATE_TEST tests R8SCF_EVALUATE.

R8VEC_PRINT prints an R8VEC.

TIMESTAMP prints the current YMDHMS date as a time stamp.
You can go up one level to
the C++ source codes.
Last revised on 07 August 2017.