numtheory/cfrac(deprecated) - Help

numtheory

 cfrac
 compute a regular or simple continued fraction expansion

 Calling Sequence cfrac(ex_numeric, n, con, den, 'quotients') cfrac(ex_numeric, n, con, den, 'centered', 'quotients') cfrac(ex_numeric, 'periodic', 'quotients') cfrac(ex_rat, x, n, form_rational, 'quotients') cfrac(ex_algebraic, x, n, diag, form_algebraic, 'quotients') cfrac(ex_algebraic, x=a, n, diag, form_algebraic, 'quotients') cfrac(ex_cf)

Parameters

 ex_numeric - number (rational, float, algebraic, transcendental, real, or complex) n - (optional) integer (n+1 is the number of partial quotients) con - (optional) unevaluated name (a list of n+1 convergents is assigned) den - (optional) unevaluated name (a list of n+1 denominators is assigned) quotients - (optional) literal name; specifies that cfrac compute the list form (a list of two lists: the first list is the pre-period, the second list is the period) for the continued fraction expansion. centered - (optional) literal name; specifies that cfrac compute a centered form periodic - (optional) literal name; specifies that cfrac compute the simple continued fraction expansion for a quadratic surd ex_numeric ex_rat - rational polynomial x - (optional) unevaluated name; a variable in which the continued fraction is expanded form_rational - (optional) name: simple, regular, or monic ex_algebraic - series or algebraic object diag - (optional) name: superdiagonal or subdiagonal form_algebraic - (optional) name: simple, semisimple, or simregular a - algebraic expression specifying a finite expansion point ex_cf - continued fraction in fraction form or list form

Description

 • Important: The numtheory[cfrac] command has been deprecated.  Use the superseding command NumberTheory[ContinuedFraction] instead.
 • The cfrac command computes a continued fraction expansion of a number, rational polynomial, series, or other algebraic expression.
 • There are at least five forms for continued fraction expansions:
 1 Regular continued fraction:

$[{b}_{0},[{a}_{1},{b}_{1}],[{a}_{2},{b}_{2}],\mathrm{...},[{a}_{n},{b}_{n}],\mathrm{...}],$

 where, usually, ${a}_{i}$ and ${b}_{i}$ for i > 0 are integers or polynomials with integer coefficients. If ${b}_{0}\ne 0$ then it is called superdiagonal, otherwise it is called subdiagonal.
 2 Simple continued fraction:

$[{a}_{0},{a}_{1},{a}_{2},\mathrm{...},{a}_{n},\mathrm{...}]=[{a}_{0},[1,{a}_{1}],[1,{a}_{2}],\mathrm{...},[1,{a}_{n}],\mathrm{...}].$

 3 Simregular continued fraction:

$[{b}_{0},[{a}_{1},1],[{a}_{2},1],\mathrm{...},[{a}_{n},1],\mathrm{...}].$

 4 Semisimple continued fraction:

$[{b}_{0},[{e}_{1},{b}_{1}],[{e}_{2},{b}_{2}],\mathrm{...},[{e}_{n},{b}_{n}],\mathrm{...}],$

 where $\left|{e}_{i}\right|=1$, $\mathrm{sign}\left({b}_{i}\right)=1$ for i = 1, 2, ...
 5 Monic polynomial continued fraction:

$[{b}_{0},[{e}_{1},{b}_{1}],[{e}_{2},{b}_{2}],\mathrm{...},[{e}_{n},{b}_{n}],\mathrm{...}],$

 where each ${b}_{i}$ is a monic polynomial for i = 1, 2, ...
 • By default, the cfrac command returns the fraction form of the continued fraction. The form used in the previous illustrations (1)-(5) is referred to as the list form.
 The list form for a periodic continued fraction is $\left[\left[{a}_{0},\mathrm{...},{a}_{m}\right],\left[{b}_{1},\mathrm{...},{b}_{n}\right]\right]$, where $0, $1, ${a}_{0}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}∈\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}ℤ$ and ${a}_{1},\dots ,{a}_{n}>0$ describe the preperiod and ${b}_{1},\dots ,{b}_{n}>0$ represent the period, i.e.,

