cfrac: Generate the continued-fraction form of an input number
Description
This function takes as input the numerator and denominator, as integers or bigz values, of a value to be converted into continued-fraction form. Irrationals can be processed to arbitrary precision by choosing a "closely-approximating" fraction.
Usage
cfrac(num, denom, ...)
Value
A vector of integers of the same class as the inputs (int, bigz, etc) representing the values in each level of the continued fraction.
Arguments
num
Numerator of the fraction to be converted. If a double is provided, the floor(num) will be used internally. bigz and mpfr values are allowed.
denom
Denominator of the fraction to be converted. Same rules as for the numerator.
Quoting from https://en.wikipedia.org/wiki/Continued_fraction, "In mathematics, a continued fraction is an expression obtained through an iterative process of representing a number as the sum of its integer part and the reciprocal of another number, then writing this other number as the sum of its integer part and another reciprocal, and so on."
See Also
cf2latex to generate both an inline text representation of the continued fractdion and LaTeX code for the continued fraction.