# On expressing $\frac{\pi^n}{4\cdot 3^{n-1}}$ as a continued fraction.

It is a celebrated equation that $$\frac{\pi}{4}=\cfrac{1}{1+\cfrac{1^2}{3+\cfrac{2^2}{5+\cfrac{3^2}{7+\ddots}}}}$$

However, there are two other conjectured equations that I found which, if true (they seem to be), might reveal a pattern.

$$\frac{\pi^2}{12}=\cfrac{1}{1+\cfrac{1^4}{3+\cfrac{2^4}{5+\cfrac{3^4}{7+\ddots}}}}$$

$$\frac{\pi^3}{36}=\cfrac{1}{1+\cfrac{1^6}{3+\cfrac{2^6}{5+\cfrac{3^6}{7+\ddots}}}}$$

Conjectured General Formula: For natural $$n\geqslant 1$$, $$\frac{\pi^n}{4\cdot 3^{n-1}}=\cfrac{1}{1+\cfrac{1^{2n}}{3+\cfrac{2^{2n}}{5+\cfrac{3^{2n}}{7+\ddots}}}}$$

Can these be numerically verified? I have not the skill to by-hand prove/disprove these, and have only been using Wolfram Alpha to arrive at these conjectures.

It would also be much appreciated if one could suggest a program I could install in order to evaluate these continued fractions independently, as well as the code required. Will PARI/GP suffice?

Thanks.

• To your last question: Pari/GP should suffice for all numerical computations. However as I found out in my answer it seems that convergence of the continued fractions for the $\pi^3/36$ problem cannot be solved numerically. If at all the continued fraction converges it might be so slow that we have no chance to arrive at 40 or 80 correct digits. An analytical solution is required, imho, and here Pari/GP cannot help much... – Gottfried Helms Feb 26 '20 at 15:01

There is a continued fraction in "Ramanujan’s Continued Fractions, Apéry’s Constant, and More" by Tito Piezas III from "A Collection of Algebraic Identities":

Entry 30:

$$f(x) = \sum_{k=0}^\infty\frac1{(x+2k+1)^2} =\cfrac{1}{x+} \;\cfrac{1^4}{3x+} \;\cfrac{2^4}{5x+} \;\cfrac{3^4}{7x+} \;\cdots$$

which yields $$f(1)=\pi^2/12$$. There is also a route in "Entry 16."

Please notice that I didn't read that paper and I am just citing, and I don't know if it is proven or if it just follows from a conjecture.

However, the alleged fraction for π³/36 diverges, and here is why. $$\def\K#1#2#3#4{\underset{#1}{\overset{#2}{\operatorname K}} \frac{#3}{#4}}$$ Let's consider continued fractions of the form $$f(k)=\K{n=1}{\infty}{a_n^k}{b_n}$$ with $$a_n=n$$ and $$b_n=2n+1$$. Your assertion is then expressed as $$\frac{\pi^3}{36} \stackrel ?= \cfrac{1}{1+f(6)}$$ where the right side converges iff $$f(6)$$ converges. Now divide all partial fractions by their numerator which gets a new representation with the same convergence behavior: $$f(k)=\K{n=1}{\infty}{1}{c_n^k b_n}$$ where the $$c_n$$ satisfy the recurrence $$c_n=1/(a_n c_{n-1})$$. With the above definition of $$a_n$$, this gives the explicit representation $$c_n =\frac{(n-1)!!}{n!!} \approx \sqrt\frac{2}{\pi n}$$ where $$!!$$ denotes the double factorial. The approximation follows from properties of the Γ function and can be expressed less sloppily, in particular $$\lim_{n\to\infty}\frac{\Gamma (n + \alpha)}{n^\alpha\Gamma(n)} = 1 \qquad\text{ applied to }\qquad n!! = \sqrt{\frac{2^{n+1}}{\pi}} \Gamma\left(\tfrac{n}{2}+1\right)$$ Then observe that the series $$\sum_n c_n^k b_n \approx \left(\frac 2\pi\right)^{k/2} \sum_n n^{-k/2}(2n+1)$$ with $$k$$ fixed converges absolutely for $$1-k/2 < -1 \Leftrightarrow k > 4$$. From the absolute convergence of that series

