Skip to main content

Quantum Pi

Calculate pi using quantum random numbers

Background

Many engineers are just mathematicians at heart. And many mathematicians have a strange obsession with finding new ways to calculate pi. A particularly fun and convoluted method for calculating the classic circle constant involves the use of random numbers.

Leonard Euler, one of the most accomplished mathematicians in history, plays a pivotal role in this method, as calculating pi with random numbers relies heavily on his intriguing solution to the question, "What is the sum of the reciprocal squares of all integers?" In mathematics this is commonly referred to as the Basel problem and the solution, helpfully, involves pi.

1 1 2 + 1 2 2 + 1 3 2 = π 2 6

Euler's solution to the Basel problem has opened the door for calculating pi from random numbers in a new way because it implies that the probability that two numbers are coprime (do not share a factor) is 6 π 2 (for a detailed proof of this concept, click here).

The Method

If you didn't understand all of that mathematical magic, don't worry! Just understand that all we need to do is randomly generate many pairs of numbers and compare the number of pairs that share a factor to the number that do not share a factor.

Here are 10 randomly generated pairs of numbers from the CamachoLab's Quantum Random Number Generator:

Clicking on any one of the pairs of numbers above will reveal its greatest common divisor; however, all that is of concern is whether the number is greater than one or equal to one. If the GCD is greater than one, the pair of numbers have a cofactor. If the GCD is equal to one, the pair is coprime.

Check out the inspiration for this application here.