quantum gatesquantum gates explainedhadamard gateCNOT gatequantum gate visualizationlearn quantum computingquantum gates tutorial

Quantum Gates Visualized — H, X, Y, Z, S, T, CNOT

Understand the most important quantum gates through visual Bloch sphere demonstrations. See the matrix, the physical effect, and apply each gate interactively.

June 9, 202611 min read

What is a Quantum Gate?

A quantum gate is the quantum analog of a classical logic gate — it transforms the state of one or more qubits. Unlike classical gates, quantum gates are reversible: every gate has an inverse operation.

Mathematically, a single-qubit gate is a 2×2 unitary matrix. Applying a gate multiplies the state vector by that matrix.

Single-Qubit Gates

Hadamard Gate (H)

H = (1/√2) [[1,  1],
             [1, -1]]

The Hadamard gate creates equal superposition from a basis state:

  • H|0⟩ = |+⟩ = (|0⟩ + |1⟩)/√2
  • H|1⟩ = |−⟩ = (|0⟩ − |1⟩)/√2

On the Bloch sphere, H rotates 180° around the diagonal between X and Z axes.

Before
H
After H

Pauli-X Gate (Quantum NOT)

X = [[0, 1],
     [1, 0]]

Flips |0⟩ ↔ |1⟩. On the Bloch sphere, it's a 180° rotation around the X axis.

Before
X
After X

Pauli-Y Gate

Y = [[0, -i],
     [i,  0]]

180° rotation around the Y axis. Includes a complex phase — Y|0⟩ = i|1⟩.

Pauli-Z Gate (Phase Flip)

Z = [[1,  0],
     [0, -1]]

Leaves |0⟩ unchanged, flips the phase of |1⟩. 180° rotation around Z axis.

Phase Gate (S)

S = [[1, 0],
     [0, i]]

90° rotation around Z. Transforms |+⟩ to |i⟩ (the +Y equator of the Bloch sphere).

T Gate (π/8 Gate)

T = [[1, 0],
     [0, e^(iπ/4)]]

45° rotation around Z. Essential for universal quantum computation — along with H and CNOT, it forms a universal gate set.

ℹ️
Note

Universal gate sets: H + T + CNOT can approximate any unitary operation to arbitrary precision. This is the quantum analog of the classical NAND gate's universality.

Multi-Qubit Gates

CNOT (Controlled-NOT)

CNOT = [[1,0,0,0],
        [0,1,0,0],
        [0,0,0,1],
        [0,0,1,0]]

Two-qubit gate: if the control qubit is |1⟩, flip the target qubit. Otherwise, do nothing.

Key property: CNOT + Hadamard creates entanglement (the Bell states).

Bell State creation:

H on qubit 0 → then CNOT(0→1)
(|00⟩ + |11⟩)/√2  — the Φ⁺ Bell state
💡
Tip

In the simulator: add a second qubit, press H on qubit 0, then click CNOT (Q0→Q1). Watch both purity bars drop — the qubits are now entangled.

CZ (Controlled-Z)

Applies a Z (phase flip) to the target qubit only when the control is |1⟩. Symmetric — it doesn't matter which qubit is control or target.

Quiz

Knowledge Check

Which gate applied to |+⟩ creates the |-⟩ state?

Knowledge Check

What makes CNOT + H capable of creating entanglement?

Try All Gates Live

Open the Bloch Sphere Simulator →

All gates (H, X, Y, Z, S, T) can be applied with keyboard shortcuts too — press the gate letter key!

Want to understand how data enters a quantum gate circuit? Read the Quantum Data Encoding Tutorial →

Continue Reading

What is a Qubit? A Visual Explanation

Understand qubits through interactive visualizations. Learn how a qubit differs from a classical bit, what superposition means physically, and how to think about quantum states intuitively.

The Bloch Sphere Explained — A Visual Guide

Master the Bloch sphere representation of a qubit. Understand polar angles θ and φ, the meaning of each axis, gate effects as rotations, and what purity means for multi-qubit systems.

Hadamard Gate & Superposition — From Intuition to Math

Master the Hadamard gate with visual intuition, matrix math, and interactive quizzes. Understand why superposition is not randomness and how phase matters in quantum computation.