|q⟩ Bad Qubits

intermediate · Programming · Hamiltonian Simulation & Trotterization

Pauli Hamiltonians

Every quantum system has a Hamiltonian — a Hermitian operator HH whose eigenvalues are the system's energy levels. To simulate HH on a quantum computer we need to express it as a sum of Pauli terms, because each individual Pauli exponential eiθPe^{-i\theta P} translates directly into a short circuit (the subject of the next lesson).

The Pauli basis

The four single-qubit Pauli matrices

I=(1001),X=(0110),Y=(0ii0),Z=(1001)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}

form an orthogonal basis for the space of all 2×22\times 2 Hermitian matrices. Any single-qubit Hamiltonian can be written uniquely as

H=cII+cXX+cYY+cZZ,cPR.H = c_I\,I + c_X\,X + c_Y\,Y + c_Z\,Z, \qquad c_P \in \mathbb{R}.

For nn qubits the basis extends to all 4n4^n tensor products P1P2PnP_1 \otimes P_2 \otimes \cdots \otimes P_n with Pj{I,X,Y,Z}P_j \in \{I,X,Y,Z\}, often written as strings such as ZXIZXI or ZZZZ. A general nn-qubit Hamiltonian is then

H=P{I,X,Y,Z}ncPP.H = \sum_{P \in \{I,X,Y,Z\}^n} c_P\,P.

Extracting Pauli coefficients

The Pauli matrices are orthonormal under the Hilbert–Schmidt inner product A,B=12tr(AB)\langle A,B\rangle = \tfrac{1}{2}\operatorname{tr}(A^\dagger B). Concretely, 12tr(PjPk)=δjk\tfrac{1}{2}\operatorname{tr}(P_j^\dagger P_k) = \delta_{jk} for any two Pauli strings PjP_j, PkP_k. This orthonormality lets you read off each coefficient by a trace:

cP=12ntr(PH).c_P = \frac{1}{2^n}\operatorname{tr}(P\,H).

A worked example: single-qubit Hamiltonian

Consider the 1-qubit Hamiltonian H=3Z+XH = 3Z + X. In matrix form:

H=3(1001)+(0110)=(3113).H = 3\begin{pmatrix}1 & 0\\ 0 & -1\end{pmatrix} + \begin{pmatrix}0 & 1\\ 1 & 0\end{pmatrix} = \begin{pmatrix}3 & 1\\ 1 & -3\end{pmatrix}.

Let us verify the coefficient of ZZ using the trace formula:

cZ=12tr(ZH)=12tr ⁣(1001)(3113)=12tr(3113)=12(3+3)=3.c_Z = \tfrac{1}{2}\operatorname{tr}(Z H) = \tfrac{1}{2}\operatorname{tr}\!\begin{pmatrix}1&0\\0&-1\end{pmatrix}\begin{pmatrix}3&1\\1&-3\end{pmatrix} = \tfrac{1}{2}\operatorname{tr}\begin{pmatrix}3&1\\-1&3\end{pmatrix} = \tfrac{1}{2}(3+3) = 3.

We can confirm the other coefficients:

The decomposition H=0I+1X+0Y+3Z=X+3ZH = 0\cdot I + 1\cdot X + 0\cdot Y + 3\cdot Z = X + 3Z matches what we started with.

Multi-qubit Hamiltonians

For two qubits the 16 Pauli strings {II,IX,IY,IZ,XI,XX,,ZZ}\{II, IX, IY, IZ, XI, XX, \ldots, ZZ\} span the space of 4×44\times 4 Hermitian matrices. A paradigmatic example is the transverse-field Ising model on two sites:

HIsing=J(ZZ)h(XI+IX),H_{\text{Ising}} = -J\,(Z\otimes Z) - h\,(X\otimes I + I\otimes X),

where JJ is the coupling strength and hh is the transverse field. This Hamiltonian has only three non-zero Pauli terms, which is typical: physically motivated Hamiltonians are sparse in the Pauli basis — they have far fewer than 4n4^n terms — and that sparsity is what makes Trotterisation efficient.

Why the Pauli representation matters for simulation

Each Pauli string PP satisfies P2=IP^2 = I, so its eigenvalues are ±1\pm 1. The exponential of a single Pauli term is therefore a rotation:

eiθP=cos(θ)Iisin(θ)P.e^{-i\theta P} = \cos(\theta)\,I - i\sin(\theta)\,P.

This closed-form expression means that any individual Pauli exponential can be realised as a small, exact quantum circuit. When the Hamiltonian is a sum H=kckPkH = \sum_k c_k P_k, the Trotter–Suzuki formula decomposes eiHte^{-iHt} into a product of these simple rotations, each of which maps directly to a circuit. The Pauli decomposition is therefore not just a mathematical convenience — it is the bridge between the physical description of a system and its gate-level implementation.

Try it

The 1-qubit Hamiltonian H=3Z+XH = 3Z + X has the matrix (3113)\begin{pmatrix}3 & 1\\ 1 & -3\end{pmatrix}. Use the trace formula cZ=12tr(ZH)c_Z = \tfrac{1}{2}\operatorname{tr}(ZH) to compute the coefficient of ZZ and return it.

Run your code to see the quantum state.

Sign in on the full site to ask questions and join the discussion.