Chapter 4

Quantum Gates

Unitary operations on state vectors

Study X, Z, and H as ideal unitary operators on qubit states.

Turn static states into controlled transformations.

Available28 minCore

Learning objectives

  • Represent ideal single-qubit gates as 2x2 unitary matrices acting on state vectors.
  • Predict how X, Z, and H act on computational-basis states and general superpositions.
  • Explain why ideal circuit gates are unitary and distinguish them from noisy physical evolution.
In this lesson

Learning objectives

  • Represent ideal single-qubit gates as 2x2 unitary matrices acting on state vectors.
  • Predict how X, Z, and H act on computational-basis states and on general superpositions.
  • Explain why unitary circuit operations are reversible, and distinguish that model from noisy physical evolution.
  • Distinguish applying a gate from performing a measurement.

Alice returns to the forge

Alice returns to the instrument from Chapter 1, but this time the guide hands her a set of levers instead of a dial to read. Pulling a lever does not look at the state and report a number; in the ideal circuit model it maps each input state to a definite transformed state without producing a random outcome. The same input therefore gives the same output state each time. The guide calls these levers gates, and warns Alice not to confuse pulling a lever with taking a reading.

That warning is the point of this chapter. An ideal gate is an operator: a fixed rule for turning one state vector into another. It is deterministic and, unlike measurement, has an inverse. A laboratory implementation can still be noisy; Chapter 8 models that open-system behavior with quantum channels rather than pretending every physical process is a perfect unitary gate.

Gates are operators, not switches

A single-qubit gate is a 2x2 matrix U that acts on a state vector by matrix multiplication:

ψ=Uψ.|\psi'\rangle = U|\psi\rangle.

Because this is ordinary linear algebra, a gate is completely determined by what it does to the two computational-basis states |0⟩ and |1⟩. Once you know U|0⟩ and U|1⟩, linearity tells you U(α0+β1)=αU0+βU1U(\alpha|0\rangle+\beta|1\rangle) = \alpha U|0\rangle + \beta U|1\rangle for any amplitudes.

The Pauli X and Z gates

The Pauli-X gate is the quantum analogue of a classical NOT: it swaps the computational-basis states.

X=[0110],X0=1,X1=0.X = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}, \qquad X|0\rangle = |1\rangle, \qquad X|1\rangle = |0\rangle.

The Pauli-Z gate leaves |0⟩ unchanged and multiplies |1⟩ by -1:

Z=[1001],Z0=0,Z1=1.Z = \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix}, \qquad Z|0\rangle = |0\rangle, \qquad Z|1\rangle = -|1\rangle.

Z looks like it "does nothing of consequence" to a basis state, since -|1⟩ and |1⟩ give the same computational-basis probability. But Z's effect on a superposition is not cosmetic. Applying Z to +=(0+1)/2|+\rangle = (|0\rangle+|1\rangle)/\sqrt{2} gives

Z+=012=.Z|+\rangle = \frac{|0\rangle - |1\rangle}{\sqrt{2}} = |-\rangle.

+|+\rangle and |-\rangle give identical computational-basis probabilities, but they are different, distinguishable states: measuring in the X basis (introduced in Chapter 3) gives a deterministic "+" outcome for +|+\rangle and a deterministic "-" outcome for |-\rangle. Z turned one into the other. The relative phase that Chapter 2 warned you not to ignore is exactly what Z acts on.

Checkpoint

What is X|0⟩?

The Hadamard gate as a matrix

Chapter 2 introduced the Hadamard gate through its effect on outcomes. Its matrix form makes that effect precise:

H=12[1111],H0=+,H1=.H = \frac{1}{\sqrt{2}}\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}, \qquad H|0\rangle = |+\rangle, \qquad H|1\rangle = |-\rangle.

Applying H a second time undoes the first application: H+=0H|+\rangle = |0\rangle and H=1H|-\rangle = |1\rangle, so H2=IH^2 = I, the identity matrix. H is its own inverse.

State form

H|ψ⟩ = H(α|0⟩ + β|1⟩) = α|+⟩ + β|-⟩

Linearity lets you apply H term by term, then re-expand |+⟩ and |-⟩ back in the computational basis to read off new amplitudes.

A short one-qubit circuit
  1. 1

    Prepare |0⟩

  2. 2

    Apply X, giving |1⟩

  3. 3

    Apply H, giving |-⟩

  4. 4

    Measure in the computational basis: 50/50, but the pre-measurement state was |-⟩, not an arbitrary 50/50 state

Each step is a deterministic gate except the last, which is the one probabilistic measurement in the sequence.

Why ideal circuit gates are unitary

Not every matrix is a valid quantum gate. A matrix U is unitary if UU=IU^\dagger U = I, where UU^\dagger is the conjugate transpose of U. Unitary matrices preserve the length of a state vector, so a normalized input state stays normalized after the gate is applied — total probability remains one, as it must.

Unitarity condition

UU=IU^\dagger U = I

Every ideal single-qubit circuit gate satisfies this.

Unitarity also means every ideal gate has an inverse: U1=UU^{-1} = U^\dagger, and that inverse is itself unitary. This is why ideal gate sequences are reversible in a way measurement is not: their combined unitary has an inverse circuit. Noise, loss, reset, and measurement are more general physical operations and need not be reversible on the system being modeled.

Gates versus measurement

