Education / Quantum Computing

Quantum Computing · Chapter 05

Quantum Model of Computation

Presentation slides 14 slides · Fullscreen presentation or print to PDF

In Chapter 4, we stated the postulates of quantum mechanics using state vectors, unitary matrices, and projective measurements. Those postulates describe how an isolated quantum system evolves and how measurement extracts an outcome, but they do not yet specify how to organize a physical evolution to perform a computation.

We first define a quantum computation in three stages: input preparation, unitary evolution, and output measurement. We then trace single-qubit computations and introduce the Pauli operators.

How do the physical postulates of quantum mechanics become a programmable computation?

A classical computation starts with an input bit string, transforms it through a sequence of gates, and reads out the final bits. A quantum computation follows a similar sequence, but between preparation and measurement the state vector evolves through unitary operations whose amplitudes can interfere.

For example, applying the Hadamard operation \(H\) to \(\ket{0}\) produces \((\ket{0}+\ket{1})/\sqrt{2}\). If we measure right away, \(0\) and \(1\) are equally likely; if instead we apply a second \(H\) before measuring, the outcome is \(0\) with certainty. How do we assemble such steps into a general model of computation and track their cost?

In this chapter · 3 sections · 8 topics
  1. 5.1 Quantum Model of Computation
    Topics in this section
    1. 5.1.1 Input, evolution, and output
    2. 5.1.2 Composition and interference
    3. 5.1.3 Readout and computational cost
  2. 5.2 Single-Qubit Computation
    Topics in this section
    1. 5.2.1 A single-qubit circuit
    2. 5.2.2 A complete one-qubit computation
    3. 5.2.3 Phase and output probabilities
  3. 5.3 Pauli Operators
    Topics in this section
    1. 5.3.1 The Pauli operators
    2. 5.3.2 Describing every operator
Reading guide · preparation, aims, and assumptions

Understand the global model of quantum computation and calculate a complete single-qubit example.

Before you begin

Chapter 4 introduces state vectors, unitary operations, measurement, and the composite-state postulate.

What you should be able to do

The example to follow

Use H, Z, H to compute NOT on either input bit, then replace Z by a variable phase.

Scope and assumptions

The global model is illustrated with one qubit. Multi-qubit registers, local and joint gates, and entanglement are developed in Chapter 6.

5.1

Quantum Model of Computation

The postulates of Chapter 4 tell us what a quantum state is, how an isolated system evolves, and what an observation reports, but they do not by themselves define an algorithm. To solve a computational problem, a procedure must fix three stages: how to initialize the system to represent the input, which sequence of elementary unitary steps to apply, and how to measure the final state to extract an answer. In this section, we establish these three stages, examine how sequential steps compose and interfere, and define what it costs to run a quantum computation.

5.1.1 Input, evolution, and output§

How do state vectors, unitary matrices, and projective measurements come together to form a computation? Every computational task begins with a classical specification of an input and asks for a classical output that satisfies some criterion. The postulates of quantum mechanics divide a quantum run into three distinct stages:

First, we prepare a well-defined initial state vector \(\ket{\psi_{\mathrm{in}}}\) that encodes the input (or starts in a standard reference configuration such as \(\ket{0}\)). Second, we evolve the closed system through a sequence of unitary steps whose combined effect is a unitary transformation \(U\), producing the output state \(\ket{\psi_{\mathrm{out}}} = U\ket{\psi_{\mathrm{in}}}\). Third, we perform a measurement on \(\ket{\psi_{\mathrm{out}}}\) to obtain a single classical outcome \(y\):

\[\ket{\psi_{\mathrm{out}}} = U\ket{\psi_{\mathrm{in}}} \quad\xrightarrow{\ \text{measure}\ }\quad y.\]

Crucially, the user of a quantum computer never receives the output state vector \(\ket{\psi_{\mathrm{out}}}\) itself as a list of complex amplitudes. By the measurement postulate, a single run yields only one classical label \(y\), sampled with probability \(|\braket{y}{\psi_{\mathrm{out}}}|^2\). The output state vector determines the probability distribution over possible outcomes, and a single run draws one sample from that distribution. Consequently, a quantum algorithm succeeds only if its unitary evolution \(U\) concentrates high probability on outcomes \(y\) that answer the task.

Writing the entire evolution as a single matrix \(U\) is a convenient mathematical summary, but it hides how the transformation is actually carried out. A physical machine cannot apply an arbitrary unitary matrix in one step; it must build \(U\) from a sequence of elementary operations, and counting how many elementary operations are required is an essential part of analyzing any algorithm.

Although a general quantum protocol may perform measurements mid-computation and use the classical outcomes to choose subsequent unitary operations, almost every core quantum algorithm can be understood in the cleanest arrangement: unitary evolution from start to finish, followed by a single measurement at the very end.

Input, unitary evolution, and readoutThe wire carries the quantum input through the complete unitary Uf to measurement. M produces one classical result; Uf may contain many elementary gates. Read each circuit left to right.Input, unitary evolution, and readout|ψ_(rm in)⟩yU_fM|ψ_(rm out)⟩=U_f|ψ_(rm in)⟩ before M
The wire carries the quantum input through the complete unitary Uf to measurement. M produces one classical result; Uf may contain many elementary gates.
Problems
  1. What are the three stages in the overview of a quantum computation?

    Show solutionHide solution

    Specify the input state, apply the prescribed unitary evolution, and measure the output.

  2. Does one measurement reveal every amplitude in the output state?

    Show solutionHide solution

    No. It returns one classical outcome, sampled with the probabilities determined by the amplitudes.

  3. Why does drawing the whole evolution as one block not make it a one-step computation?

    Show solutionHide solution

    The block abbreviates a sequence of elementary operations; its implementation cost must still be counted.

5.1.2 Composition and interference§

