The people from Gaussianos.com (spanish blog abouth math) posted a couple of algorithms to calculate Pi and asked readers to provide some more.

I recently read on The Computational Beauty of Nature that Pi is hidden in the Mandelbrot set:

Take the mandelbrot iteration function:

`z0 = 0`

z = z^2 + c

And the initial complex number:

`c = -3/4 + a * i`

That set of complex numbers lays just between the two main parts of the *body* of the set, it is also known as the ‘neck’ (since it joins the cardiod with the biggest ‘head’).

For `a = 0` the point belongs to the mandelbrot set. Let `k` be the number of iterations needed for a point (`c = -3/4 + a * i`) to reach modulus greater than 2 (escape radius), as `a` approaches to zero, `k * a` approaches to pi.

I wrote a simple C program that shows this (http://dev.gentoo.org/~ferdy/stuff/pi_mandel_gmp.c). When compiled, linked against libgmp and run, it outputs something like the following:

a || k || aprox. pi --------++-----------++----------- 1 || 3 || 3.0000000 0.1 || 33 || 3.3000000 0.01 || 315 || 3.1500000 0.001 || 3143 || 3.1430000 0.0001 || 31417 || 3.1417000 1e-05 || 314160 || 3.1416000 1e-06 || 3141593 || 3.1415930 1e-07 || 31415927 || 3.1415927

It is an utterly expensive and pointless way to calculate pi, but it is one of the most obscure and weird ways to do it ðŸ™‚

Of course, all the credit goes to Dave Boll, who discovered the fact on 1991.

– ferdy