${a}_{0}+\frac{1}{{a}_{1}+\frac{1}{\mathrm{...}+\frac{1}{{a}_{n}+\frac{1}{{b}_{1}+\frac{1}{\mathrm{...}+\frac{1}{{b}_{n}+\frac{1}{{b}_{1}+\frac{1}{\mathrm{...}+\frac{1}{{b}_{n}+\frac{1}{\mathrm{...}}}}}}}}}}}$

 • If you specify the quotients option, the continued fraction is returned in list form.  For large continued fractions, this form prints more quickly than the fraction form.
 • If you specify the n option, at most n + 1 quotients of the continued fraction are computed.
 • If cfrac is passed a continued fraction, in fraction or list form, it computes the last convergent of the continued fraction. For a periodic continued fraction, it returns the corresponding quadratic surd.
 • The print routine print/CFRAC is used by the prettyprinter to format the fraction form on screen.
 • This function is part of the numtheory package, and so can be used in the form cfrac(..) only after performing the command with(numtheory). The function can always be accessed in the long form numtheory[cfrac](..).
 • The cfrac command computes a continued fraction expansion for three kinds of input:
 6 Numeric
 7 Rational polynomials
 8 Series or algebraic objects

Numerical Case: Simple and Centered Continued Fraction

 • The cfrac(ex_numeric) calling sequence returns a fraction form of the continued fraction for the real or complex number ex_numeric.
 If ex_numeric is a complex number, cfrac returns a continued fraction expansion if and only if that expansion is finite. (There are many different definitions of continued fractions for complex numbers.)
 • If you specify the con option, cfrac assigns a list containing the convergents to that name.
 • If you specify the den option, cfrac assigns a list containing the denominators to that name.
 • If you specify the periodic option, cfrac computes a continued fraction for the quadratic surd ex_numeric. None of the other optional arguments (n, con, den) can be specified in this case.

Rational Polynomial Case

 • The cfrac(ex_rat) calling sequence returns a fraction form of the continued fraction for the rational polynomial ex_rat.
 • You can specify the form of the resulting continued fraction using the form_rational option (simple, regular, or monic). By default, cfrac returns the simple continued fraction form.
 • Applying the cfrac command to a finite simple continued fraction (fraction form or list form) returns the original rational polynomial.

Series and Algebraic Object Cases

 • The cfrac(ex_algebraic) calling sequence returns a superdiagonal continued fraction approximation for the series or algebraic object ex_algebraic that is equal to the $\left(k,k\right)$ or $\left(k,k-1\right)$ Pade approximant (depending on the parity of the order n if specified).
 • Using the cfrac(ex_algebraic, x=a) calling sequence, you can specify an expansion point. The continued fraction will be expressed in terms of powers of $x-a$.
 • If you specify the subdiagonal option, cfrac computes the continued fraction equivalent to the $\left(k,k\right)$ or $\left(k-1,k\right)$ Pade approximant.
 • You can specify the form of the resulting continued fraction using the form_algebraic option (simple, semisimple, or simregular). By default, cfrac returns the simple continued fraction form.