When the total evolution \(U\) is assembled from a sequence of elementary unitary steps, how do those steps combine? Just as in Boolean circuits, we call an elementary unitary operation that the hardware applies directly a gate, and we call an ordered sequence of gates a quantum program (or circuit).

From Section 4.1.4, we know how successive steps compose: amplitudes multiply along paths and sum across intermediate configurations, which corresponds algebraically to matrix multiplication. If a program applies the gates \(U_1, U_2, \dots, U_T\) in that chronological order to \(\ket{\psi_{\mathrm{in}}}\), the combined unitary transformation is the matrix product

\[U = U_T\cdots U_2 U_1,\]

written from right to left because each gate acts on the column vector to its right: \(\ket{\psi_{\mathrm{out}}} = U_T(\cdots(U_2(U_1\ket{\psi_{\mathrm{in}}}))\cdots)\). Because each individual gate \(U_t\) is unitary and preserves vector lengths, their product \(U\) is also unitary, guaranteeing that the final outcome probabilities always sum to \(1\). Notice that collapsing the product into a single symbol \(U\) is purely notational—the hardware still has to execute all \(T\) gates in sequence.

Why execute a multi-gate sequence if the net effect is just another unitary matrix? Because intermediate gates can alter relative phases that are completely invisible to an immediate computational-basis measurement, yet decisive for how later gates recombine paths. Compare two simple programs starting from \(\ket{0}\): applying \(H\) then \(H\), versus applying \(H\), then \(Z\), then \(H\). After the first \(H\), the state is \((\ket{0}+\ket{1})/\sqrt{2}\), where \(0\) and \(1\) each have probability \(1/2\). Applying \(Z\) flips the sign of \(\ket{1}\) to give \((\ket{0}-\ket{1})/\sqrt{2}\), leaving the intermediate computational-basis probabilities unchanged at \(1/2\) and \(1/2\). Yet multiplying the matrices reveals completely opposite final evolutions:

\[HH = I,\qquad HZH = \frac{1}{2}\begin{pmatrix}1 & 1\\ 1 & -1\end{pmatrix}\begin{pmatrix}1 & 0\\ 0 & -1\end{pmatrix}\begin{pmatrix}1 & 1\\ 1 & -1\end{pmatrix} = \begin{pmatrix}0 & 1\\ 1 & 0\end{pmatrix} = X.\]

Starting from \(\ket{0}\), the sequence \(HH\) returns \(\ket{0}\) with certainty, whereas \(HZH\) returns \(\ket{1}\) with certainty! The relative minus sign introduced by \(Z\) cannot be detected by measuring in the computational basis right after \(Z\), but the final Hadamard gate converts that relative phase into constructive interference on \(\ket{1}\) and destructive cancellation on \(\ket{0}\). An intermediate quantum state is never merely a classical probability distribution over configurations; its relative phases govern the interference of all subsequent steps.

Gates compose in time orderThe same wire passes through U1 and then U2. The output is U2 U1 applied to the input. Read each circuit left to right.Gates compose in time order|ψ_(rm in)⟩U₁U₂|ψ_(rm out)⟩=U₂U₁|ψ_(rm in)⟩
The same wire passes through U1 and then U2. The output is U2 U1 applied to the input.
Problems
  1. In the product U₃U₂U₁, which operation acts first?

    Show solutionHide solution

    U₁ acts first, then U₂, then U₃.

  2. Compare \(HH\) and \(HZH\) on input \(\ket0\).

    Show solutionHide solution

    \(HH\ket0=\ket0\), whereas \(HZH\ket0=\ket1\).

  3. Why can a phase change matter even when it leaves the immediate basis probabilities unchanged?

    Show solutionHide solution

    Later operations add contributions at common endpoints. Their relative phases determine whether they reinforce or cancel.

5.1.3 Readout and computational cost§

When the final gate finishes and we measure in the computational basis, outcome \(y\) appears with Born-rule probability

\[p(y) = |\braket{y}{\psi_{\mathrm{out}}}|^2 = |\bra{y}U\ket{\psi_{\mathrm{in}}}|^2.\]

What if the algorithm is probabilistic—say, it produces the correct answer with probability \(3/4\) and an incorrect answer with probability \(1/4\)? A single run will fail one time in four. However, by repeating the entire computation from scratch several times and taking the majority vote among the observed outcomes, we can drive the probability of an overall error arbitrarily close to zero. Because measurement collapses the state, each repetition requires preparing a fresh copy of \(\ket{\psi_{\mathrm{in}}}\) and running the full gate sequence \(U\) again. Any probabilistic quantum algorithm must state its per-run success probability so we know how many repetitions are needed.

For a cost comparison to be meaningful, we must also be honest about how the input is supplied. An algorithm must construct \(\ket{\psi_{\mathrm{in}}}\) and choose its gates using only the given problem specification; it cannot smuggle the solution into the state preparation for free.

How, then, do we measure the total cost of a quantum computation? We count the physical and operational resources the machine consumes: the number of qubits (workspace width), the total number of elementary gates, the number of sequential gate layers (depth), the number of independent runs required to achieve the target confidence, and any classical pre- or post-processing. For example, both the three-gate sequence \(HZH\) and the single gate \(X\) implement the exact same unitary matrix \(X\), but the first costs three gates while the second costs one.

Finally, keep in mind that a single-qubit example cannot by itself demonstrate a quantum speedup over classical computing. Computational advantage is a statement about how resource costs scale as the problem size grows—a question that requires multi-qubit registers and careful complexity analysis in the chapters ahead.

