- Fundamentals
- Also: H gate
Hadamard Gate
A single-qubit gate that creates an equal superposition of |0⟩ and |1⟩, one of the most fundamental operations in quantum computing.
The Hadamard gate is the most commonly used single-qubit gate in quantum computing. Its job is to create superposition: it takes a qubit with a definite value and puts it into an equal superposition of and . This is the starting point for almost every quantum algorithm. Without a way to create superposition efficiently, quantum computers would be limited to classical computation.
The Hadamard also has an elegant self-inverting property: applying it twice returns you to where you started. This symmetry makes it easy to undo and reuse in circuit design.
The details
The Hadamard gate acts on the computational basis states as:
The matrix representation is:
This is a unitary matrix: . Since (Hadamard is its own Hermitian conjugate), this also means : applying Hadamard twice returns the original state.
On the Bloch sphere, the Hadamard gate is a rotation around the diagonal axis halfway between X and Z. It maps:
- (north pole) to (equator, positive X)
- (south pole) to (equator, negative X)
- back to
- back to
Applying Hadamard to each qubit in an -qubit register simultaneously creates a uniform superposition over all basis states:
This step, taking one clock cycle regardless of , is used to initialize nearly every quantum algorithm.
from qiskit import QuantumCircuit
# Prepare uniform superposition over 3 qubits
qc = QuantumCircuit(3)
qc.h([0, 1, 2]) # Apply H to all qubits simultaneously
print(qc.draw())
# This creates (|000> + |001> + ... + |111>) / sqrt(8)
Why it matters for learners
The Hadamard gate appears in essentially every quantum circuit you will encounter. Understanding it well makes the rest of quantum computing much easier to follow.
It is the first gate applied in Grover’s algorithm to create the uniform superposition that the search exploits. It is the first and last gate in the diffusion operator step. It appears throughout the Quantum Fourier Transform circuit. Every Bell state preparation starts with a Hadamard. In quantum key distribution, the BB84 protocol uses the Hadamard basis as one of its two encoding bases.
The Hadamard gate also demonstrates an important principle: the difference between and is a relative phase of on the component. This phase difference is invisible in a single measurement (both give 50/50 outcomes) but becomes meaningful when subsequent gates use interference.
Common misconceptions
Misconception 1: The Hadamard gate gives you randomness. A qubit after Hadamard is in a definite quantum state, . The randomness appears only at measurement. Before measurement, the qubit is in a well-defined superposition, and subsequent gates can exploit the phase structure for interference. Using Hadamard just to get randomness ignores its quantum power.
Misconception 2: Hadamard puts the qubit in a 50/50 classical mixture. A classical mixture and a quantum superposition are physically different. A mixture has definite values that are unknown; a superposition genuinely has no definite value and can interfere. The Hadamard creates a superposition, not a mixture. After decoherence, a superposition becomes a mixture.
Misconception 3: H is the only way to create superposition. Any rotation that moves a qubit off the Z-axis creates superposition. The gate creates the same state. Hadamard is special because it also performs a phase transformation (swapping and ), which is exactly what makes it useful for interference-based algorithms.