An amazing one-minute bit of fun at the interactive prompt
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Sun Feb 20 08:42:26 EST 2011
On Sun, 20 Feb 2011 00:08:58 -0800, Raymond Hettinger wrote:
>>>> e = 10.0 ** -7; n = 0; z = c = complex(-0.75, e)
>>>> while abs(z) < 2.0:
> n += 1
> z = z * z + c
>
>>>> n * e
> 3.1415926
Absolutely brilliant! That alone justifies including complex as a built-
in type. *wink*
> Compute π ± e by counting Mandlebrot set iterations :-)
eps would be a better name than e. As I read it, π ± e would be some
number between 0.423310825130748 and 5.859874482048838, which isn't a
terribly impressive approximation :)
BTW, I see the symbol in your post as π (pi), not ð (lowercase eth).
--
Steven
More information about the Python-list
mailing list