it follows that $$f(k)$$ diverges by oscillation for $$k>4$$.

Addendum: For your future research we get the following take-away: Denote $$f_n \sim g_n \Longleftrightarrow \left( g_n\to\infty \text{ and } 0 < \liminf_{n\to\infty}\,\frac{f_n}{g_n} \leqslant \limsup_{n\to\infty}\,\frac{f_n}{g_n} < \infty \right)$$ Using that notation, we get the corollary

Let $$a_n, b_n>0$$ be two sequences with $$a_n\sim n^\alpha$$ and $$b_n\sim n^\beta$$. Then $$\alpha - 2\beta > 2 \quad\Longrightarrow\quad \K{n=1}{\infty}{a_n}{b_n} \;\text{ diverges by oscillation.}$$

(Notice that the notation for ~ implies α, β > 0.)

• Wow! 1) I could not find a reference on the internet for the life of me, and 2) I can't believe I rediscovered a formula from the almighty Ramanujan! :D – Mr Pie Feb 26 '20 at 10:48
• sI suppose Entry $16$ reveals the general pattern. That is astounding. Congratulations! I already upvoted, so now all that remains: $\color{green}{\checkmark}$ :) – Mr Pie Feb 26 '20 at 11:37

Using Pari/GP with 200 dec digits internal precision and up to 2 million entries for the continued fractions the results are inconclusive.

• Preface: I'm reformulating your continued fractions slightly to match my Pari/GP-procedures. Instead of $$\Tiny \frac{\pi}{4}=\cfrac{1}{1+\cfrac{1^2}{3+\cfrac{2^2}{5+\cfrac{3^2}{7+\ddots}}}}$$ I use $$\Tiny w_0={1+\cfrac{1^2}{3+\cfrac{2^2}{5+\cfrac{3^2}{7+\ddots}}}}$$ $$w_1=1/w_0 \\ \frac{\pi}{4}=w_1$$

For $$\pi/4$$ and $$\pi^2/12$$ the results approximate well, the latter needs many coefficients for the continued fraction.

For $$\pi^3/36$$ the results are inconclusive. The approximations for $$k,k+2,k+4,...$$ coefficients seem to converge to one value, and the approximations for $$k+1,k+3,k+5,...$$ coefficients seem to converge to another value, so that possibly the continued fraction as such might not be convergent.

Below the protocols for the $$\pi/4$$ , $$\pi^2/12$$ and the $$\pi^3/36$$ approaches.

I have the definition for the entries of the cont-fraction as strings in a function call, plus the number of coefficients to be used.

• Setting for $$\pi/4$$
w0 = CF("1+2*k", "(1+k)^2", 2000 ); w1=1/w0; print([w1,w2=Pi/4,err=w1-w2])
gives [0.785398163397, 0.785398163397, 5.613524196 E-202]
correct result to 202 dec digits.

• Setting for $$\pi^2/12$$
w0 = CF("1+2*k", "(1+k)^4", 20 000 ); w1=1/w0; print([w1,w2=Pi^2/12,err=w1-w2])
w0 = CF("1+2*k", "(1+k)^4", 20 001 ); w1=1/w0; print([w1,w2=Pi^2/12,err=w1-w2])
gives
[0.82246703 4674, 0.822467033424, 0.00000000124981251875]
[0.82246703 2174, 0.822467033424, -0.00000000124968755624]
correct result to 10 dec digits. But note, that the continued fraction is not yet in a usable state of approximation!
Let's use 200 000 and 200 001 coefficients:
[0.8224670334 37, 0.822467033424, 1.24998125019 E-11]
[0.8224670334 12, 0.822467033424, -1.24996875056 E-11]
The convergence needs exorbitant many coefficients to achieve usable approximation, but at least it seems to work in general.