One run gives one resultEach fresh run prepares its input and repeats the circuit. The double line carries the sampled classical result, not the state’s amplitude list. Read each circuit left to right.One run gives one result|ψ_(rm in)⟩yU_fMp(y)=|⟨y|U_f|ψ_(rm in)⟩|²
Each fresh run prepares its input and repeats the circuit. The double line carries the sampled classical result, not the state’s amplitude list.
Problems
  1. What does a measurement return on a single run?

    Show solutionHide solution

    One classical outcome, rather than a complete amplitude list.

  2. An output state has amplitudes \(3/5\) and \(4/5\). Find the two basis probabilities.

    Show solutionHide solution

    The probabilities are \(9/25\) and \(16/25\), which sum to one.

  3. Why must repeated executions and initialization be included in the cost?

    Show solutionHide solution

    Each execution needs its own initialization and gate sequence. Repetitions can be essential to obtain a reliable answer.

5.2

Single-Qubit Computation

Even though a single qubit can only encode a one-bit input, it is already rich enough to exhibit every stage of our computational model: state preparation, coherent gate execution, interference, and final readout. In this section, we introduce standard quantum circuit diagrams, trace a complete single-qubit computation in which interference flips a bit, and replace the discrete sign flip \(Z\) with a continuous phase rotation \(R_\phi\) to see how output probabilities vary smoothly with relative phase.

5.2.1 A single-qubit circuit§

Just as we drew diagrams for classical logic circuits in Chapter 2, we can represent a quantum program visually as a quantum circuit so that the sequence of gates and measurements is clear at a glance. For a single qubit, the computation begins in an initial state \(\ket{\psi_{\mathrm{in}}} = a\ket{0} + b\ket{1}\) with \(|a|^2 + |b|^2 = 1\). To encode a classical input bit \(x\in\{0,1\}\), we initialize the qubit in \(\ket{0}\) and apply \(X\) if \(x=1\), producing the basis state \(\ket{x}\).

In a circuit diagram, time flows from left to right—Notice that this is opposite to the right-to-left order of matrices in an algebraic product \(U_T\cdots U_2 U_1\ket{\psi_{\mathrm{in}}}\). A horizontal single line, called a wire, represents the qubit evolving through time, with its initial state written at the left end. Each unitary gate—such as \(H\), \(X\), or \(Z\)—is drawn as a labeled box on the wire, while a bare segment of wire represents the identity step \(I\) (the qubit waiting unchanged). Remember that a wire depicts the history of a qubit over time, not a physical wire carrying an electric current through space.

A box marked with a meter symbol (or the letter \(\mathrm{M}\)) represents a measurement in the computational basis \(\{\ket{0},\ket{1}\}\). To the right of the measurement box, a double line carries the resulting classical bit \(y\). Keeping single wires and double lines visually distinct reminds us of a crucial physical boundary: before \(\mathrm{M}\), the single wire carries a coherent quantum state vector with complex amplitudes; after \(\mathrm{M}\), the double line carries a definite classical bit (\(0\) or \(1\)).

In the simple circuit below, the qubit starts in \(\ket{0}\), passes through a Hadamard box \(H\) to become \((\ket{0}+\ket{1})/\sqrt{2}\), and is then measured, yielding \(y=0\) or \(y=1\) with probability \(1/2\) each. A single box in a diagram can also stand for a larger subroutine built from many elementary gates; the visual width of a box on the page says nothing about its internal gate cost.

One qubit: a gate followed by measurementOne wire starts at ket zero, passes through H and M, and then becomes a double classical line carrying y.One qubit: a gate followed by measurement |0⟩ H M y Hadamard gateMeasurement One quantum wire before measurement; a classical record afterward.
Read from left to right: initialize the qubit in \(\ket{0}\), apply the Hadamard gate \(H\), and measure (\(\mathrm{M}\)) in the computational basis. The double line to the right of \(\mathrm{M}\) carries the classical outcome bit \(y\), not a quantum state vector.
Problems
  1. What do a single wire, a gate box, and a double output line mean?

    Show solutionHide solution

    A single wire tracks a qubit; a gate box applies the named operation; a double output line carries the classical measurement record.

  2. Find the output probabilities after H on \(\ket1\).

    Show solutionHide solution

    \(H\ket1=(\ket0-\ket1)/\sqrt2\), so each basis outcome has probability \(1/2\).

  3. How can a specified classical input bit 1 be initialized from \(\ket0\)?

    Show solutionHide solution

    Apply X, since \(X\ket0=\ket1\).

5.2.2 A complete one-qubit computation§

Let us trace a complete single-qubit computation that uses quantum interference to compute a deterministic function: logical negation (\(\mathrm{NOT}(x) = 1-x\)). While the single gate \(X\) flips a bit directly, implementing \(\mathrm{NOT}\) via the three-gate sequence \(H\), then \(Z\), then \(H\) lets us watch interference do the work step by step. Suppose the input bit is \(0\), so we start in \(\ket{0}\):

\[\ket{0} \xrightarrow{\ H\ } \frac{\ket{0}+\ket{1}}{\sqrt{2}} \xrightarrow{\ Z\ } \frac{\ket{0}-\ket{1}}{\sqrt{2}} \xrightarrow{\ H\ } \ket{1}.\]

Look at the three stages. The first Hadamard splits \(\ket{0}\) into an equal superposition of \(\ket{0}\) and \(\ket{1}\). Next, the phase-flip gate \(Z\) leaves the amplitude of \(\ket{0}\) at \(+1/\sqrt{2}\) and negates the amplitude of \(\ket{1}\) to \(-1/\sqrt{2}\). Finally, the second Hadamard sends two paths of magnitude \(1/2\) to each output configuration: at \(\ket{0}\), the two path contributions are \(+1/2\) and \(-1/2\), which cancel to \(0\); at \(\ket{1}\), both path contributions are \(+1/2\) (since the negative sign on \(\ket{1}\) multiplies the negative arrow weight \(\bra{1}H\ket{1} = -1/\sqrt{2}\)), reinforcing to \(+1\). Measuring at the end returns \(y=1\) with probability \(1\).

