Vorige: Poisson Reihen, Nach oben: Summen, Produkte und Reihen [Inhalt][Index]
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 cfexpand
for another
way to evaluate a continued fraction.
See also cfdisrep
, cfexpand
, and cflength
.
Examples:
(%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.
(%i1) cflength: 1$ (%i2) cf ((1 + sqrt(5))/2); (%o2) [1, 1, 1, 1, 2] (%i3) cflength: 2$ (%i4) cf ((1 + sqrt(5))/2); (%o4) [1, 1, 1, 1, 1, 1, 1, 2] (%i5) cflength: 3$ (%i6) cf ((1 + sqrt(5))/2); (%o6) [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]
cfdisrep
.
(%i1) cflength: 3$ (%i2) cfdisrep (cf (sqrt (3)))$ (%i3) ev (%, numer); (%o3) 1.731707317073171
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]
Constructs and returns an ordinary arithmetic expression
of the form a + 1/(b + 1/(c + ...))
from the list representation of a continued fraction [a, b, c, ...]
.
(%i1) cf ([1, 2, -3] + [1, -2, 1]); (%o1) [1, 1, 1, 2] (%i2) cfdisrep (%); 1 (%o2) 1 + --------- 1 1 + ----- 1 1 + - 2
Returns a matrix of the numerators and denominators of the last (column 1) and next-to-last (column 2) convergents of the continued fraction x.
(%i1) cf (rat (ev (%pi, numer))); `rat' replaced 3.141592653589793 by 103993/33102 =3.141592653011902 (%o1) [3, 7, 15, 1, 292] (%i2) cfexpand (%); [ 103993 355 ] (%o2) [ ] [ 33102 113 ] (%i3) %[1,1]/%[2,1], numer; (%o3) 3.141592653011902
Default value: 1
cflength
controls the number of terms of the continued
fraction the function cf
will give, as the value cflength
times the
period. Thus the default is to give one period.
(%i1) cflength: 1$ (%i2) cf ((1 + sqrt(5))/2); (%o2) [1, 1, 1, 1, 2] (%i3) cflength: 2$ (%i4) cf ((1 + sqrt(5))/2); (%o4) [1, 1, 1, 1, 1, 1, 1, 2] (%i5) cflength: 3$ (%i6) cf ((1 + sqrt(5))/2); (%o6) [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]
Vorige: Poisson Reihen, Nach oben: Summen, Produkte und Reihen [Inhalt][Index]