Can a Quantum Computer Calculate Pi?
3 . 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5 0 2 8 8 4 1 9 7 1 6 9 3 9 9 3 7 5 1 0 5 8 2 0 9 7 4 9 4 4 5 9 2 3 0 7 8 1 6 4 0 6 2 8 6 2 0 8 9 9 8 6 2 8 0 3 4 8 2 5 3 4 2 1 1 7 0 6 7 9 8 2 1 4 8 0 8 6 5 1 3 2 8 2 3 0 6 6 4 7 0 9 3 8 4 4 6 0 9 5 5 0 5 8 2 2 3 1 7 2 5 3 5 9 4 0 8 1 2 8
What is Pi?
The constant Pi is one of the most used and widely recognized mathematical constants. Most of us are first introduced to it in elementary school and end up using it all throughout our lives. Pi is the ratio of a circle’s circumference to its diameter.
For thousands of years, pi has been the interest of mathematicians by the likes of Archimedes, Fibonacci, Newton, and Gauss. They’ve all tried to calculate as many digits of pi as they can and applied to different mathematical areas.
“Probably no symbol in mathematics has evoked as much mystery, romanticism, misconception and human interest as the number pi”. — William L. Schaaf
Some of the applications of pi include….
- Circumference
- Area of circles
- Sectors
- radians
In the 60 years, many technological advancements have been made which allow us to explore this famous number even more deeply than ever before!
Quantum Computing
One of the most important technological advancements made is quantum computing.
Quantum computing takes advantage of quantum phenomena like superposition and entanglement to perform computation exponentially faster than classical computers.
They have the ability to solve some of the world’s most complicated problems and algorithms. Quantum computers also have the potential to speed up drug discovery and even explore space faster, as they become more efficient in the next few decades.
In this case, we can use quantum computers to accurately estimate the value of Pi.
Quantum Phase Estimation Algorithm
A quantum phase estimation algorithm is a quantum algorithm. It plays a fundamental role in many complex quantum algorithms, like Schor’s algorithm.
QPE algorithms are used to estimate an eigenvector in a unitary operator.
In more mathematical terms, given a unitary matrix and a quantum state, the QPE algorithm estimates a value with high probability within additive error.
Estimating Pi Using Qiskit
Using a QPE algorithm, we can estimate the value Pi! Here are the steps I used from the Qiskit Textbook.
1. Import the necessary tools for the algorithm
2. Code the inverse Quantum Fourier Transform
3. Prepare the initial state for Quantum Phase Estimation
4. Run the quantum circuit
5. Create the function to estimate pi
6. Estimate pi using a different number of qubits
7. Plot the results to analyze
Results using matplotlib to visualize
You can clearly see that as the number of qubits increases, the quantum computer’s estimate of Pi gets closer to the true value of Pi.