Web Simulation 

 

 

 

 

Grover's Search Algorithm Simulation 

This note provides an interactive, visual simulation of Grover's Algorithm, a quantum search algorithm that demonstrates "Amplitude Amplification." Grover's Algorithm can find a unique item in an unsorted database of N items using approximately √N queries, which is quadratically faster than the classical O(N) brute-force search.

The simulation visualizes how quantum amplitudes evolve through two key operations: the Oracle (which marks the target state by flipping its phase) and the Diffuser (which amplifies the target amplitude through "Inversion about the Mean"). The algorithm starts with all states in equal superposition (each with amplitude 1/√N), then iteratively amplifies the target state's probability until it becomes highly likely to measure.

Understanding the Oracle (The "Lock and Keys" Analogy): A common confusion is: "If the Oracle can flip the target, doesn't it already know where it is?" The answer is no—the Oracle is like a lock that can test keys, not a cheat sheet. The Oracle is a verification function that processes all states simultaneously in quantum superposition. It doesn't search—it mechanically checks each state and flips the phase of the one that matches. You still don't know which one was flipped until the Diffuser amplifies it enough to be visible. The simulation uses "Blind Mode" to demonstrate this: initially, all bars look identical (blue), and the target is only revealed after the Diffuser amplifies it (turning it bright green).

The visualization shows two charts: an Amplitude Chart (where bars can be positive or negative, representing quantum amplitudes) and a Probability Chart (showing |amplitude|², which is what you would actually measure). The orange dashed line in the amplitude chart represents the current mean amplitude, which is crucial for understanding the "Inversion about the Mean" operation.

NOTE : The simulation uses N = 16 states (4 qubits) for visualization clarity. The optimal number of iterations is approximately π/4 · √N ≈ 3 iterations. If you continue iterating beyond this point, the target probability will start decreasing—this is called "over-rotation" and demonstrates the importance of stopping at the optimal point. The simulation starts in "Blind Mode" where the target is not highlighted—watch how the Oracle's scan marks it (orange when negative) and the Diffuser reveals it (bright green when amplified).

Math behind the Simulation

Grover's Algorithm operates on a quantum state |ψ⟩ = Σᵢ αᵢ|i⟩, where αᵢ are the amplitudes and |i⟩ are the basis states. The algorithm consists of two operations applied iteratively:

1. Oracle (Phase Flip):

O|i⟩ = -|i⟩ if i is the target, else O|i⟩ = |i⟩

The Oracle is a verification function, not a search function. It processes all states simultaneously in quantum superposition. For each state |i⟩, it checks if it matches the target (like a lock testing a key). If it matches, it flips the phase (multiplying the amplitude by -1). This is equivalent to: α_target → -α_target. The Oracle doesn't "know" where the target is—it's a mechanical circuit that processes all states at once. In the simulation, you'll see a scan/pulse effect that hits all bars simultaneously, and only the target bar flips to negative phase (shown in orange).

How the Oracle Circuit Works (Circuit Visualization):

The circuit visualization panel shows how the Oracle is physically constructed based on the target's binary representation. For a 4-qubit system (16 states), the target is represented as a 4-bit binary number. For example, target 13 is `1101` in binary.

The Oracle circuit consists of three parts:

  1. X-Gates (Before MCZ): For each bit in the target that is `0`, an X-gate (quantum NOT) is placed on that qubit line. This "aligns" the target pattern to `1111` so the multi-controlled gate can trigger. For `1101`, an X-gate is placed on qubit 1 (the second bit from the right).
  2. MCZ Gate (Multi-Controlled Z): A phase-flip gate that activates only when all control qubits are `1`. Because of the X-gates, this effectively triggers for the original target pattern.
  3. X-Gates (After MCZ): Matching X-gates restore the qubits to their original state (quantum circuits must be reversible).

Key Insight: "Defining the search target" is physically equivalent to "configuring the X-gates" on the circuit. When you change the target in the dropdown, watch how the X-gates move to different qubit lines based on which bits are `0` in the new target's binary representation. This proves that the Oracle circuit IS the target—it's not searching for it, it's configured to recognize it.

2. Diffuser (Inversion about the Mean):

The diffuser reflects all amplitudes across their mean value. If the mean amplitude is A_avg = (1/N) Σᵢ αᵢ, then each amplitude is updated as:

αᵢ → 2 · A_avg - αᵢ

This geometric operation amplifies amplitudes that are above the mean and reduces amplitudes that are below the mean. After the oracle flips the target's phase (making it negative), the diffuser reflects it across the mean, causing it to become much larger than the other amplitudes.

