Quantum gates & circuits

The Hadamard gate

Use a change of basis to prepare superpositions and reveal phase.

20 minCore

Intuition

Hadamard exchanges two pairs of basis directions. It maps |0⟩ to |+⟩ and |1⟩ to |−⟩. Applying it again maps those superpositions back to their computational basis states.

The two intermediate states have identical computational-basis histograms. Their distinction is coherence: one has equal signs, and the other has opposite signs. Hadamard turns that sign into a basis label.

Learning objectives

  • Read the Hadamard matrix
  • Derive H² = I
  • Use Hadamard to read the X basis

Interactive exploration

Use the controls to change the state and see its calculated readout. You can return to this experiment as you work through the derivation.

Circuit composer

q0 = leftmost bit
q0HZH
  1. H q0
  2. Z q0
  3. H q0
Step 3 / 3

State at step 3

2 amplitudes
BasisAmplitudeProbability
|0⟩0.0000%
|1⟩1.000100%

Each shot independently prepares this step’s state. A dense simulator stores 2ⁿ complex amplitudes for n wires. The composer is capped at six wires.

Mathematical foundation

The columns are the images of the two computational basis states. Their squared norms are one and their inner product is zero.

H=12(111−1)H=\frac1{\sqrt2}\begin{pmatrix}1&1\\1&-1\end{pmatrix}

Multiplying the matrices gives diagonal entries (1+1)/2 and off-diagonal entries (1−1)/2. Thus H is its own inverse.

H2=12(2002)=IH^2=\tfrac12\begin{pmatrix}2&0\\0&2\end{pmatrix}=I

Worked example

Insert Z between two Hadamards. First the state moves to |+⟩, then Z changes the sign to |−⟩, and the final H converts it to |1⟩. This conjugation realizes X on all states.

HZH∣0⟩=H∣−⟩=∣1⟩,HZH=XHZH|0\rangle=H|{-}\rangle=|1\rangle,\qquad HZH=X

Guided experiment

Step through H–Z–H from |0⟩. Check the two middle rows of amplitudes and compare their identical probabilities.

Go to the controls
Compare with the expected result

The final Hadamard converts the middle sign difference into a deterministic output.

Understanding check

Circuit challenge

Prepare |+⟩ from |0⟩. Any circuit that creates the target state up to global phase is accepted.

    BasisAmplitudeProbability
    |0⟩1.000100%
    |1⟩0.0000%
    1. What is H|−⟩?
    2. What is P(1) after H–Z–H on |0⟩?

    Next steps

    Want to keep your results? Start your learning journey

    Open Circuit Composer