Message Boards Message Boards

Squeezing Pi from a Menger Sponge

Posted 8 years ago
Attachments:
POSTED BY: Ed Pegg
4 Replies
Posted 4 years ago

I tried programming the second to last equation to approximate pi (for no real reason) but ran into something unexpected. Here is the code (in python):

num=int(input(": "))

pi=4

for n in range(num):

  den=(2*(n+1)+1)**2

  pi=pi*(den-1)/den

print(pi)

I ran the loop 1,000,000,000 times and the result dropped below pi. Is that supposed to happen?

POSTED BY: Henry Carolan

The last equation giving pi could be simplified a bit: 4*(prod from 1 to n of sum from 1 to n of 8n)/((2n+1)!!)^2.

http://www.wolframalpha.com/input/?i=4%2A%28prod%20from%201%20to%20n%20of%20sum%20from%201%20to%20n%20of%208n%29%2F%28%282n%2B1%29%21%21%29%5E2

POSTED BY: Michele Venturi
Posted 8 years ago

Just saw your mention on StandUpMaths: The Fractal Menger Sponge and Pi

Neat stuff, Ed!

POSTED BY: Kurt Gimbel

enter image description here - another post of yours has been selected for the Staff Picks group, congratulations !

We are happy to see you at the tops of the "Featured Contributor" board. Thank you for your wonderful contributions, and please keep them coming!

POSTED BY: Vitaliy Kaurov
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract