Simulated Quantum Computer Algorithm for Database Searching

This is a simulation of Grover's algorithm for searching a database for a single target address (secretly selected to be the qubit at n=7—pretend you don't know this!). Successive applications of quantum-computer operations called inversion and diffusion increase the amplitude of the target qubit. Reading the quantum register causes collapse of its wavefunction. The probability of each possible answer is then equal to the square of its amplitude. For a database of dimension N, the probability of locating the target is maximized after approximately π/4 iterations. Compare this with the 50% probability for success in a classical search after N/2 steps. Paradoxically, the quantum algorithm becomes worse with additional iterations (actually, the probability oscillates).


  • [Snapshot]
  • [Snapshot]
  • [Snapshot]


L. Grover, "Quantum Mechanics Helps in Searching for a Needle in a Haystack," Physical Review Letters, 79(2), 1997 pp. 325–328.
S. M. Blinder, Introduction to Quantum Mechanics in Chemistry, Materials Science, and Biology, Burlington, MA: Elsevier Academic Press, 2004 pp. 283–284.
    • Share:

Embed Interactive Demonstration New!

Just copy and paste this snippet of JavaScript code into your website or blog to put the live Demonstration on your site. More details »

Files require Wolfram CDF Player or Mathematica.