What if the input bit is \(1\)? Starting from \(\ket{1}\) and running the exact same circuit gives

\[\ket{1} \xrightarrow{\ H\ } \frac{\ket{0}-\ket{1}}{\sqrt{2}} \xrightarrow{\ Z\ } \frac{\ket{0}+\ket{1}}{\sqrt{2}} \xrightarrow{\ H\ } \ket{0}.\]

Here \(Z\) turns the relative minus sign back into a plus sign, so the second Hadamard reinforces on \(\ket{0}\) and cancels on \(\ket{1}\), returning \(y=0\) with certainty. Thus the circuit computes \(\mathrm{NOT}(x)\) for both classical inputs, and by linearity it transforms any superposition \(a\ket{0}+b\ket{1}\) into \(b\ket{0}+a\ket{1}\), matching the matrix identity \(HZH = X\).

Notice why both the middle phase gate and the absence of intermediate measurement are indispensable. If we omit \(Z\), the two Hadamards cancel (\(HH=I\)) and the input bit emerges unchanged. If we insert a computational-basis measurement right after the first \(H\) (or right after \(Z\)), the superposition collapses to either \(\ket{0}\) or \(\ket{1}\), and the final \(H\) then produces a random \(50/50\) coin toss instead of the negated bit.

Relative phase becomes a definite outputA qubit initialized to zero passes through H, Z, H, and measurement. The result is one with certainty. Relative phase becomes a definite output |0⟩ M 1 H Z H |0⟩ → (|0⟩ + |1⟩)/√2 → (|0⟩ − |1⟩)/√2 → |1⟩ Double lines carry classical measurement records.
Computing \(\mathrm{NOT}\) by interference: on input \(\ket{0}\), the gate sequence \(H, Z, H\) produces \(\ket{1}\) with certainty; on input \(\ket{1}\), the same sequence produces \(\ket{0}\) with certainty. Measurement takes place only after all three unitary gates have acted.
Problems
  1. What is the result of H, Z, H on input zero?

    Show solutionHide solution

    One with certainty.

  2. Follow input \(\ket1\) through H, Z, H.

    Show solutionHide solution

    \(\ket1\) becomes \((\ket0-\ket1)/\sqrt2\), then \((\ket0+\ket1)/\sqrt2\), then \(\ket0\).

  3. What changes if a measurement is inserted after the first H?

    Show solutionHide solution

    The measurement selects zero or one; either selected state gives equal final probabilities after Z and H. The deterministic interference result is lost.

5.2.3 Phase and output probabilities§

In our \(HZH\) circuit, the gate \(Z\) flipped the relative sign of \(\ket{1}\) by \(-1 = e^{i\pi}\), switching the final measurement outcome from certainty of \(0\) to certainty of \(1\). What happens if we rotate the relative phase by an arbitrary angle \(\phi\) between \(0\) and \(\pi\)? Replace \(Z\) with the general phase gate \(R_\phi = \operatorname{diag}(1, e^{i\phi})\), which leaves \(\ket{0}\) unchanged and multiplies \(\ket{1}\) by the unit-magnitude phase factor \(e^{i\phi}\):

\[R_\phi\ket{0} = \ket{0},\qquad R_\phi\ket{1} = e^{i\phi}\ket{1}.\]

Because \(|e^{i\phi}| = 1\), the columns of \(R_\phi\) are orthonormal for every real angle \(\phi\), so \(R_\phi\) is unitary. Notice that \(\phi = 0\) gives \(R_0 = I\), while \(\phi = \pi\) gives \(R_\pi = Z\). Tracing the circuit \(H R_\phi H\) from input \(\ket{0}\) yields

\[\ket{0} \xrightarrow{\ H\ } \frac{\ket{0}+\ket{1}}{\sqrt{2}} \xrightarrow{\ R_\phi\ } \frac{\ket{0}+e^{i\phi}\ket{1}}{\sqrt{2}} \xrightarrow{\ H\ } \frac{1+e^{i\phi}}{2}\ket{0} + \frac{1-e^{i\phi}}{2}\ket{1}.\]

Taking the squared magnitudes of the two final amplitudes (using \(|1\pm e^{i\phi}|^2 = (1\pm\cos\phi)^2 + \sin^2\phi = 2(1\pm\cos\phi)\), just as in Section 3.4.3) gives the readout probabilities:

\[p(0) = \left|\frac{1+e^{i\phi}}{2}\right|^2 = \frac{1+\cos\phi}{2},\qquad p(1) = \left|\frac{1-e^{i\phi}}{2}\right|^2 = \frac{1-\cos\phi}{2}.\]

As \(\phi\) varies continuously from \(0\) to \(\pi\), the probability of reading out \(0\) glides smoothly from \(p(0)=1\) (at \(\phi=0\), pure constructive interference on \(0\)), through \(p(0)=1/2\) (at \(\phi=\pi/2\), where \(1\) and \(i\) meet at a right angle in the complex plane), down to \(p(0)=0\) (at \(\phi=\pi\), complete cancellation on \(0\) and certainty of \(1\)). Immediately before the second Hadamard gate, the state \((\ket{0}+e^{i\phi}\ket{1})/\sqrt{2}\) has identical computational-basis probabilities \((1/2, 1/2)\) for every value of \(\phi\); the final Hadamard gate is what translates the hidden relative phase \(\phi\) into observable readout probabilities.

