Sunday, May 24, 2020

Using Random Numbers to Estimate Pi


A friend recently asked that I post something about the mathematical constant, pi. It is the ratio of a circle's circumference to it diameter. To fifty digits, pi is 

3.14159265358979323846264338327950288419716939937510...

There have been many methods established for calculating pi. One of the more interesting methods is derived from Euler's solution to the zeta function:

Euler showed that this function, in its limit, is:

This result has been used in number theory to establish the probability (P) of two random numbers being relatively prime (having no common factors greater than 1) is approximately:

Now, if we generate a large number of pairs of random numbers, we can count how many are relatively prime and then use the proportion to estimate pi using the formula:
I wrote a Google Sheet to make this approximation using 1000 pairs of random numbers. A link to this sheet is here and you can try for yourself. To refresh or change the 1000 pairs of numbers, simply update a blank cell in the sheet. In my first estimate, there were 612 of the 1000 pairs that were relatively prime yielding a proportion, P, of 0.612. This gave an approximation of pi of 3.13.



 

No comments:

Post a Comment

1679 - One important message sent from Earth 31 years ago

In 1974 an interstellar radio transmission was broadcast to the  globular cluster   Messier 13   from the Arecibo radio telescope in Puerto ...

Popular in last 30 days