An amazing one-minute bit of fun at the interactive prompt

R

Raymond Hettinger

e = 10.0 ** -7; n = 0; z = c = complex(-0.75, e) n += 1
z = z * z + c
3.1415926

Compute ð ± e by counting Mandlebrot set iterations :)


Raymond
 
R

Raymond Hettinger

Compute ð ± e by counting Mandlebrot set iterations :)

That should be: pi plus-or-minus e

Raymond
 
S

Steven D'Aprano

n += 1
z = z * z + c

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).
 
A

Anssi Saari

Ben Finney said:
Very cool! I love π nerdery.




It was in my reader. Perhaps your server has encoding trouble?

He (or rather Google) used iso-8859-7 as a character set, which is the
Latin/Greek alphabet and definitely has pi at 0xF0. Not exactly a
common character set though. Running a iso-8859-1 font in a terminal
means I see a ? instead of pi...
 
R

Roy Smith

Ben Finney said:
Very cool! I love � nerdery.




It was in my reader. Perhaps your server has encoding trouble?

He was probably reading the nroff man page.

(ducking and running)
 
M

Martin v. Loewis

eps would be a better name than e.

py> ε = 10.0 ** -7; n = 0; z = c = complex(-0.75, ε)
py> while abs(z) < 2.0:
.... n += 1
.... z = z * z + c
....
py> π = n * ε
py> print(Ï€)
3.1415926

Regards,
Martin
 
M

Mark Dickinson

[...]
3.1415926

Compute ð ± e by counting Mandlebrot set iterations :)

Very neat! Is it supposed to be obvious why this gives an
approximation to pi? If so, I'll think about it a bit more; if not,
do you have any references?

Maybe you should have saved this for March 14th...

Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,229
Latest member
GloryAngul

Latest Threads

Top