Sponsored links: Algebra eBooks
 

Help Index

A

B

C

D

E

F

G

H

I

J

K

L

M

N

O

P

Q

R

S

T

U

V

W

X

Y

Z

The Maxima on-line user's manual

Algebra Calculator

Search:

Cf Calculator

Cf

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 ([23,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,23]*23);
cf ([29,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,29]*29);

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:

* <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.

               (%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]

* A continued fraction can be evaluated by evaluating the arithmetic representation returned by cfdisrep.

               (%i1) cflength: 3$
               (%i2) cfdisrep (cf (sqrt (3)))$
               (%i3) ev (%, numer);
               (%o3)                   1.731707317073171

* 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]

There are also some inexact matches for cf. Try ?? cf to see them.

(%o1)                                true
(%i2) 

Cf Example

Related Examples

cf-length-sqrt

length(cf(sqrt(28!)));

Calculate

cf-sqrt

cf(539/103);

cf(sqrt(7));

Calculate

cf

cf([0, 99999999980000...

Calculate

cf-sqrt

cf(sqrt(21!));

Calculate

cf

gcf(3,23);

Calculate

cf

cf ([23, 1,1,1,1,1,1,...

Calculate

cf

cf([0, 90008919865958...

cf([0, 90008919865958...

Calculate

cf

cf ([43,1,1,1,1,1,1,1...

Calculate

cf

cf (1/2);

Calculate

cf-sqrt

cf(sqrt(8!));

Calculate