Quantum Computing Ultimate Simulation

Grover search on a simulated n-qubit register: quadratic speed-up over classical search
Start with all items equally likely (Hadamard on every qubit). Each Grover iteration = oracle (flip sign of marked items) + diffusion (reflect all amplitudes about their mean). The chance to find a marked item rises, peaks near pi/4 sqrt(N/M) iterations, then falls again - overshoot is real.
The science

The state vector of n qubits has N = 2^n amplitudes. Oracle: O|x> = -|x> if x is marked. Diffusion: D = 2|s><s| - I. In the plane spanned by the marked and unmarked uniform states, G = D O is a rotation by 2*theta with sin theta = sqrt(M/N), so after k iterations P(success) = sin^2((2k+1) theta). Optimal k = round(pi/(4 theta) - 1/2) ~ (pi/4) sqrt(N/M); a classical unstructured search needs ~N/2 oracle calls on average.

The simulation applies the full N-amplitude updates (real amplitudes suffice here) and the page compares the result with the closed form. Simplifications: noiseless ideal qubits; the oracle is a black box; the speed-up is quadratic, not exponential, and only for unstructured search. Measurement picks an item with probability = amplitude squared.