🔄 Before we begin — what is a quantum gate?
In a classical computer, gates like AND, OR, and NOT process bits. AND takes two inputs and gives one output — you cannot recover the inputs from the output. Classical gates are irreversible.

Quantum gates are fundamentally different. Every quantum gate is reversible — you can always undo it and recover the input. Mathematically, each gate is a rotation on the Bloch sphere. The X gate flips north to south (like NOT). The H gate rotates to the equator (creating superposition). The Z gate rotates around the vertical axis (changing phase).

This reversibility is not optional — it is forced by quantum mechanics. The Schrödinger equation is reversible, so every process a quantum computer performs must also be reversible.
🌀 Why reversibility matters so much
Reversibility enables quantum error correction — you can detect and fix errors without looking at the data (which would collapse it). It also means quantum computers conserve information in a way classical computers don't. Every bit that goes in comes out somewhere — nothing is lost.
⚡ Quantum Gates · Session 3 · Q7

Gate Builder

Apply quantum gates and watch the Bloch sphere rotate in real time. Build gate sequences, discover why every gate is reversible, and master the CNOT that creates entanglement.

🔄 Classical vs Quantum
🌐 Single-Qubit Gates
⛓️ CNOT Gate
🔧 Gate Sequences
🏆 Challenge
🔄

Reversibility

Every quantum gate has an inverse. X·X = I. H·H = I. This is required by quantum mechanics — information is never destroyed.

🌐

Bloch Rotations

Each gate rotates the qubit state vector on the Bloch sphere. X = 180° flip. H = 90° rotation to equator. Z = phase rotation.

⛓️

CNOT Gate

Two-qubit gate: flips target qubit if and only if control qubit is |1⟩. The key gate for creating entanglement between qubits.

🧮

Unitary Matrices

Each gate is a unitary matrix. Applying the gate = matrix multiplication. The circuit = product of all gate matrices.

Wizzy · Quantum Guide
Let's compare classical gates to quantum gates side by side. The key difference: classical gates can destroy information (AND: two inputs → one output, you can't recover inputs). Quantum gates never destroy information — they are reversible rotations.
🌀 Reversibility is a law, not a choice
The Schrödinger equation — the fundamental law governing quantum systems — is time-reversible. Running it backwards is just as valid as running it forwards. This forces every quantum gate to be reversible. There is no quantum AND gate that takes 2 inputs and gives 1 output.

Step 1 — Classical Gates vs Quantum Gates

❌ Classical NOT — Reversible
InOutReversible?
01
10
✅ Quantum X — Reversible
InOutX·X?
|0⟩|1⟩Back to |0⟩ ✅
|1⟩|0⟩Back to |1⟩ ✅
❌ Classical AND — Irreversible!
In AIn BOut
000
010
100
111
⚠️ If output is 0 — was input 00, 01, or 10? Lost forever!
✅ Quantum Toffoli (reversible AND)
ABC inC out
0000
1101
✅ A and B are preserved as outputs — fully reversible!
Key insight: Quantum computers can perform any classical computation (using Toffoli gates), but they also do much more. Every classical gate that destroys information has a reversible quantum equivalent that preserves it.
Wizzy · Quantum Guide
Click any gate button to apply it to the qubit. Watch the Bloch sphere arrow rotate — each gate is a specific rotation. Notice the probabilities update. Try applying the same gate twice — you'll always get back to where you started. That's reversibility in action!
🌀 The H gate is the most important gate in quantum computing
H (Hadamard) maps |0⟩ to (|0⟩+|1⟩)/√2 — perfect superposition. Without H, there is no superposition, no interference, and no quantum speedup. Almost every quantum algorithm starts with H gates on all qubits.

Step 2 — Single-Qubit Gates

|0⟩
P(0)=100% P(1)=0%
No gate applied yet
Try: Apply H → see superposition. Apply H again → back to |0⟩. Apply X → |1⟩. Apply X again → |0⟩. Every gate is its own inverse (for X, H, Z, Y) or has an inverse (S† for S).
Wizzy · Quantum Guide
The CNOT (Controlled-NOT) gate operates on two qubits. It flips the target qubit if and only if the control qubit is |1⟩. When the control qubit is in superposition, CNOT creates entanglement. This is how we got the Bell states in Q4!
🌀 Why superposition + CNOT = entanglement
If control = |+⟩ = (|0⟩+|1⟩)/√2 and target = |0⟩, CNOT gives (|00⟩+|11⟩)/√2 — a Bell state. The two qubits are now entangled. This is why CNOT is the single most important two-qubit gate in all of quantum computing.