Visualizing the Formula: During the Diffuser step, the simulation shows an algebraic construction to make the formula concrete:

  • A cyan "2 * Mean (2a)" line appears above the mean, representing the "2a" term in the formula
  • For the target bar, a cyan vertical line extends from the 2a line down to the destination, labeled "- (Old Amp)" in red
  • This visualizes: New = 2a - Old
  • Since the old amplitude is negative, subtracting it is equivalent to adding its magnitude: New = 2a - (negative) = 2a + |negative|
  • This is why the target bar shoots up so high—it's starting from 2a and adding the magnitude of the negative old amplitude!
  • Additionally, a white ghost track shows the full path from start to destination, with an orange pivot point on the mean line, proving symmetric reflection

The Diffuser Circuit (Fixed, Generic Amplifier):

Unlike the Oracle (which changes based on the target), the Diffuser is a fixed circuit that never changes. It's like an "optical lens" that converts the Oracle's phase flip into a measurable probability spike. The Diffuser circuit is a "Hadamard Sandwich" with the following structure:

  1. H-Layer (Un-mix): Apply Hadamard gates to all qubits, taking the system out of the "superposition of numbers" basis
  2. X-Layer (Invert): Apply X gates to all qubits, turning |0000⟩ into |1111⟩
  3. MCZ Gate (Phase Shift): Multi-Controlled Z gate that flips the phase of the |1111⟩ state
  4. X-Layer (Re-Invert): Apply X gates again to undo step 2
  5. H-Layer (Re-mix): Apply Hadamard gates again to return to the original basis

This sequence performs the mathematical operation of reflecting the state vector across the "Equal Superposition" vector. Because the Oracle just flipped the target bar down (making it negative), the target is now far from the average. When the Diffuser flips it around the average, it ends up pointing way up (high positive amplitude).

Key Insight: The Oracle is the "Lock" (you build it for each specific problem). The Diffuser is the "Key Turner" (a generic tool you use with any Oracle). The Diffuser circuit never changes—it's always the same H-X-MCZ-X-H sequence, regardless of what you're searching for.

Optimal Number of Iterations:

The optimal number of Grover iterations is approximately ⌊π/4 · √N⌋. For N = 16, this is 3 iterations. After this point, continuing to iterate will cause the target probability to decrease (over-rotation). The algorithm achieves a success probability of nearly 100% at the optimal point.

Quantum Speedup:

Classically, finding a unique item in an unsorted database requires O(N) queries in the worst case. Grover's Algorithm achieves O(√N) queries, providing a quadratic speedup. While this is not exponential (like Shor's algorithm), it is still significant for large databases and demonstrates the power of quantum amplitude amplification.

 

Usage Example

