Maxima Function
cf (expr)
Converts expr into a continued fraction.
expr is an expression
comprising continued fractions and square roots of integers.
Operands in the expression may be combined with arithmetic operators.
Aside from continued fractions and square roots,
factors in the expression must be integer or rational numbers.
Maxima does not know about operations on continued fractions outside of cf
.
cf
evaluates its arguments after binding listarith
to false
.
cf
returns a continued fraction, represented as a list.
A continued fraction a + 1/(b + 1/(c + ...))
is represented by the list [a, b, c, ...]
.
The list elements a
, b
, c
, ... must evaluate to integers.
expr may also contain sqrt (n)
where n
is an integer.
In this case cf
will give as many
terms of the continued fraction as the value of the variable
cflength
times the period.
A continued fraction can be evaluated to a number
by evaluating the arithmetic representation
returned by cfdisrep
.
See also for another way to evaluate a continued fraction.
Examples:
expr is an expression comprising continued fractions and square roots of integers.
(%i1) cf ([5, 3, 1]*[11, 9, 7] + [3, 7]/[4, 3, 2]); (%o1) [59, 17, 2, 1, 1, 1, 27] (%i2) cf ((3/17)*[1, -2, 5]/sqrt(11) + (8/13)); (%o2) [0, 1, 1, 1, 3, 2, 1, 4, 1, 9, 1, 9, 2]
cflength
controls how many periods of the continued fraction
are computed for algebraic, irrational numbers.
A continued fraction can be evaluated by evaluating the arithmetic representation
returned by cfdisrep
.
Maxima does not know about operations on continued fractions outside of cf
.
(%i1) cf ([1,1,1,1,1,2] * 3); (%o1) [4, 1, 5, 2] (%i2) cf ([1,1,1,1,1,2]) * 3; (%o2) [3, 3, 3, 3, 3, 6]