Why does this loop yield $\pi/8$? Was doing some benchmarks for the mpmath python library on my pc with randomly generated tests.
I found that one of those tests was returning a multiple of $\pi$ consistently. I report it here:
from mpmath import *
mp.dps=50

print "correct pi: ", pi

den=mpf("3")
a=0
res=0

for n in xrange(0,1000):
    res=res+1/den
    a=a+32
    den=den+a

print "result:     ", res*8

Result:
correct pi:  3.1415926535897932384626433832795028841971693993751
result:      3.1410926536210432286970258295579986968615976706527

The convergence rate is very low. 10000 terms only give accuracy to the 5th-4th decimal digit. Is it there somewhere a formula for pi that involves the number 32?

From your program one can infer that we must have
$$
den_n=f(n)=32 T(n)+3
$$
Where $T(n)=1+2+...+n=\frac{n(n+1)}{2}$ is a so-called Triangular Number. Then you form the sum
$$
\begin{align}
res_n&=\sum_{i=0}^n\frac{1}{f(i)}\\
&=\sum_{i=0}^n\frac{1}{32 T(i)+3}\\
&=\sum_{i=0}^n\frac{1}{16i(i+1)+3}\\
\end{align}
$$
So the question remains: is this series approximating $\pi/8$ and why ... Others have elaborated on that :)
