Continued Fraction

Author

Eric W. Weisstein
January 19, 2017

This notebook downloaded from http://mathworld.wolfram.com/notebooks/NumberTheory/ContinuedFraction.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/ContinuedFraction.html.

©2017 Wolfram Research, Inc. except for portions noted otherwise

Notation

Big-K

HoldForm[Subscript[b,0]+ContinuedFractionK[Subscript[a,i],Subscript[b,i],{i,1,∞}]]//TraditionalForm

Pringsheim

With[{top={Black,White,White,Black},bot={White,Black,Black,White}},Grid[{{Item[Subscript[a,1],Frame->top]},{Item[Subscript[b,1],Frame->bot]}}]+Grid[{{Item[Subscript[a,1],Frame->top]},{Item[Subscript[b,2],Frame->bot]}}]]//TraditionalForm

Example

ContinuedFractionK[Subscript[a,i],Subscript[b,i],{i,4}]

FromGeneralContinuedFraction[l_List?MatrixQ,simp_:Identity]:=Fold[simp[#2[[1]]/(#1+#2[[2]])]&,0,Reverse[l]]

FromGeneralContinuedFraction[Table[{Subscript[a,i],Subscript[b,i]},{i,4}]]

Note this builds up fractions “from the bottom” and so cannot be used to get the convergents:

FromGeneralContinuedFractionList[l_List?MatrixQ]:=FoldList[#2[[1]]/(#1+#2[[2]])&,0,Reverse[l]]

FromGeneralContinuedFractionList[Table[{b[k],a[k]},{k,4}]]

Closed Forms

1+(Underoverscript[\[ContinuedFractionK], n, ∞])((2 n)/(2 n+1))==(((Sqrt[e])+1)/(e-1))

$Version

1+ContinuedFractionK[2n,2n+1,{n,∞}]

1+ContinuedFractionK[2n,2n+1,{n,100}]//N

N[(Sqrt[E] + 1)/(E - 1)]

(Underoverscript[\[ContinuedFractionK], (k=0), ∞])((q^k)/1)==(((QPochhammer2[q, (q^5)]) (QPochhammer2[(q^4), (q^5)]))/((QPochhammer2[(q^2), (q^5)]) (QPochhammer2[(q^3), (q^5)]))) [Rogers-Ramnujan]

$Version

(q^(1/5))ContinuedFractionK[(q^(k-1)),1,{k,∞}]

(q^(1/5))ContinuedFractionK[(q^k),1,{k,0,∞}]

Plot[(q^(1/5))ContinuedFractionK[(q^(k-1)),1,{k,50}]-(q^(1/5))((QPochhammer[q,(q^5)]QPochhammer[(q^4),(q^5)])/(QPochhammer[(q^2),(q^5)]QPochhammer[(q^3),(q^5)])),{q,.01,.99}]

Plot[(q^(1/5))ContinuedFractionK[(q^k),1,{k,0,50}]-(q^(1/5))((QPochhammer[q,(q^5)]QPochhammer[(q^4),(q^5)])/(QPochhammer[(q^2),(q^5)]QPochhammer[(q^3),(q^5)])),{q,.01,.99}]

(Underoverscript[\[ContinuedFractionK], (n=0), ∞])((e^(-2 π n))/1)==(e^(2 π/5)) ((Sqrt[(Sqrt[5]) ϕ])-ϕ) [Ramanujan]

$Version

ContinuedFractionK[Exp[-2(n-1) Pi],1,{n,∞}]

ContinuedFractionK[Exp[-2n Pi],1,{n,0,∞}]

N[Exp[2π/5](Sqrt[GoldenRatio Sqrt[5]]-GoldenRatio),20]

N[ContinuedFractionK[Exp[-2(n-1) Pi],1,{n,300}],20]

N[ContinuedFractionK[Exp[-2n Pi],1,{n,0,300}],20]

(Underoverscript[\[ContinuedFractionK], (n=0), ∞])((exp(-2 π (Sqrt[5]) n))/1)==(((Sqrt[5])/((((5^(3/4)) ((((1/2) ((Sqrt[5])-1)))^(5/2))-1)^(1/5))+1))-(1/2) ((Sqrt[5])+1)) (e^((2 π)/(Sqrt[5]))) [Ramanujan]

$Version

ContinuedFractionK[Exp[-2n Pi(Sqrt[5])],1,{n,0,∞}]

N[ContinuedFractionK[Exp[-2n Pi(Sqrt[5])],1,{n,0,200}],20]

N[(((Sqrt[5])/(1+((((5^(3/4))((((((Sqrt[5])-1)/2)))^(5/2))-1))^(1/5))))-(((Sqrt[5])+1)/2))(E^(2π/(Sqrt[5]))),20]

(1/(1+(Underoverscript[\[ContinuedFractionK], (n=1), ∞])(((Ceiling[(n/2)])^2)/1)))==4 (∫_0^∞)((x exp((Sqrt[5]) (-x)))/(cosh(x)))dx [Ramanujan]

$Version

ContinuedFractionK[((Ceiling[n/2])^2),1,{n,∞}]

N[1/(1+ContinuedFractionK[((Ceiling[n/2])^2),1,{n,1000}]),20]

i=4Integrate[((x Exp[-x (Sqrt[5])])/(Cosh[x])),{x,0,∞}]//FullSimplify

N[i,20]

(1/((Underoverscript[\[ContinuedFractionK], n, ∞])(((Ceiling[(n/2)])^3)/({{{, ({{n+1, (Mod[n, 2])==0}, {1, True}})}}))+1))==2 (∫_0^∞)(((x^2) exp((Sqrt[3]) (-x)))/(sinh(x)))dx [Ramanujan]

$Version

ContinuedFractionK[((Ceiling[n/2])^3),1,{n,∞}]

1/(1+ContinuedFractionK[((Ceiling[n/2])^3),Piecewise[{{n+1,Mod[n,2]==0}},N[1,20]],{n,2*^5}])

i2=2Integrate[(((x^2)Exp[-x (Sqrt[3])])/(Sinh[x])),{x,0,∞}]//FullSimplify

N[i2,20]

Recurrence Relations

Recurrence

ConvergentsByRecurrence[b0_,l_]:=Module[{A,B,a,b},
{a,b}=Transpose[l];
A[-1]=1;
A[0]=b0;
B[-1]=0;
B[0]=1;
A[k_]:=b[[k]] A[k-1]+a[[k]]A[k-2];
B[k_]:=b[[k]] B[k-1]+a[[k]]B[k-2];
Table[A[k]/B[k],{k,0,Length[l]}]
]

ContinuedFractionK[i,i,{i,∞}]//N

ConvergentsByRecurrence[0,Table[{n,n},{n,10}]]

Table[ContinuedFractionK[i,i,{i,k}],{k,10}]

ContinuedFractionK[i,(i^2),{i,1000}]//N

ConvergentsByRecurrence[0,Table[{n,n^2},{n,10}]]

Table[ContinuedFractionK[i,(i^2),{i,k}],{k,10}]

A(n) B(n-1)-A(n-1) B(n)==(((-1))^(n+1))(Subscript[a, 1])(Subscript[a, 2])(Subscript[⋯a, n]) XXXX

c=ConvergentsByRecurrence[0,Table[{n,n^2},{n,10}]]

A[n_]:=Numerator[c[[n+1]]];
B[n_]:=Denominator[c[[n+1]]];

A[3]/B[3]

Table[{A[n]B[n-1]-A[n-1]B[n],(((-1))^(n+1))Product[k,{k,2,n-2}]},{n,2,8}]