Follow these steps to explore Grover's Algorithm and amplitude amplification:

  1. Initial State (Blind Mode): When you first load the simulation, all 16 states start in equal superposition. Each state has an amplitude of 1/√16 = 0.25, meaning each state has an equal probability of 6.25% (0.25²). Notice that all bars look identical (blue)—the target is not highlighted yet. This is "Blind Mode": you've secretly set a target (via the dropdown), but visually, you can't tell which one it is. This demonstrates that the algorithm doesn't cheat by knowing the answer upfront.
  2. Step 1: Apply Oracle (The "Lock Testing Keys"): Click the "Step 1: Apply Oracle" button. Watch what happens:
    • You'll see a scan/pulse effect that sweeps across all bars simultaneously—this represents the Oracle processing all states in superposition
    • One bar (the target) flips from pointing UP to pointing DOWN (its amplitude becomes negative)
    • The target bar turns orange when it's negative—this is the "mark" from the Oracle
    • Watch the orange dashed "Mean" line appear and drop during the animation—this shows how the mean changes as the target flips negative
    • After Step 1 completes, the mean line is labeled "Mean (New Inversion Axis)"—this is the axis around which Step 2 will reflect all amplitudes
    • The probability chart shows that the target still has the same probability (6.25%) because probability = amplitude², and (-0.25)² = 0.25²
    • Key Insight: The Oracle is like a lock—it can test all keys simultaneously, but you still don't know which key worked until the next step reveals it. Notice how the mean drops because one amplitude became negative—this sets up the geometry for the next step.
  3. Step 2: Apply Diffuser (The "Reveal"): Click the "Step 2: Apply Diffuser" button. This performs "Inversion about the Mean":
    • The mean line is now labeled "Reflection Axis (Mean)" and stays fixed during the animation (the mean is invariant under reflection)
    • A cyan "2 * Mean (2a)" line appears above the mean—this represents the algebraic ceiling: New = 2a - Old
    • For the target bar, you'll see:
      • A white ghost track showing the path from start to destination
      • An orange pivot point where the track crosses the mean line (proving symmetric reflection)
      • A cyan vertical line from the 2a line down to the destination, labeled "- (Old Amp)" in red
      • This visualizes the formula: New = 2 * Mean - Old
    • All bars "reflect" across the mean line: bars above the mean go down, bars below the mean go up
    • The target bar (which was negative/orange) shoots up dramatically because it was far below the mean. Since Old is negative, 2a - (negative) = 2a + |negative|, which is why it goes so high!
    • As the target bar becomes large and positive, it turns bright green—this is the "reveal"! Now you can see which state is the target
    • All other bars shrink slightly because they were close to the mean
    • Check the probability chart - the target probability should now be around 30-40%!
    • Key Insight: The Diffuser uses constructive interference to amplify the marked (negative phase) item, making it stand out. The visualization shows the algebraic construction: starting from 2a and subtracting the old (negative) amplitude results in a large positive amplitude. This is how the algorithm "finds" the answer—not by searching, but by amplifying the distinction created by the Oracle.
  4. Complete a Full Iteration: A full Grover iteration consists of Oracle + Diffuser. Try clicking both steps in sequence:
    • After 1 iteration: Target probability ≈ 30-40%
    • After 2 iterations: Target probability ≈ 70-80%
    • After 3 iterations: Target probability ≈ 95-99% (optimal point!)
    • After 4+ iterations: Target probability starts decreasing (over-rotation)
  5. Use Auto-Run: Click the "Auto-Run" button to watch the algorithm run automatically. It will apply Oracle, then Diffuser, repeatedly until reaching the optimal number of iterations (3 for N=16). Watch how the target amplitude grows with each iteration, and notice the warning message when over-rotation occurs.
  6. Try Lock Cracker Mode (Function Inversion): Switch the Mode dropdown to "Lock Cracker (Function Inversion)". This demonstrates a real-world scenario where the Oracle evaluates a function rather than checking a specific number:
    • The equation is: (x + shift) % 8 = targetResult
    • Adjust the shift and targetResult values to see how the answer changes
    • Watch the circuit visualization—instead of X-gates, you'll see math operation boxes: Adder (+shift), Modulo (% 8), Comparator (= targetResult), and Phase Flip (MCZ)
    • Key Insight: The Oracle circuit is built from the equation parameters (shift and targetResult), NOT from the answer. This proves the Oracle isn't "cheating"—it's a function evaluation circuit that finds which input satisfies the equation. The quantum computer discovers the answer by testing all inputs simultaneously.
  7. Change the Target: In Simple Search mode, use the "Target State" dropdown to select a different state as the target. Click "Reset" to start fresh, then run the algorithm again. The algorithm works the same way regardless of which state is the target - this demonstrates that Grover's Algorithm doesn't need to know where the target is, it just needs an oracle that can recognize it.
  8. Observe the Geometric Interpretation: The key insight of Grover's Algorithm is geometric:
    • The Oracle flips the target's phase (rotates it 180° in the amplitude space)
    • The Diffuser reflects all amplitudes across the mean (like a mirror)
    • Together, these operations rotate the state vector toward the target
    • After √N iterations, the state vector points almost directly at the target
  9. Compare Amplitude vs Probability: Pay attention to both charts:
    • Amplitude Chart: Shows quantum amplitudes (can be positive or negative). The orange dashed line shows the mean amplitude, which is crucial for the diffuser operation.
    • Probability Chart: Shows |amplitude|² (always positive). This is what you would measure in a real quantum computer. Notice that even when the target amplitude is negative (after Oracle), its probability is still positive.
  10. Understand Over-Rotation: Continue clicking "Step 2: Apply Diffuser" beyond 3 iterations. You'll see a warning message and notice that the target probability starts decreasing. This demonstrates that Grover's Algorithm has an optimal stopping point - too many iterations actually make the result worse!

Tip: The key insight of Grover's Algorithm is the geometric interpretation: the Oracle and Diffuser work together like a rotation in quantum state space. The Oracle marks the target by flipping its phase, and the Diffuser amplifies it by reflecting all amplitudes across the mean. Watch the orange dashed mean line carefully - understanding where it is helps explain why the diffuser amplifies the target. The algorithm achieves nearly 100% success probability after √N iterations, but continuing beyond this point causes over-rotation and decreases the success probability. This is why the optimal number of iterations is approximately π/4 · √N.