Phase becomes an output probabilityThe final Hadamard converts the relative phase into measurement probabilities. Read each circuit left to right.Phase becomes an output probability|0⟩yHR_φHMp(0)=(1+cosφ)/2, p(1)=(1−cosφ)/2
The final Hadamard converts the relative phase into measurement probabilities.
Problems
  1. What does \(R_\phi\) do to each basis state?

    Show solutionHide solution

    It leaves \(\ket0\) unchanged and maps \(\ket1\) to \(e^{i\phi}\ket1\).

  2. Calculate the output probabilities at \(\phi=0,\pi/2,\pi\).

    Show solutionHide solution

    The pairs \((p(0),p(1))\) are \((1,0)\), \((1/2,1/2)\), and \((0,1)\).

  3. Start the phase circuit at \(\ket1\) instead of \(\ket0\). Find its final amplitudes and probabilities.

    Show solutionHide solution

    The final state is \((1-e^{i\phi})\ket0/2+(1+e^{i\phi})\ket1/2\). Its probabilities are \(p(0)=(1-\cos\phi)/2\) and \(p(1)=(1+\cos\phi)/2\).

5.3

Pauli Operators

Our single-qubit programs have already made heavy use of the identity \(I\), the bit flip \(X\), the phase flip \(Z\), the Hadamard \(H\), and phase rotations \(R_\phi\). How are all possible \(2\times 2\) single-qubit matrices related to one another? In this section, we introduce the fourth member of the Pauli family—the combined bit-and-phase flip \(Y\)—show that the four matrices \(I, X, Y, Z\) form a linear basis that can express any single-qubit operator, and distinguish between writing an operator as a sum of basis matrices and building a unitary gate out of a circuit.

5.3.1 The Pauli operators§

We have met \(X\), which swaps \(\ket{0}\) and \(\ket{1}\), and \(Z\), which flips the relative sign of \(\ket{1}\). What happens if we perform both actions in sequence—applying \(Z\) first and \(X\) second? Acting on the computational basis states,

\[XZ\ket{0} = X\ket{0} = \ket{1},\qquad XZ\ket{1} = X(-\ket{1}) = -\ket{0}.\]

The product \(XZ\) swaps the two configurations and attaches opposite signs to them. Notice, however, one algebraic difference: whereas \(X\) and \(Z\) each equal their own adjoint and square to the identity (\(X^2 = I\) and \(Z^2 = I\)), applying \(XZ\) twice gives \((XZ)^2\ket{0} = XZ\ket{1} = -\ket{0}\), so \((XZ)^2 = -I\). Multiplying \(XZ\) by the imaginary unit \(i\) restores self-inversion, since \((iXZ)^2 = i^2(XZ)^2 = (-1)(-I) = I\). We therefore define the operator \(Y\) as

\[Y = iXZ,\qquad Y\ket{0} = i\ket{1},\qquad Y\ket{1} = -i\ket{0}.\]

Together, \(X\), \(Y\), and \(Z\) are called the Pauli operators (or Pauli matrices). Alongside the identity matrix \(I\), their \(2\times 2\) matrices in the computational basis \(\{\ket{0},\ket{1}\}\) are

\[I = \begin{pmatrix}1 & 0\\ 0 & 1\end{pmatrix},\quad X = \begin{pmatrix}0 & 1\\ 1 & 0\end{pmatrix},\quad Y = \begin{pmatrix}0 & -i\\ i & 0\end{pmatrix},\quad Z = \begin{pmatrix}1 & 0\\ 0 & -1\end{pmatrix}.\]

On a general single-qubit state \(\ket{\psi} = a\ket{0} + b\ket{1}\), the three Pauli gates act as a bit flip, a combined bit-and-phase flip, and a phase flip:

\[X(a\ket{0}+b\ket{1}) = b\ket{0}+a\ket{1},\quad Y(a\ket{0}+b\ket{1}) = -ib\ket{0}+ia\ket{1},\quad Z(a\ket{0}+b\ket{1}) = a\ket{0}-b\ket{1}.\]

Each of \(I, X, Y, Z\) is both unitary and equal to its own adjoint (\(P^\dagger = P\), a property called Hermitian), so each is its own inverse: \(X^2 = Y^2 = Z^2 = I\). Does the order matter when we multiply two distinct Pauli matrices? Very much so: we found \(XZ\ket{0} = \ket{1}\), whereas reversing the order gives \(ZX\ket{0} = Z\ket{1} = -\ket{1}\). In fact, any two distinct Pauli operators anticommute—swapping their order introduces a minus sign (\(ZX = -XZ\), \(YX = -XY\), \(ZY = -YZ\))—and multiplying any two distinct Paulis produces the third Pauli times \(\pm i\) (for instance, \(XY = iZ\) and \(YZ = iX\)). When a single-qubit state is multiplied by a product of Pauli gates, that extra factor of \(-1\) or \(\pm i\) is an overall global phase and does not alter any measurement probabilities.

The Pauli gates on one wireThese are four separate circuits on the same arbitrary input. The displayed output vectors include their phase factors. Read each circuit left to right.The Pauli gates on one wireI|ψ⟩Ia|0⟩+b|1⟩X|ψ⟩Xb|0⟩+a|1⟩Y|ψ⟩Y−ib|0⟩+ia|1⟩Z|ψ⟩Za|0⟩−b|1⟩
These are four separate circuits on the same arbitrary input. The displayed output vectors include their phase factors.
Problems
  1. Find \(Y\ket0\) and \(Y\ket1\).

    Show solutionHide solution

    \(Y\ket0=i\ket1\) and \(Y\ket1=-i\ket0\).

  2. Check \(Y^2=I\) on both basis states.

    Show solutionHide solution

    \(Y^2\ket0=i(-i)\ket0=\ket0\) and \(Y^2\ket1=(-i)i\ket1=\ket1\). Linearity establishes the identity for every input.

  3. Calculate \(XZ\ket0\) and \(ZX\ket0\). How does \(Y=iXZ\) account for the phase?

    Show solutionHide solution

    \(XZ\ket0=\ket1\), while \(ZX\ket0=-\ket1\). Multiplying the first result by i gives \(Y\ket0=i\ket1\).