Step 3 — CNOT Gate: Truth Table & Entanglement

CNOT truth table — click a row to simulate:
|00⟩
|00⟩
Control=|0⟩: target unchanged
|01⟩
|01⟩
Control=|0⟩: target unchanged
|10⟩
|11⟩
Control=|1⟩: target flipped
|11⟩
|10⟩
Control=|1⟩: target flipped
|+⟩|0⟩
(|00⟩+|11⟩)/√2
⭐ BELL STATE!
Click any row to see what happens. The last row is special — a superposition input creates entanglement!
Wizzy · Quantum Guide
Now build a sequence of gates! Click gates to add them to your circuit. The Bloch sphere shows the cumulative effect. Notice: order matters! H then X gives a different result than X then H. Try to discover the pattern.
🌀 Gates don't commute
In maths, 3×4 = 4×3 (multiplication commutes). But quantum gate matrices do not commute — HX ≠ XH. The order you apply gates changes the result. This non-commutativity is one reason quantum computing is fundamentally different from classical computing.

Step 4 — Gate Sequences

Click gates above to build a sequence...
|0⟩
P(0)=100% P(1)=0%
Circuit: (empty)
Build a sequence. Try H·H (back to |0⟩), or X·H·X and H·X·H (different results!).
Wizzy · Quantum Guide
🎯 Final challenge! A target state is shown. Use the gates to reach it in as few steps as possible. Each correct target hit scores points! This is how real quantum programmers think — finding the shortest gate sequence to reach a desired quantum state.

Challenge — Reach the Target State

Target state
|+⟩
Hint: one gate from |0⟩
Your state
|0⟩
Distance: 100%
Apply gates to reach the target state. Score increases as you get closer!
0
Score
0
Solved
0
Gates used
🧠 What you learned about gates
  • Quantum gates are reversible rotations on the Bloch sphere — unlike classical gates which can destroy information.
  • H gate creates superposition from |0⟩. X gate flips the qubit. Z gate changes phase. S and T apply partial phase rotations.
  • Applying the same gate twice usually returns to the start (X·X=I, H·H=I, Z·Z=I).
  • Gates don't commute — HX ≠ XH. Order matters in quantum circuits.
  • CNOT on a superposition control qubit creates entanglement — the foundation of quantum algorithms.

Gate Master Badge!

You mastered quantum gates — the building blocks of every quantum algorithm!

⚡ WhizzStep Quantum Lab
This certifies that
Student Name
has mastered Quantum Gates — X, H, Z, S, T, CNOT & Gate Sequences
Gate Master
Bloch Rotations
CNOT Expert
📖 Quantum Vocabulary
Unitary matrix NEW

A matrix U where U†U = I (its conjugate transpose times itself = identity). Every quantum gate is unitary — this ensures reversibility and probability conservation.

Pauli gates

X, Y, Z — the three fundamental single-qubit rotation gates. X flips |0⟩↔|1⟩. Z flips phase. Y does both. All are their own inverse.

Like 180° rotations around three perpendicular axes of the Bloch sphere.
Hadamard (H) KEY

Maps |0⟩→(|0⟩+|1⟩)/√2 and |1⟩→(|0⟩-|1⟩)/√2. Creates superposition. The most important single-qubit gate.

Like rotating the Bloch sphere's north pole to the equator.
CNOT NEW

Controlled-NOT: flips target qubit if control is |1⟩. With superposition control: creates entanglement.

Phase gate (S, T)

S = 90° phase rotation. T = 45°. These rotate around the Z axis by fractional amounts and are needed for universal quantum computation.

Universal gate set

A small set of gates from which any quantum computation can be built. {H, T, CNOT} is universal — any quantum circuit can be approximated using only these three gates.

Key Concepts from Q7

Reversibility

🔄 Never Lose Information

Every quantum gate is reversible. This follows from the unitary nature of quantum evolution. No information is ever destroyed in a quantum computation.

Non-commutativity

⚠️ Order Matters

Unlike multiplication (3×4 = 4×3), quantum gates don't commute. HX ≠ XH. This gives quantum circuits their computational power.

Universal set

🔧 {H, T, CNOT}

Just three gates — H, T, and CNOT — can approximate any quantum computation to any desired accuracy. This is quantum universality.

Circuit = Matrix

🧮 Pure Maths

A quantum circuit is the matrix product of its gates applied in sequence. The output state = (last gate) × ... × (first gate) × (input state).