Parameters

Followings are short descriptions on each parameters
  • Number of States (N): The simulation uses N = 16 states, which corresponds to 4 qubits (2⁴ = 16). This provides a good balance between visualization clarity and demonstrating the algorithm's behavior. Each state represents one possible item in the unsorted database. The algorithm's performance scales as O(√N), so doubling the number of states roughly doubles the number of iterations needed.
  • Initial Superposition: All states start in equal superposition, meaning each state has an amplitude of 1/√N = 1/4 = 0.25. This gives each state an equal probability of 1/N = 6.25%. This uniform superposition is created by applying Hadamard gates to all qubits in a real quantum computer, but in this simulation it's the starting state.
  • Mode: The simulation offers two modes:
    • Simple Search (Find Number): The classic Grover's Algorithm example. You select a target state (0-15), and the Oracle circuit uses X-gates to mark that specific binary pattern. This mode demonstrates the basic algorithm but can feel "circular" (if the circuit knows the target, why search?).
    • Lock Cracker (Function Inversion): A real-world scenario that solves the circular logic problem. Instead of searching for a number, you're solving an equation: (x + shift) % 8 = targetResult. The Oracle circuit shows mathematical operations (adder, modulo, comparator) rather than X-gates. This proves the Oracle is built from the equation, not the answer—demonstrating true function inversion.
  • Target State (Simple Search Mode): In Simple Search mode, you can select any state from 0 to 15 using the dropdown menu. The algorithm doesn't need to know which state is the target - it only needs an Oracle (verification function) that can recognize it. The target is marked by the Oracle operation through a phase flip. Initially, the target is not visually highlighted (Blind Mode) - all bars look identical. After the Oracle marks it (orange when negative) and the Diffuser amplifies it (bright green when large), the target becomes visible. When you change the target, the circuit visualization updates automatically to show how the Oracle circuit is configured for that specific binary pattern.
  • Lock Cracker Parameters (Function Inversion Mode): In Lock Cracker mode, you set up an equation rather than selecting a target:
    • Shift: The value added to x in the equation (x + shift) % 8 = targetResult. Range: 0-7.
    • Target Result: The desired result of the equation. Range: 0-7.
    • Calculated Answer: The simulation automatically calculates which state (0-7) satisfies the equation. This is the "answer" that Grover's Algorithm will find.
    As you change shift or targetResult, watch how the circuit visualization updates to show the new mathematical operations, and the calculated answer changes. This demonstrates that the Oracle is built from the equation parameters, not the answer.
  • Optimal Iterations: The optimal number of Grover iterations is approximately ⌊π/4 · √N⌋. For N = 16, this is ⌊π/4 · 4⌋ = ⌊3.14⌋ = 3 iterations. After 3 iterations, the target probability reaches nearly 100%. Continuing beyond this point causes "over-rotation," where the target probability decreases.
  • Amplitude vs Probability: Quantum amplitudes can be positive or negative, but probabilities (which are what you measure) are always positive and equal to amplitude². This is why the amplitude chart shows bars going up and down, while the probability chart only shows positive values. Negative amplitudes are crucial for quantum interference effects.
  • Mean Amplitude: The mean (average) amplitude is calculated as A_avg = (1/N) Σᵢ αᵢ, where αᵢ are the individual amplitudes. This mean is visualized as an orange dashed line in the amplitude chart. The mean line appears during the Oracle animation (so you can see it drop as the target flips negative) and stays visible afterward. During the Diffuser step, the mean line is locked to its starting value (it's invariant under reflection) and is labeled "Reflection Axis (Mean)". The Diffuser operation reflects all amplitudes across this mean line using the formula: New = 2 * Mean - Old. A cyan "2 * Mean (2a)" line appears during Diffuser to show the algebraic construction. For the target bar, a red "- (Old Amp)" label shows the subtraction operation visually.

Buttons and Controls

Followings are short descriptions on each control
  • Reset: Resets the simulation to the initial equal superposition state. All amplitudes return to 1/√N = 0.25, the iteration counter resets to 0, and any auto-run is stopped. This allows you to start fresh and observe the algorithm from the beginning.
  • Step 1: Apply Oracle: Applies the Oracle operation, which is a verification function that processes all states simultaneously in quantum superposition. It marks the target state by flipping its phase (multiplying its amplitude by -1). This is the first step of each Grover iteration. The animation shows a scan/pulse effect that sweeps across all bars, and the target bar flips from positive to negative (turning orange). The Oracle doesn't "know" where the target is—it's a mechanical circuit that processes all states at once, like a lock testing all keys simultaneously. The mean line shifts slightly downward because one amplitude is now negative.
  • Step 2: Apply Diffuser: Applies the Diffuser operation, which performs "Inversion about the Mean." This is the second step of each Grover iteration. The animation first shows the mean line (orange dashed), then animates all bars reflecting across it. The target bar (which was negative/orange) shoots up dramatically and turns bright green when it becomes large—this is the "reveal" that makes the target visible. Other bars shrink slightly. This step increments the iteration counter and reveals which state is the target (if it's been amplified enough).
  • Auto-Run: Automatically runs the complete Grover algorithm by repeatedly applying Oracle and Diffuser operations. The button text changes to "Stop" while running. The algorithm runs until reaching the optimal number of iterations (3 for N=16), then automatically stops. You can also click "Stop" manually to pause at any point.
  • Target State: A dropdown menu that lets you select which state (0-15) is the target. Changing the target and clicking Reset allows you to see that the algorithm works identically regardless of which state is the target - demonstrating that Grover's Algorithm doesn't need to know where the target is, only that an oracle can recognize it.

Interaction and Visualization

  • Amplitude Chart (Top Canvas): The main visualization shows 16 vertical bars representing the quantum amplitudes of each state:
    • Blue Bars: All states initially (Blind Mode), and non-target states throughout. Positive amplitude (pointing up).
    • Dark Blue Bars: Non-target states with negative amplitude (pointing down)
    • Orange Bars: Target state after Oracle marks it (negative phase). This is the "mark" from the Oracle—the target is tagged but not yet revealed.
    • Bright Green Bars: Target state after Diffuser amplifies it (positive and large). This is the "reveal"—now you can see which state is the target!
    • Dark Green Bars: Target state when revealed but negative (rare, during transitions)
    • Gray Line: Zero line (center of chart) - bars above are positive, bars below are negative
    • Orange Dashed Line: Mean amplitude line - crucial for understanding the Diffuser operation. This line appears during the Oracle animation (so you can see it drop as the target flips negative) and stays visible afterward. During the Diffuser step, it's labeled "Reflection Axis (Mean)" and stays fixed (the mean is invariant under reflection). After Step 1, it's labeled "Mean (New Inversion Axis)" to indicate it's the axis for the next reflection.
    • Cyan Dashed Line "2 * Mean (2a)": Appears during the Diffuser step to show the algebraic ceiling. This represents the "2a" term in the formula: New = 2 * Mean - Old. It helps visualize why the target bar shoots up so high when the old amplitude is negative.
    • Reflection Visualization (Target Bar During Diffuser): When the Diffuser is applied, the target bar shows a detailed geometric construction:
      • White Ghost Track: A dotted white line showing the path from the bar's starting position to its destination
      • Orange Pivot Point: A dot on the mean line where the ghost track crosses, proving symmetric reflection
      • Cyan Construction Line: A vertical cyan line from the "2a" line down to the destination, showing the algebraic measurement
      • Red Label "- (Old Amp)": Text showing the subtraction operation in the formula New = 2a - Old
      This visualization makes the algebraic formula concrete: starting from 2a and subtracting the old (negative) amplitude results in a large positive amplitude.
    • Y-axis: Represents amplitude values from -1.0 (bottom) to +1.0 (top)
    • State Labels: Numbers 0-15 below each bar identify the state
  • Probability Chart (Bottom Canvas): Shows the measurement probabilities for each state:
    • Green Bars: Non-target states (probability = amplitude²)
    • Red Bars: Target state (probability = amplitude²)
    • Y-axis: Represents probability from 0% (bottom) to 100% (top)
    • Percentage Labels: Shows probability percentage for bars with probability > 5%

    Note: The probability chart always shows positive values because probability = |amplitude|². Even when the target amplitude is negative (after Oracle), its probability is still positive. This is why you can see the target probability increase even when its amplitude is negative.

  • Smooth Animations: All state transitions are animated smoothly using cubic easing functions. When you click "Step 1: Apply Oracle" or "Step 2: Apply Diffuser," the bars animate from their current values to their new values over 800ms. This makes it easy to follow how amplitudes change during each operation.
  • Info Display: The control panel shows real-time information:
    • Iterations: Current number of Grover iterations (Oracle + Diffuser = 1 iteration)
    • Optimal Iterations: The recommended number of iterations (⌊π/4 · √N⌋ = 3 for N=16)
    • Target Probability: Current probability of measuring the target state (updated in real-time)
    • Warning Message: Appears in red when iterations exceed the optimal number, indicating over-rotation
  • Geometric Interpretation: The visualization emphasizes the geometric nature of Grover's Algorithm:
    • Oracle: Rotates the target state by 180° (phase flip) in the amplitude space
    • Diffuser: Reflects all amplitudes across the mean line (like a mirror)
    • Combined Effect: These operations rotate the state vector toward the target
    • Optimal Point: After √N iterations, the state vector points almost directly at the target
    • Over-Rotation: Continuing beyond the optimal point rotates past the target, decreasing probability
  • Quantum Speedup: The simulation demonstrates why Grover's Algorithm is faster than classical search:
    • Classical Search: Requires O(N) queries in the worst case (checking each item one by one)
    • Grover's Algorithm: Requires O(√N) queries (only 3 iterations for N=16)
    • Quadratic Speedup: For large N, this is a significant improvement (e.g., for N=1,000,000, classical needs 1,000,000 queries, Grover needs ~1,000)
    • Amplitude Amplification: The algorithm doesn't search randomly - it systematically amplifies the target's probability through quantum interference
  • Probability Conservation: The total probability always sums to 1 (100%). As the target probability increases, the probabilities of all other states decrease proportionally. You can verify this by checking that the sum of all probabilities in the probability chart always equals 100% (within numerical precision).
  • Circuit Visualization: The bottom panel shows both the Oracle and Diffuser circuits side by side:
    • Oracle Circuit (Left, Problem-Specific):
      • Simple Search Mode:
        • 4 Qubit Lines: Horizontal lines representing qubits q₃ (top) to q₀ (bottom)
        • Binary Display: Shows the target's binary representation (e.g., 13 = `1101`)
        • X-Gates (Orange): Placed on qubit lines where the target bit is `0`. These "align" the pattern to `1111` before the MCZ gate
        • MCZ Gate (Blue): Multi-Controlled Z gate that flips phase when all controls are `1`
        • X-Gates (Restore): Matching X-gates after MCZ to restore reversibility
        • Dynamic Updates: When you change the target, the X-gates automatically move to the correct qubit lines based on the new binary pattern
      • Lock Cracker Mode (Function Inversion):
        • 3 Qubit Lines: Horizontal lines representing qubits q₂ (top) to q₀ (bottom) for 8 states (0-7)
        • Math Operation Boxes: Instead of X-gates, shows the actual function evaluation:
          • Adder Box: Adds the shift value to the input (x + shift)
          • Modulo Box: Computes modulo 8 ((x + shift) % 8)
          • Comparator Box: Checks if result equals targetResult
        • MCZ Gate (Blue): Multi-Controlled Z gate that flips phase when the comparator outputs `1`
        • Dynamic Updates: When you change shift or targetResult, the circuit updates to show the new equation parameters
        • Key Insight: This proves the Oracle is built from the equation, not the answer. The circuit evaluates the function for all inputs simultaneously, marking the one that satisfies the equation.
      • Highlighting: The Oracle block is highlighted (yellow glow) when "Step 1: Apply Oracle" is clicked
    • Diffuser Circuit (Right, Fixed/Generic):
      • H-Gates (Purple): Hadamard gates on all qubits (first and last layers)
      • X-Gates (Blue): X gates on all qubits (second and fourth layers)
      • MCZ Gate (Blue): Multi-Controlled Z gate in the center
      • Fixed Structure: The Diffuser circuit never changes—it's always H-X-MCZ-X-H, regardless of the target
      • Highlighting: The Diffuser block is highlighted (green glow) when "Step 2: Apply Diffuser" is clicked
      • Tooltip: Hover over the Diffuser section to see: "This circuit never changes. Its only job is to invert amplitudes around the mean, converting the Oracle's 'phase flip' into a measurable 'probability spike'."
    • Connecting Arrow: Shows the flow from Oracle → Diffuser

    The circuit visualization demonstrates the fundamental difference: The Oracle is programmable (changes with the target), while the Diffuser is hard-coded (always the same). The Oracle is the "Lock" you build for each problem; the Diffuser is the "Key Turner" you use with any Oracle. This proves that "defining the search target" is equivalent to "configuring the X-gates" on the Oracle circuit, while the Diffuser is a generic amplifier that works with any Oracle.