The science
Start in the uniform superposition |s> = N^(-1/2) sum_x |x>. One Grover iteration is the oracle (phase flip of marked items) followed by the diffusion operator.
oracle O|x> = -|x> if x is marked, else |x>
diffusion D = 2|s><s| - I (reflection about the mean amplitude)
theta = asin( sqrt(M/N) )
P_success(k) = sin^2( (2k+1) theta )
k_opt = round( pi/(4 theta) - 1/2 ) ~ (pi/4) sqrt(N/M)
Every iteration rotates the state by 2 theta in the plane spanned by the marked and unmarked uniform states. Stopping at k_opt gives the best probability; continuing rotates past the target and P falls again, which the graph shows.
Independent check: the page stores the full real amplitude vector and applies the oracle and the mean inversion element by element; the result at each k is compared with the closed form. Agreement to about 1e-14 confirms both. Simplifications: amplitudes stay real (no other phases arise in this algorithm), the oracle is an ideal black box, no noise or gate errors, and one oracle call is counted per iteration. The classical comparison (N+1)/(M+1) is the expected number of random probes without replacement until the first marked item. Marked positions are spread evenly; the result does not depend on where they are.