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.
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:
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 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.
The Pauli-Z gate leaves |0⟩ unchanged and multiplies |1⟩ by -1:
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 gives
and 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 and a deterministic "-" outcome for . Z turned one into the other. The relative phase that Chapter 2 warned you not to ignore is exactly what Z acts on.
Checkpoint
The Hadamard gate as a matrix
Chapter 2 introduced the Hadamard gate through its effect on outcomes. Its matrix form makes that effect precise:
Applying H a second time undoes the first application: and , so , 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.
- 1
Prepare |0⟩
- 2
Apply X, giving |1⟩
- 3
Apply H, giving |-⟩
- 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 , where 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
Every ideal single-qubit circuit gate satisfies this.
Unitarity also means every ideal gate has an inverse: , 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.
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
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 gives the same result as applying X and then H one step at a time.
Common misconceptions
Check your understanding
Summary
References and further study
- Michael A. Nielsen and Isaac L. Chuang, Quantum Computation and Quantum Information.
- John Preskill, Lecture Notes for Physics 229: Quantum Information and Computation.
- IBM Quantum Learning, Quantum circuits.
Chapter exercises
Practice the ideas from this chapter with short interactive exercises.
Gates versus measurement
Distinguish pulling a gate lever from taking a measurement.
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:
The Pauli-Z gate leaves alone and negates :
Neither ideal gate produces a random classical outcome. The same input state produces the same transformed output state.
Z and relative phase
See how the Z gate turns |+⟩ into |-⟩.
The state that looks unchanged and isn't
Alice loads 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 |-⟩
and share identical computational-basis probabilities, but measuring in the X basis (apply H, then measure) gives a deterministic "+" outcome for and a deterministic "-" outcome for . Z produced a real, measurable difference.
Unitarity and reversibility
Confirm that ideal unitary gates preserve total probability.
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 is unitary: . Unitary matrices preserve vector length, so if is normalized before the gate, the new state is normalized after it too:
Because 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 4 review
Combine gate matrices, unitarity, and the gate-versus-measurement distinction.
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:
- Ideal gates are operators: a single-qubit circuit gate is a 2x2 unitary matrix acting deterministically on a state vector.
- X and Z: , ; , .
- Unitarity: every ideal circuit gate satisfies , preserving normalization and guaranteeing an inverse.
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