Interactive Calculator · Algorithms and Advantage
Grover Search Calculator
See exactly how many Grover iterations you need, how success probability rises and falls, and when quantum search actually beats classical search.
Number of candidates N = 2 to the power of n qubits-worth of bits.
One iteration includes the full oracle circuit, so this is far lower than a gate rate.
Optimal iterations
804
≈ (π/4)√(N/M)
Success probability
100.00%
after 804 iterations
Classical checks (average)
524,289
(N + 1)/(M + 1)
Query speedup
652.1×
Classical checks ÷ Grover iterations
Wall-clock time
Classical: 524.3 µs
Quantum: 80.40 ms
At these rates the classical search finishes first, because quantum iterations are slow.
Success probability versus iterations
The probability oscillates. Stop at the first peak. Running too long rotates the state past the answer and success falls again.
Choose a search space size and the number of marked items, compute the optimal number of Grover iterations and success probability, compare with classical search, and compare wall-clock times at rates you set.
What this calculator does
Grover's algorithm searches an unstructured collection of N items for one that satisfies a test, using about the square root of N evaluations of the test instead of about N. It is the most famous quantum algorithm after Shor's, and the speedup is proven to be optimal for unstructured search. But the details are often misunderstood. The algorithm does not find the answer after any number of steps: success probability oscillates, and running too long makes things worse. Also, a square-root speedup in the number of queries does not automatically translate into a faster computer, because each quantum iteration is far slower than a classical check.
This calculator makes those points concrete. Set the size of the search space from 2 to 2 to the 128, set the number of marked items, and it computes the optimal iteration count, the success probability after any number of iterations, the expected classical effort, the query speedup, and the wall-clock time for each side given the speeds you choose. The chart shows the full oscillation so you can see the sweet spot and the overshoot.
How to use it
Start with the Database of 1 million preset. For N around a million and one marked item, the optimal number of iterations is 804, and the success probability at that point is above 99.99 percent. A classical search checks about 524,000 items on average, so the query speedup is about 650 times. Now look at the wall-clock panel. At one billion classical checks per second and ten thousand quantum iterations per second, the classical search takes half a millisecond and the quantum search takes 80 milliseconds. The classical computer wins by a large margin. That is not a flaw in the algorithm. It is the central point of the 2021 analysis by Babbush and coauthors, which showed that quadratic speedups pay off only when the classical computation is already very long.
Next, try the AES-128 key search preset. The search space is 2 to the 128, and the optimal count is about 1.4 times 10 to the 19 iterations. At ten thousand iterations per second that is about 46 million years, and since each iteration must evaluate AES inside a fault-tolerant circuit, ten thousand per second is generous. Grover's algorithm cannot be sped up by simply adding machines, because splitting the search across many devices reduces the speedup, as Zalka showed in 1999. This is why AES-128 is regarded as acceptably secure against quantum attacks.
Finally, uncheck the optimal option and use the iteration slider with the Overshoot demo preset. Success peaks near the optimal count and then falls, reaching nearly zero when the state has rotated past the marked items. When the number of marked items is unknown, the algorithm must be run with varied iteration counts, as in the method of Boyer, Brassard, Høyer, and Tapp.
Reading the result
The calculator treats Grover's algorithm as a rotation. The state starts almost perpendicular to the marked subspace, at a small angle θ with sin θ = √(M/N), and each iteration rotates it by 2θ toward the marked items. After k iterations the success probability is sin² of (2k + 1)θ. The best k brings the angle close to 90 degrees. Because the rotation is by a fixed amount, doing more than the optimal number of iterations starts to rotate the state back toward the unmarked items.
The speedup figure divides the expected classical checks by the Grover iterations. It is a ratio of queries, not of time, which is why the wall-clock panel exists. For real problems you should also include the cost of implementing the oracle, which usually costs many logical gates, and the overhead of error correction, which makes each logical gate much slower than a classical operation.
Assumptions and limits
The model assumes a perfect noiseless algorithm and an oracle that takes one iteration step each. It treats classical search as random sampling without replacement. In practice, many search problems have structure that classical algorithms exploit, so the true classical baseline can be far better than N/2. And real implementations suffer from errors that reduce success probability unless the machine is fault tolerant. Treat the results as the ideal-case benchmark against which more careful resource estimates should be compared.
The formulas behind it
Rotation angle
θ = arcsin √(M/N)
Initial angle between the uniform state and the marked subspace.
Success probability
P(k) = sin²((2k + 1)θ)
Probability of measuring a marked item after k Grover iterations.
Optimal iterations
k_opt ≈ round( π/(4θ) − 1/2 ) ≈ (π/4)√(N/M)
The first peak of P(k).
Classical expected checks
(N + 1)/(M + 1)
Expected number of random checks until a marked item is found, without replacement.
Query speedup
(N + 1)/((M + 1)·k_opt)
Ratio of classical checks to Grover iterations. Not the same as a time speedup.
Worked examples
One in a million
- N = 2²⁰ = 1,048,576 and M = 1.
- θ = arcsin(1/1024) = 0.000977, so k_opt = round(804.2 − 0.5) = 804.
- Classical average is about 524,288 checks, so the query speedup is about 652.
ResultAt 10⁹ checks per second classical and 10⁴ iterations per second quantum, classical takes 0.52 ms and quantum 80 ms.
Brute-forcing AES-128
- N = 2¹²⁸, M = 1, so k_opt ≈ 0.785 × 2⁶⁴ = 1.45 × 10¹⁹.
- At 10⁴ iterations per second the time is 1.45 × 10¹⁵ seconds.
ResultThat is about 46 million years, even with a generous iteration rate.
Many solutions
- N = 1024 and M = 256, so one quarter of items are marked.
- θ = arcsin(0.5) = 30°, so k_opt = round(π/(4 × 0.5236) − 0.5) = round(1.0) = 1.
ResultA single Grover iteration finds a marked item with probability 100 percent here.
Frequently asked questions
Why does success probability drop if I run more iterations?
Each iteration rotates the state by a fixed angle, and after passing the marked direction the state rotates away from it again.
Can Grover's algorithm speed up any search?
It speeds up unstructured search by a square root. If the problem has structure, a classical algorithm may already be faster than the Grover bound.
Does a square-root speedup make quantum search practical?
Only for problems where the classical search is extremely long, because quantum iterations are slow and error correction adds large overheads.
References
- Grover, L. K. (1996). A fast quantum mechanical algorithm for database search. Proceedings of the 28th Annual ACM Symposium on Theory of Computing, 212-219.
- Boyer, M., Brassard, G., Høyer, P., & Tapp, A. (1998). Tight bounds on quantum searching. Fortschritte der Physik, 46, 493-505.
- Bennett, C. H., Bernstein, E., Brassard, G., & Vazirani, U. (1997). Strengths and weaknesses of quantum computing. SIAM Journal on Computing, 26, 1510-1523.
- Zalka, C. (1999). Grover's quantum searching algorithm is optimal. Physical Review A, 60, 2746-2751.
- Babbush, R., et al. (2021). Focus beyond quadratic speedups for error-corrected quantum advantage. PRX Quantum, 2, 010103.
- Jaques, S., Naehrig, M., Roetteler, M., & Virdia, F. (2020). Implementing Grover oracles for quantum key search on AES and LowMC. EUROCRYPT 2020, LNCS 12106, 280-310.
Keep exploring
- Paper: A Fast Quantum Mechanical Algorithm for Database Search
- Algorithm: Grover's Algorithm
- Myth: A quantum computer tries every possible answer at the same time
- Myth: Quantum computers will break all encryption, including AES and hashes
- Forecast: Quantum Advantage by 2030: What to Expect and What Not To
These calculators use simplified, published models for education and planning. Real devices and systems differ, so treat results as estimates. They are not engineering, investment, legal, or security advice.