• Setting for $$\pi^3/36$$
w0 = CF("1+2*k", "(1+k)^6", 2 000 000 ); w1=1/w0; print([w1,w2=Pi^3/36,err=w1-w2])
w0 = CF("1+2*k", "(1+k)^6", 2 000 001 ); w1=1/w0; print([w1,w2=Pi^3/36,err=w1-w2])
gives
[0.907969268604, 0.861285463342, 0.0466838052623]
[0.810934471732, 0.861285463342, -0.0503509916094]
and giving more coefficients becomes usesless in practical purposes.

Conclusion: the first two continued fractions seem to be correct, because of the improvement of accuracy roughly related to the increase of number-of-used coefficients.
With the third continued fraction I've doubts, whether it might be possible that the continued fraction cannot converge at all. But I've never read such a thing - on the other hand I don't know much about non-simple continued fractions like in your cases here. Added: the wikipedia-entry on generalized continued fractions mentions the possibility of non-convergence, so this may well happen here.
But if it can be proved that it converges then I'd guess that it converges to your expected value.
Generalization: I think in general numerical checks on the common road of computation become useless and it is needed to apply algebraic arguments and find an analytical answer.

appendix: Pari/GP-program used.

  {CF(funcA,funcB="1",maxcoeffs=100) = local(convgts,a_k,b_k);
eval(Str("A_(k)=",funcA));  \\ installing the function A_(n) given by string funcA
eval(Str("B_(k)=",funcB));  \\ installing the function B_(n) given by string funcB
convgts = [B_(0),A_(0);0,1];  \\ initialize
for(k=1,maxcoeffs,
a_k = A_(k);
b_k = B_(k);
convgts = convgts * [0,1; b_k,a_k]; \\matrix-multiplication
);
return( convgts[1,2]/ convgts[2,2]*1.0) ; }


Example: CF("1+k","1") evaluates the generalized continued fraction using A=[1;2,3,4,5,...] , B=[1,1,1,1,1,...] and because B has only ones as coefficients this is a simple continued fraction.

Example: CF("1+k","2+k") evaluates the generalized continued fraction using A=[1;2,3,4,5,...] , B=[2,3,4,5,6,...] giving $$\exp(1)-1 \approx 1.71828$$ .

Note, for the reference to the index of the coefficient use the symbol k in your formula-string. The first entry is indexed by k=0.

update
Here a protocol for the approximation-history of the $$\pi^3/36$$-problem. The odd and even indexed convergents from 20001 on are displayed:

   odd convergents           even convergents
k     cvgt(k)          k     cvgt(k)
--------------------------------------------
20001  1.23315310020  20002  1.10135343484
20003  1.23315309941  20004  1.10135343539
20005  1.23315309862  20006  1.10135343594
20007  1.23315309783  20008  1.10135343648
20009  1.23315309704  20010  1.10135343703
20011  1.23315309625  20012  1.10135343758
20013  1.23315309545  20014  1.10135343813
20015  1.23315309466  20016  1.10135343867
20017  1.23315309387  20018  1.10135343922
20019  1.23315309308  20020  1.10135343977


We see the micro-minimal improve towards a common convergent downwards in the left table and upwards in the right table.
Here the binomial-transforms (P^-1*List)

        inverse binomial transform of the list
odd convergents                     even convergents
k     cvgt(k)                     k     cvgt(k)
---------------------------------------------------------------
20001             1.23315310020  20002            1.10135343484
2  -0.000000000791808010433      2  0.000000000548026207045
0         1.58319661722E-13      0       -1.09568710520E-13
0        -4.74785730458E-17      0        3.28563729351E-17
0         1.89826039525E-20      0       -1.31355425421E-20
0        -9.48594322162E-24      0        6.56361379837E-24
0         5.68778402700E-27      0       -3.93528208757E-27
0        -3.97840565974E-30      0        2.75240356386E-30
0         3.17997410062E-33      0       -2.19986945318E-33
0        -2.85921776493E-36      0        1.97783856983E-36


The micro-minimality of the improvement of approximation becomes possibly even more stunning when comparing the improvement from $$2*10^3, 2*10^4, 2*10^5$$ to $$2*10^6$$ coefficients. this gives this table:

  reciprocal      reciprocal
