Linear Operators & Matrices
Linear Operators & Matrices
Quantum gates, observables, Hamiltonians, and measurements are all linear operators. This lesson nails the operator toolkit: how an operator becomes a matrix once you fix a basis, how the adjoint is defined (it's where "Hermitian" and "unitary" will come from), and the basis-independent quantities — trace and determinant — we rely on constantly.
Learning Objectives
After this lesson you will be able to:
- Represent a linear operator as a matrix in a chosen basis and compute its action on kets.
- Define the adjoint via the inner product and show it equals the conjugate transpose.
- Perform a change of basis and recognize similarity transformations.
- Compute and use the trace (cyclicity, basis-independence) and the determinant.
- Evaluate commutators and explain why they matter physically.
Intuition
A linear operator is a function on vectors that respects addition and scaling: it sends lines to lines and the origin to the origin. Fix a basis and the operator is completely captured by what it does to the basis vectors — a finite table of numbers, i.e. a matrix. Change the basis and the same operator gets a different matrix. The quantities that don't change under such relabeling — trace, determinant, eigenvalues — are the operator's physical fingerprints.
Theory
Linear operators
A map is a linear operator if for all and ,
Linearity means is determined by its action on a basis: if , then for ,
The coefficients (from 0.1.3) are the matrix of ; the formula above is matrix–vector multiplication. Composition is matrix multiplication: , derived by inserting completeness .
The adjoint
The adjoint (Hermitian conjugate) is defined by the inner-product relation
Equivalently . Claim: in any orthonormal basis, the matrix of is the conjugate transpose of the matrix of : .
Proof. . By the defining relation with , : $\langle j|A|i\rangle = \langle A^\dagger j|i\rangle = \overline{\langle i | A^\dagger | j\rangle} = \overline{(A^\dagger){ij}}(A^\dagger){ij} = \overline{\langle j|A|i\rangle} = \overline{A_{ji}}$. ∎
Properties (all from the definition): , , , and .
These three names — defined next lesson but anchored here — are adjoint conditions: Hermitian , unitary , normal .
Change of basis
Let and be two orthonormal bases, related by a unitary with (columns of are the new basis vectors in old coordinates). A ket's coordinate column transforms as , and an operator's matrix transforms by a similarity transformation:
Derivation. . Same operator, new matrix. Quantities preserved by are exactly the physical invariants below.
Trace
The trace is . Key properties:
- Linear: .
- Cyclic: . (Proof: expand indices; , then iterate.)
- Basis-independent: $\operatorname{Tr}(S^\dagger A S) = \operatorname{Tr}(A S S^\dagger) = \operatorname{Tr}(A)SS^\dagger = I$. (We proved basis-independence directly in 0.1.3 E3 too.)
- Equals the sum of eigenvalues (next lesson).
The trace is how expectation values and probabilities are computed in the density-matrix formalism: (Term 1.5).
Determinant and commutator
The determinant is the product of eigenvalues; it is multiplicative (), basis-independent (), and is invertible iff . For unitaries .
The commutator measures failure to commute; the anticommutator is . Commutators are central in quantum mechanics: observables commute iff they are simultaneously diagonalizable (Term 0.1.5) and can be measured together without disturbance; the canonical gives the uncertainty principle (Term 1.3). For Pauli matrices, (see Appendix E).
Worked Examples
Example 1 — Building a matrix from its action
Define on a qubit by , (it swaps basis states). The columns of the matrix are the images of the basis kets in coordinates:
This is the Pauli- / NOT gate. Its adjoint is (Hermitian), and since also (unitary): is both Hermitian and unitary — a fact we'll see is special to involutions.
Example 2 — Change of basis: seen in the Hadamard basis
The Pauli- is diagonal in . Change to the Hadamard basis via S = H = \tfrac1{\sqrt2}\begin{psmallmatrix}1 & 1\\ 1 & -1\end{psmallmatrix} (which is unitary and Hermitian, so ):
So in the basis is — the famous identity . Same operator, different matrix; note and are unchanged ( and respectively).
Hands-on (Python)
import numpy as np
def dag(A):
return A.conj().T # adjoint = conjugate transpose
X = np.array([[0, 1], [1, 0]], dtype=complex)
Y = np.array([[0, -1j], [1j, 0]], dtype=complex)
Z = np.array([[1, 0], [0, -1]], dtype=complex)
H = np.array([[1, 1], [1, -1]], dtype=complex) / np.sqrt(2)
# Build an operator column-by-column from its action on the basis:
ket0 = np.array([1, 0], dtype=complex)
ket1 = np.array([0, 1], dtype=complex)
A = np.column_stack([X @ ket0, X @ ket1]) # columns are A|0>, A|1>
print(np.allclose(A, X)) # True
# Adjoint, trace, determinant:
print(np.allclose(dag(X), X)) # X is Hermitian
print(np.trace(Z), np.linalg.det(Z)) # 0, (-1+0j)
# Change of basis HZH = X (similarity transform with S = H, S† = H):
print(np.allclose(dag(H) @ Z @ H, X)) # True
print(np.isclose(np.trace(dag(H) @ Z @ H), np.trace(Z))) # trace invariant: True# Commutators / anticommutators of Paulis:
def comm(A, B): return A @ B - B @ A
def acomm(A, B): return A @ B + B @ A
print(np.allclose(comm(X, Y), 2j * Z)) # [X,Y] = 2iZ
print(np.allclose(acomm(X, Y), np.zeros((2, 2)))) # Paulis anticommute: {X,Y}=0Braket preview. When you build
Circuit().x(0)in Term 2, the SDK is composing exactly these operator matrices (as a unitary) and applying them to the state vector. The math here is what the simulator does under the hood.
Exercises
E1 (easy). Find the matrix of the operator and identify it.
Solution
|0\rangle\langle1| = \begin{psmallmatrix}0&1\\0&0\end{psmallmatrix}, |1\rangle\langle0| = \begin{psmallmatrix}0&0\\1&0\end{psmallmatrix}; their sum is \begin{psmallmatrix}0&1\\1&0\end{psmallmatrix} = X, the NOT gate.
E2 (easy). Verify for , .
Solution
AB = X S = \begin{psmallmatrix}0&i\\1&0\end{psmallmatrix}, so (AB)^\dagger = \begin{psmallmatrix}0&1\\-i&0\end{psmallmatrix}. , , so $B^\dagger A^\dagger = \operatorname{diag}(1,-i)X = \begin{psmallmatrix}0&1\-i&0\end{psmallmatrix}$. They match. ∎
E3 (medium). Prove from the index definition, and give a counterexample to .
Solution
$\operatorname{Tr}(AB) = \sum_i (AB){ii} = \sum{i,j}A_{ij}B_{ji} = \sum_{j,i}B_{ji}A_{ij} = \sum_j (BA)_{jj} = \operatorname{Tr}(BA)$. But cyclicity allows only rotations, not arbitrary swaps. Counterexample with Paulis: vs . Since ... let's use : so , trace . And : , so , trace . ∎
E4 (medium). Show that the trace of a commutator is always zero, . What does this imply about whether can hold for finite matrices?
Solution
by cyclicity. But in dimension . So the canonical commutation relation has no finite-dimensional matrix realization — position and momentum require infinite-dimensional Hilbert spaces. (Qubits, being finite, only ever use bounded observables like the Paulis.)
E5 (hard). Prove that the trace is the unique (up to scale) linear functional on operators satisfying for all — i.e. cyclicity essentially characterizes the trace.
Solution sketch
Using with , : and , so . Take , : forces for . Take , : forces all diagonal values equal, say to . Then by linearity $f(A) = \sum_i A_{ii},c = c\operatorname{Tr}(A)f$ is a scalar multiple of the trace. ∎
Checkpoint
- How is an operator's matrix determined by its action on a basis?
- Give the defining inner-product relation for the adjoint and the resulting matrix rule.
- How does an operator's matrix transform under a change of orthonormal basis?
- List three properties of the trace and explain why basis-independence matters physically.
- What is the physical significance of two observables commuting?
Answers
- The -th column is in coordinates; equivalently .
- ; in an ONB, (conjugate transpose).
- with unitary (similarity transform).
- Linear, cyclic (), basis-independent, equals sum of eigenvalues. Basis-independence means physical predictions (e.g. ) don't depend on the arbitrary choice of coordinates.
- Commuting observables share an eigenbasis, so they can be measured simultaneously with definite joint values and without mutual disturbance.
Further Reading
- [Axl] Axler, Linear Algebra Done Right, Ch. 3, 5, 7, 10 — operators, adjoints, trace, determinant.
- [NC] Nielsen & Chuang, §2.1.5–2.1.7 — operators, adjoints, the outer-product representation, trace.
- [HJ] Horn & Johnson, Matrix Analysis — the definitive matrix reference.
← Prev: Dirac Notation · Up: Term 0 · Next: Eigenvalues & the Spectral Theorem →