5.3.2 Describing every operator§

Look at where the nonzero entries of \(I, X, Y, Z\) sit: \(I\) and \(Z\) occupy the main diagonal (with matching and opposite signs), while \(X\) and \(Y\) occupy the off-diagonal positions (with matching real entries and opposite imaginary entries). Can every \(2\times 2\) complex matrix be written as a linear combination of \(I, X, Y,\) and \(Z\)? Take an arbitrary \(2\times 2\) matrix

\[A = \begin{pmatrix}a & b\\ c & d\end{pmatrix}.\]

Because \(\tfrac{1}{2}(I+Z) = \begin{pmatrix}1 & 0\\ 0 & 0\end{pmatrix}\) and \(\tfrac{1}{2}(I-Z) = \begin{pmatrix}0 & 0\\ 0 & 1\end{pmatrix}\), combinations of \(I\) and \(Z\) can produce any diagonal entries \(a\) and \(d\). Similarly, because \(\tfrac{1}{2}(X+iY) = \begin{pmatrix}0 & 1\\ 0 & 0\end{pmatrix}\) and \(\tfrac{1}{2}(X-iY) = \begin{pmatrix}0 & 0\\ 1 & 0\end{pmatrix}\), combinations of \(X\) and \(Y\) can produce any off-diagonal entries \(b\) and \(c\). Combining all four pieces expresses \(A\) uniquely as

\[A = \frac{a+d}{2}I + \frac{b+c}{2}X + \frac{c-b}{2i}Y + \frac{a-d}{2}Z.\]

We can verify each entry directly: the top-left entry is \(\tfrac{a+d}{2} + \tfrac{a-d}{2} = a\), the bottom-right is \(\tfrac{a+d}{2} - \tfrac{a-d}{2} = d\), the top-right is \(\tfrac{b+c}{2} - i\tfrac{c-b}{2i} = b\), and the bottom-left is \(\tfrac{b+c}{2} + i\tfrac{c-b}{2i} = c\). Thus the four matrices \(\{I, X, Y, Z\}\) form a complete basis for single-qubit operators—every linear operator on a single qubit (whether unitary or not) is a weighted sum of these four matrices. For example, our Hadamard gate and phase gate expand as

\[H = \frac{X+Z}{\sqrt{2}},\qquad R_\phi = \frac{1+e^{i\phi}}{2}I + \frac{1-e^{i\phi}}{2}Z.\]

Pause to distinguish two very different ways of combining matrices. Writing \(H = (X+Z)/\sqrt{2}\) expresses \(H\) as a sum of Pauli matrices, whereas a quantum circuit combines gates in sequence by multiplying their matrices. A circuit containing only the gates \(X, Y, Z\) can only form products like \(ZX = iY\), which map \(\ket{0}\) to \(\pm\ket{0}\), \(\pm i\ket{0}\), \(\pm\ket{1}\), or \(\pm i\ket{1}\)—a sequence of Pauli gates starting from \(\ket{0}\) can never create a superposition like \(H\ket{0} = (\ket{0}+\ket{1})/\sqrt{2}\)! Nor is every linear combination of Pauli matrices a valid quantum gate: for instance, \(I+Z = \operatorname{diag}(2,0)\) doubles \(\ket{0}\) and annihilates \(\ket{1}\), which is not unitary.

When does a linear combination of \(I\) and a Pauli matrix give a valid unitary gate? For any real angle \(\theta\), define the continuous rotation operator

\[R_x(\theta) = \cos\frac{\theta}{2}\,I - i\sin\frac{\theta}{2}\,X = \begin{pmatrix}\cos(\theta/2) & -i\sin(\theta/2)\\ -i\sin(\theta/2) & \cos(\theta/2)\end{pmatrix}.\]

Taking its adjoint replaces \(-i\) with \(+i\) (since \(I^\dagger = I\) and \(X^\dagger = X\)), and multiplying \(R_x(\theta)^\dagger R_x(\theta)\) cancels the cross terms \(\pm i\cos(\theta/2)\sin(\theta/2)X\) while using \(X^2 = I\) to leave \(\bigl(\cos^2(\theta/2) + \sin^2(\theta/2)\bigr)I = I\). Thus \(R_x(\theta)\) is unitary for every \(\theta\): acting on \(\ket{0}\), it produces \(\cos(\theta/2)\ket{0} - i\sin(\theta/2)\ket{1}\), rotating the state continuously between \(\ket{0}\) (at \(\theta=0\)) and \(-i\ket{1}\) (at \(\theta=\pi\), where \(R_x(\pi) = -iX\)). Having a continuous family of gates \(R_x(\theta)\) is a much stronger hardware capability than having only the single fixed gate \(X\).

In short, the four Pauli matrices \(\{I, X, Y, Z\}\) provide a universal coordinate system for describing any single-qubit operator on paper; constructing arbitrary unitary evolutions out of a fixed set of hardware gates is a separate engineering and algorithmic question that we will tackle in Chapter 8.

Further reading: IBM Quantum’s guide to the Pauli basis.

A matrix sum is not a gate sequenceH equals the normalized matrix sum of X and Z. Applying X then Z instead gives their product ZX, a different circuit. Read each circuit left to right.A matrix sum is not a gate sequenceHadamard|0⟩HH=(X+Z)/√2; H|0⟩=|+⟩Pauli sequence|0⟩XZZX|0⟩=−|1⟩
H equals the normalized matrix sum of X and Z. Applying X then Z instead gives their product ZX, a different circuit.
Problems
  1. What is the distinction between a linear combination of Pauli matrices and a sequence of Pauli gates?

    Show solutionHide solution

    A linear combination adds weighted matrix entries. A sequence multiplies the matrices in application order. These are different operations.

  2. Expand \(\operatorname{diag}(1,i)\) in the Pauli basis.

    Show solutionHide solution

    \(\operatorname{diag}(1,i)=(1+i)I/2+(1-i)Z/2\); the X and Y coefficients vanish.

  3. Can a sequence of I, X, Y, and Z map \(\ket0\) to \((\ket0+\ket1)/\sqrt2\)? Explain without counting circuit lengths.

    Show solutionHide solution

    No. Each Pauli maps a basis state to a basis state times a phase. Repeating such operations preserves that property, whereas the target has two nonzero basis amplitudes.

