There’s been a lot of hype recently surrounding quantum computers. From IBM releasing their new 127-qubit Eagle Chip, to Xanadu unveiling their Quantum Codebook, there’s been a lot going on in the industry!
However, this news might lead one to wonder: Sure, the tech’s cool and all, but what can I actually use a quantum computer for?
Before we get started, a few important notes:
- This is meant to be a beginner-friendly walkthrough of Grover’s algorithm, but you should have some knowledge of quantum mechanics.
- I was as new to this as you are a week ago. With enough time, the idea will ‘click’. Trust me.
Remember Dictionaries?
When was the last time you used a dictionary? Not an online one (I’m looking at you Google Translate), but a printed, physical dictionary. It’s been a while, hasn’t it?
There’s a good reason why we moved on from them too: they’re too time consuming. I could spend an entire French class desperately flipping through the pages just to find one word.
And this is the time it takes to search through structured data — sorted according to a meaningful metric, in this case alphabetically.
The last step is to increase the amplitude of |w〉. We can do this by applying another reflection. This second reflection is called the diffuser operator, and performs the reflection 2|s〉〈s|- 1.
This expression can be visualized, making it much easier to understand its function. Below, the diffuser is Us.
Here’s what the amplitude implications of the reflection are.
Awesome. We now have a state where |w〉 is amplified. But how do we make sure that we measure |w〉 most of the time, so that the amount of times |w〉 is measured is significantly larger than the other processes?
Simple. Repeat steps 2 and 3. Each time they’re repeated, they push the new state closer and closer to the winning state |w〉 on the vertical axis.
We need to repeat this process around √N times to get an accurate result.
Back to the Code
We’ve created the initial superposition state as well as the oracle, but we are yet to create the diffuser.
As a recap, the first Hadamard’s are the initialization and the CZ after the barrier is our oracle. We apply the H’s, Z’s, CZ, and the last pair of H’s as our diffuser, which accomplishes the reflection 2|s〉〈s|- 1 mentioned above.
This is what the completed circuit looks like. Notice we added measurements at the end, which will map the state of the qubits to classical bits.
Interestingly, this paper by Michael Nielsen and Isaac Chuang proved that only one run through is required to produce an accurate result in this experiment, so there’s no need to repeat any of the reflections.
We need to make sure that this code functions correctly.
We run the code on a quantum simulator in Qiskit called QASM, which accounts for errors in computation on real quantum devices. The code returns the expected value |11〉, running only once. Looks like the algorithm works!
Let’s see it run on a real quantum computer!
The other outputs we get are the products of errors in quantum computation.
This proves the fact that quantum computation can take as little as O(√N), which is a drastic speed up compared to classical methods, as shown in the graph.
3 Qubits For Me
The algorithm is run much the same on 3 qubits.
We’ll look for 2 solutions where length of list N is 8. This is also one of the problems where the paper showed only one run-through of the algorithm was necessary to obtain an accurate measurement.
On the quantum sim, we only get states |101〉 and |110〉, which were the states we were looking for. Let’s test it out on a real quantum computer.
Once again, the other values that appear in our probabilities are errors in the quantum computation.
Key Takeaways:
- Grover’s algorithm takes the search of unstructured data from O(N) time to O(√N) time
- It uses Amplitude Amplification, which can be visualized as rotations
- It is programmable on Qiskit using basic quantum gates
Applications of Grover’s Algorithm:
- Data mining: Grover’s algorithm can be used to find patterns in large datasets that would be impossible to find with a classical computer. For example, it could be used to find fraudulent transactions in a financial database or to identify cancer cells in a medical image.
- Cryptography: Grover’s algorithm can be used to break cryptographic keys that are currently considered secure. This could have a major impact on the security of online communications and transactions.
- Optimization: Grover’s algorithm can be used to solve optimization problems that are difficult or impossible to solve with a classical computer. For example, it could be used to find the shortest route between two points or to find the optimal investment portfolio..
Limitations of Grover’s Algorithm:
- Quadratic speedup: Grover’s algorithm gives a quadratic speedup compared to classical algorithms, which means that it can only provide a significant speedup for some problems that have a large search space. For problems with smaller search spaces, the speedup may not be good enough to justify the use of this algorithm.
- Limited by hardware: Grover’s algorithm requires the use of a large number of qubits to achieve a significant speedup, which is currently beyond the capabilities of most quantum hardware. This means that the algorithm may not be practical for many real-world applications until more powerful quantum hardware is developed.
- Limited to unstructured search: Grover’s algorithm is designed for unstructured search problems, which means that it may not be applicable to other types of problems such as optimization or simulation.
- Error-prone: Grover’s algorithm, like all quantum algorithms, is susceptible to errors due to noise and decoherence. These errors can affect the accuracy and reliability of the algorithm, which can limit its practical use in real-world applications.
- Limited applicability in cryptography: Although Grover’s algorithm can be used to break certain cryptographic algorithms, it is not applicable to all types of encryption. For example, public-key encryption is not vulnerable to Grover’s algorithm due to its use of mathematical problems that are not efficiently solvable by quantum computers.
Conclusion:
Overall, Grover’s algorithm is a powerful tool that can be used to solve a variety of problems. For example, it can be used to find patterns in data, break cryptographic keys, and solve optimization problems. As quantum computers become more powerful, Grover’s algorithm will become increasingly important.