An interesting formula for $\pi$

Looking through some old notebooks I found this monster of a formula:

For any integer $$r>1$$, we have

$$\pi=(-1)^{\left\lfloor\frac{r}{2}\right\rfloor-\left\lfloor\frac{2r-1}{4}\right\rfloor}\sum_{n=1}^\infty \frac{(2r-1)((2r-1)(n-1))!}{(n(2r-1)-1)!}\left(\sum_{k=1}^{\left\lfloor\frac{2r-1}{2}\right\rfloor} (-1)^{f(k,r)}\frac{\cot\left(\frac{\pi kr}{2r-1}\right)}{(2r-3)!} {2r-3\choose g(k,r)}\right)^{-1},$$

where we have $$f(k,r)=k+1+\frac{1}{2} \left(\left\lfloor \frac{2r-1}{4}\right\rfloor -\left\lfloor \frac{r}{2}\right\rfloor+k-1\right) \left(\left\lfloor \frac{2r-1}{4}\right\rfloor -\left\lfloor \frac{r}{2}\right\rfloor+k\right)$$ and $$g(k,r)=k \left\lfloor \frac{2r-1}{2}\right\rfloor -1\ \% \ 2 r-1,$$ with $$\%$$ denoting the modulo operation. It's kind of messy but I can't seem to simplify it much more. A number of years have passed since I found it and I don't even remember how I derived it (also, I haven't done any mathematics for over five years so I'm kind of rusty). I'm pretty sure it has something to do with rising or falling factorials though. It seems to converge pretty quickly. To get the first one thousand decimals of $$\pi$$ with, say $$r=300$$, we don't really need the series to go to infinity, $$17$$ will suffice.

So, my question is if anyone knows anything about this formula. Is it well-known? Are there any other, similar formulas? What's going on with the cotangents? I have a hard time "visualizing" what's going on (and I really wish I kept better, more detailed notes).

Edit:

If anyone is interested, here is more compact (and hopefully more legible) version which holds true if and only if $$r\equiv 3\pmod{4}$$:

$$\pi=\sum_{n=1}^\infty \frac{r(r(n-1))!}{(nr-1)!}\left(\sum_{k=1}^{\frac{r-1}{2}} i^{k (k-1)-2}\frac{\cot\left(\frac{\pi k(r+1)}{2r}\right)}{(r-2)!} {r-2\choose \frac{k (r+1)-2}{2}\ \% \ r}\right)^{-1}.$$

Edit 2 (some background):

Just to give some context: I think this formula grew out of the study of series such as

$$\sum_{n=1}^{\infty} (rn)_{1-r}=\sum_{n=1}^{\infty}\left(\prod_{i=1}^{r-1}(rn-i)\right)^{-1}=\sum_{n=1}^{\infty}\frac{1}{(rn-1)(rn-2)\cdots (rn-r+1)},$$

where $$(n)_r$$ is the Pochhammer symbol. The basic idea is that

