What is the Hadamard gate?
The short answer
The Hadamard gate, written H, is a single-qubit quantum gate that turns |0⟩ into the equal superposition (|0⟩ + |1⟩)/√2 and |1⟩ into (|0⟩ − |1⟩)/√2. Its matrix is (1/√2)[[1, 1], [1, −1]]. Applying it twice returns the qubit to where it started, and on the Bloch sphere it is a half turn about the axis halfway between x and z. It is how almost every quantum algorithm creates superposition.
Learn this step by step in the Quantum Gates and Circuits course, in the free Q-Learn app. Get it on Google PlayGet Q-Learn
The matrix
Every single-qubit gate is a 2 × 2 matrix that acts on the qubit's two amplitudes. The Hadamard gate's is:
H = (1/√2) [ 1 1 ; 1 −1 ]
Read it column by column. The first column is what H does to |0⟩, the second what it does to |1⟩:
- H|0⟩ = (|0⟩ + |1⟩)/√2, a state usually written |+⟩.
- H|1⟩ = (|0⟩ − |1⟩)/√2, a state usually written |−⟩.
Both give 0 or 1 with probability 1/2 when measured. They differ only in the sign, the phase, of the |1⟩ part. The factor 1/√2 keeps the probabilities adding up to 1: (1/√2)² + (1/√2)² = 1.
H twice does nothing
Apply H to |+⟩ and the two paths to |1⟩ cancel while the two paths to |0⟩ add up, so you get |0⟩ back with certainty. In matrix terms, H × H is the identity: the Hadamard gate is its own inverse.
That cancellation is interference, and it is the reason the Hadamard gate is more than a coin toss. A random coin flipped twice is still random; a qubit sent through two Hadamard gates is not. See what is superposition? for why that matters.
On the Bloch sphere
On the Bloch sphere, the Hadamard gate is a 180° rotation about the axis pointing halfway between the x and z axes. It swaps the north pole |0⟩ with |+⟩ on the equator, and the south pole |1⟩ with |−⟩.
You can watch it happen: open the Bloch sphere simulator, press H, then press H again.
It swaps the X and Z bases
Sandwiching a gate between two Hadamards changes which axis it acts on:
- H X H = Z
- H Z H = X
So the Hadamard gate is how you switch between measuring in the usual |0⟩/|1⟩ basis and the |+⟩/|−⟩ basis. Protocols such as BB84 quantum key distribution rely on exactly this switch.
On many qubits at once
A Hadamard gate on each of n qubits, all starting at |0⟩, gives an equal superposition of all 2ⁿ possible bit strings. Three qubits give all eight strings from 000 to 111, each with amplitude 1/√8. This is the first step of most quantum algorithms, including Grover's search, Deutsch–Jozsa and Bernstein–Vazirani, and it is also the first step in making an entangled Bell pair.
Check it in Python
These lines build the Hadamard matrix with NumPy and apply it, once, twice, and to three qubits:
import numpy as np
H = np.array([[1, 1], [1, -1]]) / np.sqrt(2)
zero = np.array([1, 0])
one = np.array([0, 1])
# Adding 0.0 turns the -0.0 that rounding can leave into a plain 0.
print("H|0> =", np.round(H @ zero, 4) + 0.0)
print("H|1> =", np.round(H @ one, 4) + 0.0)
print("H H|0> =", np.round(H @ H @ zero, 4) + 0.0)
# Three Hadamards on three qubits: an equal superposition of all 8 states.
H3 = np.kron(np.kron(H, H), H)
amplitudes = H3 @ np.eye(8)[0]
print("H on 3 qubits:", np.round(amplitudes, 4))
print("each of the 8 outcomes has probability", round(float(amplitudes[0] ** 2), 4))
H|0> = [0.7071 0.7071] H|1> = [ 0.7071 -0.7071] H H|0> = [1. 0.] H on 3 qubits: [0.3536 0.3536 0.3536 0.3536 0.3536 0.3536 0.3536 0.3536] each of the 8 outcomes has probability 0.125
H|0⟩ gives two equal amplitudes of 0.7071 (that is 1/√2), H|1⟩ gives the same with a minus sign, H twice gives back |0⟩, and three Hadamards spread the qubits evenly over eight outcomes with probability 1/8 each. In Qiskit the same gate is written qc.h(0).
Where the name comes from
The gate is named after the French mathematician Jacques Hadamard, who studied the family of ±1 matrices it belongs to. The Hadamard transform was used in signal processing and coding theory long before quantum computing.
Frequently asked questions
Is the Hadamard gate a rotation?
Yes. On the Bloch sphere it is a 180° rotation about the axis halfway between x and z. Up to an overall phase, which has no effect on measurements, every single-qubit gate is a rotation of the sphere.
Why is the Hadamard gate important?
It is the standard way to put a qubit into an equal superposition and to take it back out again. Almost every quantum algorithm begins by applying it to every qubit, and it is needed to change measurement basis and to create entanglement.
Is the Hadamard gate reversible?
Yes, like every quantum gate. It is its own inverse: applying H twice returns the original state.