Summary

Questions and worked problems

Attempt each question before opening a hint. Explain your reasoning, then compare it with the solution.

1. Quick check §

Why does drawing the whole evolution as one block not make it a one-step computation?

Hint 1

Track the amplitudes through each operation before taking squared magnitudes.

Worked solution

The block abbreviates a sequence of elementary operations; its implementation cost must still be counted.

Revisit the relevant explanation

2. Quick check §

Apply \(H\), then \(X\), then \(H\) to \(\ket0\) and to \(\ket1\), and identify the resulting operation. Do the same for \(H\), \(Y\), \(H\).

Hint 1

\(X\ket\pm=\pm\ket\pm\).

Hint 2

\(Y\ket+=-i\ket-\) and \(Y\ket-=i\ket+\).

Worked solution

For \(HXH\): \(\ket0\to\ket+\to\ket+\to\ket0\) and \(\ket1\to\ket-\to-\ket-\to-\ket1\). So \(HXH=Z\). For \(HYH\): \(\ket0\to\ket+\to\frac{1}{\sqrt2}(i\ket1-i\ket0)=-i\ket-\to-i\ket1\), and \(\ket1\to\ket-\to\frac{1}{\sqrt2}(i\ket1+i\ket0)=i\ket+\to i\ket0\). The operation sends \(\ket0\mapsto-i\ket1\) and \(\ket1\mapsto i\ket0\), which is \(-Y\). Conjugating by \(H\) exchanges \(X\) and \(Z\) and flips the sign of \(Y\); the earlier identity \(HZH=X\) is one case of this pattern.

Revisit the relevant explanation

3. Quick check §

In the circuit \(H\), \(R_\phi\), \(H\) on input \(\ket0\), which values of \(\phi\) give \(p(1)=\frac34\)? Can a measurement of the output distinguish \(\phi=2\pi/3\) from \(\phi=4\pi/3\)?

Hint 1

\(p(1)=(1-\cos\phi)/2\).

Hint 2

\(\cos\phi=\cos(2\pi-\phi)\).

Worked solution

\(p(1)=\frac34\) requires \(\cos\phi=-\frac12\), so \(\phi=2\pi/3\) or \(\phi=4\pi/3\) in \([0,2\pi)\). The probabilities depend on \(\phi\) only through \(\cos\phi\), so these two phases give identical statistics for this circuit: no number of repetitions will separate them. The final amplitudes do differ, \(\frac{1\pm e^{i\phi}}{2}\), but only in a way that the computational-basis measurement does not see. Telling them apart needs a different circuit, for example one that adds a known phase of \(\pi/2\) before the final \(H\).

Revisit the relevant explanation

4. Worked problem §

Follow input \(\ket1\) through H, Z, H.

Hint 1

Track the amplitudes through each operation before taking squared magnitudes.

Worked solution

\(\ket1\) becomes \((\ket0-\ket1)/\sqrt2\), then \((\ket0+\ket1)/\sqrt2\), then \(\ket0\).

Revisit the relevant explanation

5. Worked problem §

Expand \(A=\begin{pmatrix}0&1\\0&0\end{pmatrix}\) in the Pauli basis using \(A=\frac{a+d}{2}I+\frac{b+c}{2}X+\frac{c-b}{2i}Y+\frac{a-d}{2}Z\). Verify the expansion by adding the matrices. Then find \(A\ket0\) and \(A\ket1\), and explain why \(A\) is not a gate.

Hint 1

Here \(a=c=d=0\) and \(b=1\).

Hint 2

\(\frac{-1}{2i}=\frac i2\).

Worked solution

The coefficients are \(0\) for \(I\) and \(Z\), \(\frac12\) for \(X\), and \(\frac{-1}{2i}=\frac i2\) for \(Y\), so \(A=\frac12(X+iY)\). Check: \(\frac12\begin{pmatrix}0&1\\1&0\end{pmatrix}+\frac i2\begin{pmatrix}0&-i\\i&0\end{pmatrix}=\frac12\begin{pmatrix}0&1+1\\1-1&0\end{pmatrix}=\begin{pmatrix}0&1\\0&0\end{pmatrix}\). Then \(A\ket1=\ket0\) and \(A\ket0=0\), the zero vector. A gate must send every normalized state to a normalized state; \(A\) destroys \(\ket0\) entirely, so it is not unitary. Completeness lets the Paulis describe every \(2\times2\) matrix, including ones that no closed-system evolution can produce.

Revisit the relevant explanation

6. Worked problem §

Compute the products \(XY\), \(YZ\), and \(ZX\) by applying them to \(\ket0\) and \(\ket1\), and express each as a phase times a single Pauli. A circuit applies \(X\) and then \(Y\). Which single gate has the same effect on every input, up to global phase?

Hint 1

\(XY\) means \(Y\) acts first.

Hint 2

For example, \(XY\ket0=X(i\ket1)=i\ket0\).

Worked solution