$$\sum_{\substack{\gcd(r,a_i)=1 \\ a_i

for some (increasingly unruly and complicated) factor $$A$$. For example:

$$\sum_{n=1}^{\infty}\frac{8}{(4n-1)(4n-3)}$$ $$\sum_{n=1}^{\infty}\frac{\frac{150}{\sqrt{250-110\sqrt{5}}}}{(5n-1)(5n-2)(5n-3)(5n-4)}$$ $$\sum_{n=1}^{\infty}\frac{8\sqrt{3}}{(6n-1)(6n-5)}$$

and for $$r=7$$ the factor looks something like this:

$$-\frac{5040 (-1)^{4/7} \left(2 \sqrt{-1}-2 (-1)^{5/7}+(-1)^{6/7}-1\right) \sqrt{26767+44439 i \sqrt{3}}}{56 i \sqrt{26767+44439 i \sqrt{3}}+\sqrt{14} \left(\sqrt{2} \left(26767+44439 i \sqrt{3}\right)^{2/3} \left(\sqrt{3}-i\right)-1238 \sqrt{7} \left(\sqrt{3}+i\right)\right)}.$$

Moving around some terms here and there I guess we end up with the infinite series of factorials to the left and $$A$$ being the inverted sum on the right. What would be cool to know is if there's any way of simplifying the whole binomial-mod-thing. Any thoughts are welcome!

• You don't discover a formula like this by accident. Are you sure you don't remember anything about what motivated it? E.g. what motivated the definitions of $f$ and $g$? – Clive Newstead Apr 9 at 14:11
• Those cotangents make this seem reminiscent of Archimedes' polygonal approximation. But all the factorials and the oddly specific definition of $f$ and $g$ elude me. (That said, removing the floor functions in favor of doing everything in modulo operations would probably help with geometric interpretation of a truncation.) – Ian Apr 9 at 14:13
• (For example, a lot of the seemingly funky case work here disappears without a trace if you just decide whether $r$ should be odd or even up front.) – Ian Apr 9 at 14:23
• @CliveNewstead Well, I was trying stuff out with rising and falling factorials, the other pages in the notebook are full of observations on those. But I guess all calculations were done in Mathematica, and I can't find the file. I will look some more. – Carolus Apr 9 at 14:23
• Don't get me wrong, it's cool that it works for both odd and even $r$. But it'd be easier to look at in $\begin{cases} \dots & r \text{ is odd } \\ \dots & r \text{ is even } \end{cases}$ form. For example, I think the sign pattern in the summation over $k$ is actually relatively simple, but it's tedious to extract it from this general formula for $f$. – Ian Apr 9 at 14:26

Note the following identity: $$\begin{equation} \frac{1}{1-x^r}= \frac{1}{r} \sum\limits_{p=0}^{r-1} \frac{-1}{x-e^{\frac{2 \imath \pi p}{r}}} \cdot (-1)^{\frac{2 p}{r}} \quad (i) \end{equation}$$ where $$r$$ is a positive integer.

Now, let us assume that $$r\ge 3$$ is a prime number. We define the following quantity: $$\begin{equation} {\mathfrak S}(r):= \sum\limits_{n=1}^\infty \frac{1}{\prod\limits_{p=1}^{r-1} (r n-p)} \end{equation}$$ Then we have: $$\begin{eqnarray} {\mathfrak S}(r)&=& \int\limits_{[0,1]^{r-1}} \frac{\prod\limits_{\xi=1}^{r-1}t_\xi^{r-1-\xi}}{\left(1-\prod\limits_{\xi=1}^{r-1} t_\xi^r\right)} \cdot \prod\limits_{\xi=1}^{r-1} dt_\xi \\ &=&\frac{\pi}{r (r-2)!} \sum\limits_{q=0}^{r-2} \binom{r-2}{q} (-1)^q \cot[\frac{\pi(1+q)}{r}] + \frac{\pi \imath^{3 r+1}}{r(r-2)!} \sum\limits_{q=0}^{r-1} (-1)^q \left( 2 \sin[\frac{\pi q}{r}]\right)^{r-2} \frac{q}{r} \end{eqnarray}$$ where we obtained the expression on the very bottom by using $$(i)$$ and successively integrating over $$t_\xi$$ starting from $$\xi=r-1$$ all the way down to $$\xi=1$$.

In:= r = Prime[RandomInteger[{2, 10}]]; M = 5000;
N[Take[Accumulate[
Table[1/Product[r n - p, {p, 1, r - 1}], {n, 1, M}]], -5],
100] // MatrixForm
N[1/r (I \[Pi])/(r - 2)! Sum[
Binomial[r - 2, q] (-1)^q (-1)^((2 (q + 1) p )/r)
If[p == 0, 1, (2 p)/r - 1], {p, 0, r - 1}, {q, 0, r - 2}] +
1/r (I \[Pi])/(r - 2)! Sum[ (1 - E^((2 I p \[Pi])/r))^(r - 2)  p/
r (-1)^(1 + 2 p/r), {p, 0, r - 1}], 100]
N[1/r  \[Pi]/(r - 2)! Sum[
Binomial[r - 2, q] (-1)^q ( Cot[(\[Pi] (1 + q))/r]), {q, 0,
r - 2}] +
1/r ( I^(3 r + 1) \[Pi])/(r - 2)! Sum[ (-1)^
q (2 Sin[(  q \[Pi])/r])^(r - 2)  q/r, {q, 0, r - 1}], 100] • Where did the first identity come from out of curiosity? – Tom Himler Apr 25 at 1:40
• @Tom Himler The first identity is just partial fraction decomposition -- see formulae in my answer to math.stackexchange.com/questions/3184487/… . – Przemo Apr 25 at 9:18
• Ah I see, I did not see the $i$ in the exponential function. – Tom Himler Apr 25 at 17:59