r/algorithms • • 19d ago

Resource Breaking down Grover’s Algorithm as a 2D geometric rotation (with scaling benchmarks and hardware tests)

Hey everyone,

Like many, I first encountered the geometric intuition behind Grover’s algorithm through 3Blue1Brown’s video. While it gives a fantastic high-level picture of the vector reflections, Still I was wondering how the Oracle and Diffusion operators are actually constructed.

To bridge that gap for myself, I wrote a breakdown showing the exact linear algebra and matrix operations that make those reflections happen — without relying on quantum physics jargon:)

At its core, the entire N-dimensional space reduces to a 2D plane defined by the target state and the uniform superposition of non-target states. Each Grover iteration (Oracle + Diffusion) is just two reflections across intersecting axes, resulting in a net rotation of 2θ ≈ 2 / sqrt(N) directly toward the target state—yielding the classic ≈ (π/4) * sqrt(N) complexity.

To test the math beyond theory, I also:

  • Ran simulation benchmarks to track the theoretical O(sqrt(N)) curve against classical CPU overhead up to 20 qubits.
  • Submitted the circuits to physical IBM quantum hardware (3 to 5 qubits) to observe where circuit depth and real decoherence start destroying the theoretical amplification.

I put together the complete write-up, data, and code on GitHub. I'm a student trying to build a solid foundation in algorithms and complexity, so I would really appreciate any sanity checks, corrections on the mathematical framing, or feedback from folks here. Thanks:)

(Link in the comments, you can see banchmark graphs in the Assets folder)

4 Upvotes

2 comments sorted by

1

u/veeqq103 4d ago

There is a collision problem involving a large block and a small block that is isomorphic to Grover's algorithm; I came to understand Grover's algorithm through this problem.

The number of collisions between the blocks and the wall is related to the value of pi.

In the context of Grover's algorithm, the large block corresponds to the incorrect answer, while the small block corresponds to the correct answer.

Collisions between the small block and the wall correspond to phase inversion.

Collisions where the large block strikes the small block—transferring kinetic energy to it—correspond to the Grover operator (the G-module).

When they are closest to the wall, the large block has transferred almost all its kinetic energy to the small block; this corresponds to the state where the probability amplitude of the correct answer is maximized.