Examples

 > $\mathrm{with}\left(\mathrm{numtheory}\right):$
 > $\mathrm{cfrac}\left(\mathrm{π},6\right)$
 ${3}{+}\frac{{1}}{{7}{+}\frac{{1}}{{15}{+}\frac{{1}}{{1}{+}\frac{{1}}{{292}{+}\frac{{1}}{{1}{+}\frac{{1}}{{1}{+}{\mathrm{...}}}}}}}}$ (1)
 > $\mathrm{cfrac}\left(\mathrm{π},100,'\mathrm{quotients}'\right)$
 $\left[{3}{,}{7}{,}{15}{,}{1}{,}{292}{,}{1}{,}{1}{,}{1}{,}{2}{,}{1}{,}{3}{,}{1}{,}{14}{,}{2}{,}{1}{,}{1}{,}{2}{,}{2}{,}{2}{,}{2}{,}{1}{,}{84}{,}{2}{,}{1}{,}{1}{,}{15}{,}{3}{,}{13}{,}{1}{,}{4}{,}{2}{,}{6}{,}{6}{,}{99}{,}{1}{,}{2}{,}{2}{,}{6}{,}{3}{,}{5}{,}{1}{,}{1}{,}{6}{,}{8}{,}{1}{,}{7}{,}{1}{,}{2}{,}{3}{,}{7}{,}{1}{,}{2}{,}{1}{,}{1}{,}{12}{,}{1}{,}{1}{,}{1}{,}{3}{,}{1}{,}{1}{,}{8}{,}{1}{,}{1}{,}{2}{,}{1}{,}{6}{,}{1}{,}{1}{,}{5}{,}{2}{,}{2}{,}{3}{,}{1}{,}{2}{,}{4}{,}{4}{,}{16}{,}{1}{,}{161}{,}{45}{,}{1}{,}{22}{,}{1}{,}{2}{,}{2}{,}{1}{,}{4}{,}{1}{,}{2}{,}{24}{,}{1}{,}{2}{,}{1}{,}{3}{,}{1}{,}{2}{,}{1}{,}{1}{,}{10}{,}{2}{,}{\mathrm{...}}\right]$ (2)
 > $\mathrm{cfrac}\left({3}^{\frac{1}{2}},'\mathrm{periodic}'\right)$
 ${1}{+}\frac{{1}}{{1}{+}\frac{{1}}{{2}{+}\frac{{1}}{{1}{+}\frac{{1}}{{2}{+}{\mathrm{...}}}}}}$ (3)
 > $\mathrm{cfrac}\left({3}^{\frac{1}{2}},'\mathrm{periodic}','\mathrm{quotients}'\right)$
 $\left[\left[{1}\right]{,}\left[{1}{,}{2}\right]\right]$ (4)
 > $\mathrm{cfrac}\left(\frac{35470}{99661}+\frac{315I}{99661},'\mathrm{centered}'\right)$
 $\frac{{I}}{{3}{}{I}{+}\frac{{1}}{{1}{+}{5}{}{I}{-}\frac{{1}}{{2}{+}{I}{+}\frac{{I}}{{1}{+}{2}{}{I}{-}\frac{{I}}{{3}{+}{2}{}{I}{-}\frac{{I}}{{1}{+}{I}}}}}}}$ (5)
 > $f≔\mathrm{cfrac}\left(\frac{{x}^{4}+13{x}^{2}+50x+120}{5{x}^{2}+x+1}\right)$
 ${f}{:=}\frac{{1}}{{5}}{}{{x}}^{{2}}{-}\frac{{1}}{{25}}{}{x}{+}\frac{{321}}{{125}}{+}\frac{{1}}{\frac{{625}}{{5934}}{}{x}{-}\frac{{2810875}}{{11737452}}{+}\frac{{1}}{\frac{{23216680056}}{{14242671875}}{}{x}{+}\frac{{57431352636}}{{14242671875}}}}$ (6)
 > $\mathrm{cfrac}\left(f\right)$
 $\frac{{{x}}^{{4}}{+}{13}{}{{x}}^{{2}}{+}{50}{}{x}{+}{120}}{{5}{}{{x}}^{{2}}{+}{x}{+}{1}}$ (7)
 > $g≔\mathrm{cfrac}\left({\left(1+x\right)}^{k},x,7,'\mathrm{subdiagonal}','\mathrm{simregular}'\right)$
 ${g}{:=}\frac{{1}}{{1}{-}\frac{{k}{}{x}}{{1}{+}\frac{{1}}{{2}}{}\frac{\left({k}{+}{1}\right){}{x}}{{1}{-}\frac{{1}}{{6}}{}\frac{\left({k}{-}{1}\right){}{x}}{{1}{+}\frac{{1}}{{6}}{}\frac{\left({k}{+}{2}\right){}{x}}{{1}{-}\frac{{1}}{{10}}{}\frac{\left({k}{-}{2}\right){}{x}}{{1}{+}\frac{{1}}{{10}}{}\frac{\left({k}{+}{3}\right){}{x}}{{1}{+}{\mathrm{...}}}}}}}}}$ (8)
 > $\mathrm{op}\left(g\right)$
 $\left[{0}{,}\left[{1}{,}{1}\right]{,}\left[{-}{k}{}{x}{,}{1}\right]{,}\left[\frac{{1}}{{2}}{}\left({k}{+}{1}\right){}{x}{,}{1}\right]{,}\left[{-}\frac{{1}}{{6}}{}\left({k}{-}{1}\right){}{x}{,}{1}\right]{,}\left[\frac{{1}}{{6}}{}\left({k}{+}{2}\right){}{x}{,}{1}\right]{,}\left[{-}\frac{{1}}{{10}}{}\left({k}{-}{2}\right){}{x}{,}{1}\right]{,}\left[\frac{{1}}{{10}}{}\left({k}{+}{3}\right){}{x}{,}{1}\right]{,}{\mathrm{...}}\right]$ (9)
 > $\mathrm{cfrac}\left({ⅇ}^{x},x=1,5\right)$
 ${ⅇ}{+}\frac{{x}{-}{1}}{\frac{{1}}{{ⅇ}}{+}\frac{{x}{-}{1}}{{-}{2}{}{ⅇ}{+}\frac{{x}{-}{1}}{{-}\frac{{3}}{{ⅇ}}{+}\frac{{x}{-}{1}}{{2}{}{ⅇ}{+}\frac{{x}{-}{1}}{\frac{{5}}{{ⅇ}}{+}{\mathrm{...}}}}}}}$ (10)

Compatibility

 • The optional arguments con and den can be used in conjunction with the option centered as of Maple 16.
 • The argument ex_cf can be a periodic continued fraction as of Maple 16.
 • The a parameter was introduced in Maple 16.
 • The ex_cf parameter was updated in Maple 16.