Grover's Algorithm with PennyLane
Overview
Grover's Algorithm with PennyLane
This PennyLane demo implements Grover's algorithm, the canonical quantum search routine that finds a marked item in an unstructured space of N possibilities using only about sqrt(N) oracle queries, a quadratic speedup over the O(N) any classical search requires. The tutorial builds the algorithm from its components using PennyLane's circuit primitives: preparing a uniform superposition over all candidates with Hadamard gates, applying an oracle that flips the phase of the marked state, and applying the Grover diffusion (amplitude-amplification) operator that reflects the state about its mean to boost the marked amplitude. It shows how to repeat the oracle-plus-diffusion step the optimal number of times and how the success probability evolves with the number of iterations, then measures the register to recover the marked item. PennyLane's built-in GroverOperator makes the diffusion step concise, and the demo visualizes how the amplitude concentrates on the solution. Because amplitude amplification underlies many quantum speedups, it is a foundational example for understanding how interference is engineered to surface a desired answer, presented with PennyLane.
Run it
pip install -r requirements.txt
python demo.py
Source and license
Imported from demonstrations_v2/tutorial_grovers_algorithm/demo.py in PennyLaneAI/demos at c52c0abeb5122218aa96b38eea848864cce7323f, under the Apache License 2.0. Original authors: Xanadu and the PennyLane community. The upstream LICENSE is included alongside this example.
This entry was created automatically from publicly available records. QCR links to public sources and only stores repository content where the license permits redistribution.
Publication
doi:10.48550/arxiv.quant-ph/9605043Lov K. Grover
Versions
Cite all versions? Use the base QCR ID to always reference the latest version of this entry.
Join the Discussion
Comments (0)
No comments yet. Be the first to share your thoughts!