\(XY\ket0=X(i\ket1)=i\ket0\) and \(XY\ket1=X(-i\ket0)=-i\ket1\), so \(XY=iZ\). \(YZ\ket0=Y\ket0=i\ket1\) and \(YZ\ket1=-Y\ket1=i\ket0\), so \(YZ=iX\). \(ZX\ket0=Z\ket1=-\ket1\) and \(ZX\ket1=Z\ket0=\ket0\), which is \(iY\) since \(iY\ket0=-\ket1\) and \(iY\ket1=\ket0\). So \(ZX=iY\). The circuit “\(X\), then \(Y\)” is the product \(YX=-XY=-iZ\), which is \(Z\) up to the global phase \(-i\). Any product of Paulis collapses to one Pauli times a phase, which is why Pauli gates alone cannot create superpositions from \(\ket0\).

Revisit the relevant explanation

7. Worked problem §

Using \(R_x(\theta)=\cos\frac\theta2I-i\sin\frac\theta2X\) and \(X^2=I\), show that \(R_x(\alpha)R_x(\beta)=R_x(\alpha+\beta)\). Deduce that \(R_x(\pi/2)\) is a square root of NOT up to global phase, and compare it with the square root \(\sqrt X\) of Chapter 3, whose stay-weight is \(\frac{1+i}{2}\) and switch-weight is \(\frac{1-i}{2}\).

Hint 1

Multiply out and use the angle-addition formulas.

Hint 2

\(R_x(\pi)=-iX\). Write \(e^{i\pi/4}=\frac{1+i}{\sqrt2}\).

Worked solution

Multiplying, \(R_x(\alpha)R_x(\beta)=\cos\frac\alpha2\cos\frac\beta2I-i\big(\sin\frac\alpha2\cos\frac\beta2+\cos\frac\alpha2\sin\frac\beta2\big)X-\sin\frac\alpha2\sin\frac\beta2X^2\). With \(X^2=I\), the \(I\) terms combine to \(\cos\frac{\alpha+\beta}{2}\) and the \(X\) terms to \(-i\sin\frac{\alpha+\beta}{2}\), giving \(R_x(\alpha+\beta)\). Hence \(R_x(\pi/2)^2=R_x(\pi)=-iX\): NOT up to the global phase \(-i\). Multiplying \(R_x(\pi/2)=\frac{1}{\sqrt2}(I-iX)\) by \(e^{i\pi/4}=\frac{1+i}{\sqrt2}\) gives \(\frac{1+i}{2}I+\frac{1-i}{2}X\), which is exactly \(S\). The square root of NOT found by path sums is a rotation by \(\pi/2\) about the \(X\) direction, up to global phase.

Revisit the relevant explanation

8. Misconception §

A student runs the phase circuit \(H\), \(R_\phi\), \(H\) once, obtains outcome \(0\), and reports “\(\phi=0\), because \(p(0)=1\) at \(\phi=0\).” What does one outcome actually establish? How many runs would estimate \(p(0)\) to within about \(\pm0.05\), and what would still remain unknown?

Hint 1

Outcome \(0\) has nonzero probability for every \(\phi\neq\pi\).

Hint 2

For \(R\) runs the standard deviation of the observed frequency is at most \(1/(2\sqrt R)\).

Worked solution

One outcome \(0\) rules out only \(\phi=\pi\), where \(p(0)=0\). For every other \(\phi\) the outcome had probability \((1+\cos\phi)/2>0\); at \(\phi=\pi/2\), for instance, it was a fair coin. Estimating \(p(0)\) requires repeated runs with fresh initialization. With \(R\) runs the observed frequency has standard deviation at most \(1/(2\sqrt R)\), so about \(100\) runs give roughly \(\pm0.05\). Even then, the estimate determines \(\cos\phi\) but not the sign of \(\phi\). The cost of a measured answer includes the repetitions, as the cost of readout requires.

Revisit the relevant explanation

9. Extension §

Start the phase circuit at \(\ket1\) instead of \(\ket0\). Find its final amplitudes and probabilities.

Hint 1

Track the amplitudes through each operation before taking squared magnitudes.

Worked solution

The final state is \((1-e^{i\phi})\ket0/2+(1+e^{i\phi})\ket1/2\). Its probabilities are \(p(0)=(1-\cos\phi)/2\) and \(p(1)=(1+\cos\phi)/2\).

Revisit the relevant explanation

10. Extension §

Use \(HXH=Z\), \(HZH=X\), and \(HIH=I\) to show that \(HR_x(\theta)H=R_z(\theta)\), where \(R_z(\theta)=\cos\frac\theta2I-i\sin\frac\theta2Z\). Write \(R_z(\theta)\) as a diagonal matrix and show that it equals the phase operation \(R_\theta\) up to a global phase. What does this say about the circuit \(H\), \(R_\phi\), \(H\)?

Hint 1

Conjugation by \(H\) acts term by term on a linear combination: \(H(aI+bX)H=aI+bZ\).

Hint 2

\(\cos\frac\theta2\mp i\sin\frac\theta2=e^{\mp i\theta/2}\).

Worked solution

Since \(H(aI+bX)H=aHIH+bHXH=aI+bZ\), we get \(HR_x(\theta)H=\cos\frac\theta2I-i\sin\frac\theta2Z=R_z(\theta)\). On the diagonal, \(R_z(\theta)=\mathrm{diag}(e^{-i\theta/2},e^{i\theta/2})=e^{-i\theta/2}\,\mathrm{diag}(1,e^{i\theta})=e^{-i\theta/2}R_\theta\). Hence \(HR_\phi H=e^{i\phi/2}HR_z(\phi)H=e^{i\phi/2}R_x(\phi)\), because \(H\) undoes itself. The interference circuit is, up to global phase, a single rotation about the \(X\) direction by \(\phi\): from \(\ket0\) it gives \(p(1)=\sin^2\frac\phi2=\frac{1-\cos\phi}{2}\), as found for the phase circuit. Phase changes and rotations are the same operations seen in different bases.

Revisit the relevant explanation

Where this leads. Chapter 6 extends the model to multiple qubits and develops joint operations, entanglement, and local measurement.

Search this book

Search all chapters and appendices.