Applying a gate

  • In the ideal model, the same input state gives the same transformed output state.
  • Unitary and reversible; the inverse is another unitary.
  • Does not produce a classical outcome by itself.

Performing a measurement

  • Probabilistic: outcomes follow the Born rule.
  • Not reversible; the post-measurement state discards other information.
  • Produces one classical outcome in the chosen basis.

A circuit can freely mix many gates, but a measurement is a distinct kind of step with different rules.

Check your understanding

Why is an ideal circuit gate required to be unitary?

Reading a one-qubit circuit

A circuit diagram is read left to right as a sequence of gates applied to a starting state, usually |0⟩, ending in an optional measurement. Because gates are matrices, applying several gates in sequence corresponds to multiplying their matrices together in the matching order, right to left: the circuit "apply X, then H" corresponds to the single combined operator HX, and HX0HX|0\rangle gives the same result as applying X and then H one step at a time.

Common misconceptions

Check your understanding

What is Z|+⟩?

Summary

References and further study

Chapter exercises

Practice the ideas from this chapter with short interactive exercises.

Check your understandingfoundation

Gates versus measurement

Distinguish pulling a gate lever from taking a measurement.

Not started

A lever that never looks

The forge guide hands Alice a lever marked X. In the ideal circuit model, pulling it never reports a number; it maps each loaded state to a definite new state.

"This is not a reading," the guide says. "It is an operator. Watch what it does to the two basis states before you touch anything else."

X and Z on basis states

The Pauli-X gate swaps the computational-basis states:

X0=1,X1=0.X|0\rangle = |1\rangle, \qquad X|1\rangle = |0\rangle.

The Pauli-Z gate leaves 0|0\rangle alone and negates 1|1\rangle:

Z0=0,Z1=1.Z|0\rangle = |0\rangle, \qquad Z|1\rangle = -|1\rangle.

Neither ideal gate produces a random classical outcome. The same input state produces the same transformed output state.

Which statement correctly describes pulling a gate lever?
What is X|1⟩?
    Interactive examplefoundation

    Z and relative phase

    See how the Z gate turns |+⟩ into |-⟩.

    Not started

    The state that looks unchanged and isn't

    Alice loads +|+\rangle onto the bench and pulls the Z lever. The computational-basis probability bars do not move — both still read 50/50. "Nothing happened," she says.

    "Look again with the mirror basis," the guide replies, "and tell me if you still believe that."

    Z turns |+⟩ into |-⟩

    Z+=Z(0+12)=012=.Z|+\rangle = Z\left(\frac{|0\rangle+|1\rangle}{\sqrt{2}}\right) = \frac{|0\rangle-|1\rangle}{\sqrt{2}} = |-\rangle.

    +|+\rangle and |-\rangle share identical computational-basis probabilities, but measuring in the X basis (apply H, then measure) gives a deterministic "+" outcome for +|+\rangle and a deterministic "-" outcome for |-\rangle. Z produced a real, measurable difference.

      Guided exerciseintermediate

      Unitarity and reversibility

      Confirm that ideal unitary gates preserve total probability.

      Not started

      Every lever has a twin

      The guide shows Alice a second workshop, identical to the first but with every lever reversed. "For each ideal gate, there is exactly one lever here that undoes it," she says. "That is not a coincidence — it follows from unitarity."

      Unitarity preserves probability

      An ideal circuit gate UU is unitary: UU=IU^\dagger U = I. Unitary matrices preserve vector length, so if ψ=α0+β1|\psi\rangle = \alpha|0\rangle + \beta|1\rangle is normalized before the gate, the new state Uψ=α0+β1U|\psi\rangle = \alpha'|0\rangle + \beta'|1\rangle is normalized after it too:

      α2+β2=1    α2+β2=1.|\alpha|^2 + |\beta|^2 = 1 \implies |\alpha'|^2 + |\beta'|^2 = 1.

      Because U1=UU^{-1} = U^\dagger exists and is itself unitary, every ideal gate can be undone by another ideal gate. Noise and measurement are more general physical operations and need not be reversible on the system.

      Total probability, between 0 and 1.

        Chapter reviewintermediate

        Chapter 4 review

        Combine gate matrices, unitarity, and the gate-versus-measurement distinction.

        Not started

        The second guardian

        A taller guardian stands at the edge of the forge district. "The first guardian tested your grip on the single-qubit model," it says. "I test whether you can tell a lever from a reading."

        Chapter 4 synthesis

        Before you leave this district, confirm these pillars:

        1. Ideal gates are operators: a single-qubit circuit gate is a 2x2 unitary matrix acting deterministically on a state vector.
        2. X and Z: X0=1X|0\rangle=|1\rangle, X1=0X|1\rangle=|0\rangle; Z0=0Z|0\rangle=|0\rangle, Z1=1Z|1\rangle=-|1\rangle.
        3. Unitarity: every ideal circuit gate satisfies UU=IU^\dagger U = I, preserving normalization and guaranteeing an inverse.
        Review I — Which statement distinguishes a gate from a measurement?
        Review II — What is HXH applied to |0⟩, where H and X are the Hadamard and Pauli-X gates?

        The district opens

        The guardian steps aside. "You know a lever from a reading, and you know why every lever has a twin. Entanglement lies ahead, where the levers start to touch more than one qubit at once."

          Chapter completion

          Exercises completed: 0/4

          Next: Chapter 5Take chapter assessmentFoundations cumulative assessment