even convergent  odd convergent     at index    at index
-----------------------------------------------------------
0.908014406855  0.810882478513        2 000       2 001
0.907973742909  0.810929315943       20 000      20 001
0.907969675369  0.810934002994      200 000     200 001
0.907969268604  0.810934471732    2 000 000   2 000 001


It really seems as if the approximates at even and odd convergents get stuck at separate values.(The reciprocal convergents should both approximate $$\pi^3/36 \approx 0.8613$$)

• Thanks heaps for this answer! This was very useful and thoroughly explained. This is also the first time I have developed a continued fraction that seems very likely to be divergent, which is very interesting. Thanks heaps Helms :) – Mr Pie Feb 26 '20 at 21:31
• @MrPie - thanks for your compliments! Well, I've got more curious, too: what is the exponent between $4$ and $6$ from where the divergence occurs. I have no real good template at the moment, but by some peeks into it seems it might be between $4.2$ and $4.5$ or $4.8$. But the picture is shadowy. It would be good to make a new question for this specific point: how to determine convergence/ divergence of continued fractions of this type dependend on the exponent. (But I think I won't do such a question actually, feel a bit tired already...) – Gottfried Helms Feb 26 '20 at 21:36
• @GottfriedHelms: "It really seems as if the approximates at even and odd convergents get stuck at separate values": Indeed. As I managed to show in my answer, that fraction diverges by oscillation. – emacs drives me nuts Feb 27 '20 at 11:52
• @emacsdrivesmenuts - very nice! Thanks for pinging me up. – Gottfried Helms Feb 27 '20 at 12:01

I cannot confirm the last fraction for π³/36. (Addendum: See my other answer for why that fraction does diverge (by oscillation b.t.w.)).

I used the following quick Python script. math.pi is only of limited precision, but it's error is much smaller than the error for the 3rd fraction.

#!/usr/bin/env python

from __future__ import print_function
from decimal import *
from math import *

getcontext().prec = 1000

def expand (N, expo):
f = Decimal(0)
for i in range (N, 0, -1):
z = Decimal(i) ** expo
n = 2*i + 1
print ("%d / %d+" % (z, n))
f = z / (n + f)
print ("%d / %d+" % (1, 1))
return 1 / (1 + f)

Pi = Decimal(pi)
res = expand (1200, 6)
print ("frac is approx", res)
print ("\nfrac - pi^3 / 36  is approx: ", res - Pi*Pi*Pi / 36)
print ("\n'float' precision is roughly 2^{%f}"
% (log(abs(sqrt(pi) ** 2 - pi)) / log(2)))



Running:

...
15625 / 11+
4096 / 9+
729 / 7+
64 / 5+
1 / 3+
1 / 1+
frac is approx 0.9080445148...
frac - pi^3 / 36  is approx:  0.0467590515...
'float' precision is roughly 2^{-51.000000}


The last is what is expected from IEEE double precision, i.e. the error in Pi^3 / 36 is of similar magnitude and orders of magnitude smaller than 0.046.

Note: This is just an indicator in which direction to go; I didn't bother with how fast / good that fraction converges and how errors propagate. (One could use Fraction (rationals) but they will explode.)

• That was a typo, just refresh your page. – emacs drives me nuts Feb 26 '20 at 11:17
• Well, as I was iterating the third fraction, the results seemed to oscillate between $\pi^3\div 38$ and $\pi^3\div 34$ so, being convergent, I just took the average $\pi^3\div 36$ and conjectured the fraction to converge to that value. But $0.9080445148\ldots\approx \pi^3\div 34.1462$. The most decent approximation of the form $\pi^a \div b$ I can find to equal the aforesaid decimal is $\pi^5 \div 337$. – Mr Pie Feb 26 '20 at 11:21
• Thank you for the code. I will award you a 50 rep bounty in a few days :) – Mr Pie Feb 26 '20 at 11:38
• Not for that code. – emacs drives me nuts Feb 26 '20 at 12:35
• @Mr Pie: That code is no more needed and served it's purpose: The fraction for π³/36 diverges as shown in my other answer. – emacs drives me nuts Feb 27 '20 at 11:50