QuantumCore

Lesson 5 · 45 min · introductory

Linear Operators & Matrix Representations

Loading progress…

A linear operator on a finite-dimensional Hilbert space is completely described by a square matrix of numbers Aij=⟨i∣A∣j⟩A_{ij}=\langle i\vert A\vert j\rangle. This lesson derives that representation, shows that composing operators is multiplying matrices, defines the adjoint A†A^\dagger and proves how a matrix changes when we switch orthonormal bases.

Prerequisites: Dirac Bra–Ket Notation & Outer Products

Objectives and key results
  • Represent a linear map by its matrix elements Aij=⟨i∣A∣j⟩A_{ij}=\langle i\vert A\vert j\rangle in an orthonormal basis and reconstruct A=∑ijAij∣i⟩⟨j∣A=\sum_{ij}A_{ij}\lvert i\rangle\langle j\rvert.

  • Compose operators as matrix products, deriving (AB)ij=∑kAikBkj(AB)_{ij}=\sum_k A_{ik}B_{kj} from the completeness relation.

  • Compute adjoints from the defining identity ⟨u∣Av⟩=⟨A†u∣v⟩\langle u\vert Av\rangle=\langle A^\dagger u\vert v\rangle and use (A†)ij=Aji‾(A^\dagger)_{ij}=\overline{A_{ji}} and (AB)†=B†A†(AB)^\dagger=B^\dagger A^\dagger.

  • Change orthonormal basis with [A]F=P†[A]EP[A]_{\mathcal F}=P^\dagger[A]_{\mathcal E}P and explain why the trace does not depend on the basis.

definition · Matrix element
Aij=⟨i∣A∣j⟩,A=∑i,jAij ∣i⟩⟨j∣A_{ij}=\langle i\vert A\vert j\rangle,\qquad A=\sum_{i,j}A_{ij}\,\lvert i\rangle\langle j\rvert
identity · Composition is matrix multiplication
(AB)ij=∑kAikBkj(AB)_{ij}=\sum_{k}A_{ik}B_{kj}
identity · Adjoint
(A†)ij=Aji‾,(AB)†=B†A†(A^\dagger)_{ij}=\overline{A_{ji}},\qquad (AB)^\dagger=B^\dagger A^\dagger
theorem · Change of orthonormal basis
[A]F=P† [A]E P,Pij=⟨ei∣fj⟩[A]_{\mathcal F}=P^\dagger\,[A]_{\mathcal E}\,P,\qquad P_{ij}=\langle e_i\vert f_j\rangle
identity · Trace is basis independent
Tr (P†AP)=Tr A\mathrm{Tr}\,(P^\dagger A P)=\mathrm{Tr}\,A

Linear maps and their matrices#

Quantum states live in a Hilbert space H≅Cd\mathcal H\cong\mathbb C^d, and everything that happens to a state — a gate, a time evolution, a measurement observable — is described by a linear operator on that space. Before we can talk about Hermitian observables or unitary gates we need a precise, computational handle on operators in general. The key message of this lesson is simple: once an orthonormal basis {∣1⟩,…,∣d⟩}\{\lvert 1\rangle,\dots,\lvert d\rangle\} is fixed, an operator is a d×dd\times d complex matrix, and every abstract statement about operators becomes a statement about matrices that we can check with a calculator or a simulator.

Throughout, {∣i⟩}i=1d\{\lvert i\rangle\}_{i=1}^{d} is an orthonormal basis, so ⟨i∣j⟩=δij\langle i\vert j\rangle=\delta_{ij}, and we use the completeness relation from the Dirac-notation lesson: ∑k=1d∣k⟩⟨k∣=I.\sum_{k=1}^{d}\lvert k\rangle\langle k\rvert=I.

Definition

Linear operator

A map A:H→HA:\mathcal H\to\mathcal H is linear if A(α∣u⟩+β∣v⟩)=αA∣u⟩+βA∣v⟩A(\alpha\lvert u\rangle+\beta\lvert v\rangle)=\alpha A\lvert u\rangle+\beta A\lvert v\rangle for all vectors ∣u⟩,∣v⟩\lvert u\rangle,\lvert v\rangle and all scalars α,β∈C\alpha,\beta\in\mathbb C. We write A∣v⟩A\lvert v\rangle or ∣Av⟩\lvert Av\rangle for the image of ∣v⟩\lvert v\rangle.

Proposition

A linear operator is determined by the images of the basis vectors

Let AA be linear on H\mathcal H with orthonormal basis {∣j⟩}\{\lvert j\rangle\}. Then for every ∣v⟩=∑jvj∣j⟩\lvert v\rangle=\sum_j v_j\lvert j\rangle we have A∣v⟩=∑jvj A∣j⟩A\lvert v\rangle=\sum_j v_j\,A\lvert j\rangle. In particular, two linear operators that agree on every basis vector are equal, and AA is fully specified by the dd vectors A∣1⟩,…,A∣d⟩A\lvert 1\rangle,\dots,A\lvert d\rangle.

Proof (4 steps)
  1. Step 1:
    ∣v⟩=∑j=1dvj∣j⟩,vj=⟨j∣v⟩\lvert v\rangle=\sum_{j=1}^{d}v_j\lvert j\rangle,\qquad v_j=\langle j\vert v\rangle
    Expand ∣v⟩\lvert v\rangle in the orthonormal basis; the coefficients are the inner products ⟨j∣v⟩\langle j\vert v\rangle (Parseval).
  2. Step 2:
    A∣v⟩=A(∑jvj∣j⟩)A\lvert v\rangle=A\Big(\sum_{j}v_j\lvert j\rangle\Big)
    Apply AA to both sides of the expansion.
  3. Step 3:
    =∑jvj A∣j⟩=\sum_{j}v_j\,A\lvert j\rangle
    Linearity lets us pull the finite sum and the scalars vjv_j outside AA.
  4. Step 4:
    A∣j⟩=B∣j⟩ ∀j ⟹ A∣v⟩=∑jvjA∣j⟩=∑jvjB∣j⟩=B∣v⟩ ∀vA\lvert j\rangle=B\lvert j\rangle\ \forall j\ \Longrightarrow\ A\lvert v\rangle=\sum_j v_jA\lvert j\rangle=\sum_j v_jB\lvert j\rangle=B\lvert v\rangle\ \forall v
    If two linear maps agree on the basis, the same expansion shows they agree on every vector, so A=BA=B.

∎

Derivation

From basis images to the matrix Aij=⟨i∣A∣j⟩A_{ij}=\langle i\vert A\vert j\rangle

  1. Step 1:
    A∣j⟩=∑i∣i⟩⟨i∣A∣j⟩A\lvert j\rangle=\sum_{i}\lvert i\rangle\langle i\vert A\vert j\rangle
    Expand the vector A∣j⟩A\lvert j\rangle in the basis by inserting I=∑i∣i⟩⟨i∣I=\sum_i\lvert i\rangle\langle i\rvert on the left.
  2. Step 2:
    Aij:=⟨i∣A∣j⟩ ⟹ A∣j⟩=∑iAij∣i⟩A_{ij}:=\langle i\vert A\vert j\rangle\ \Longrightarrow\ A\lvert j\rangle=\sum_i A_{ij}\lvert i\rangle
    Name the coefficients: column jj of the matrix holds the coordinates of the image A∣j⟩A\lvert j\rangle.
  3. Step 3:
    A∣v⟩=∑jvj∑iAij∣i⟩=∑i(∑jAijvj)∣i⟩A\lvert v\rangle=\sum_j v_j\sum_i A_{ij}\lvert i\rangle=\sum_i\Big(\sum_j A_{ij}v_j\Big)\lvert i\rangle
    Combine with the proposition above and swap the two finite sums.
  4. Step 4:
    (Av)i=∑jAijvj(A v)_i=\sum_j A_{ij}v_j
    The ii-th coordinate of the image is the ordinary matrix–vector product of the matrix [Aij][A_{ij}] with the column (vj)(v_j).
  5. Step 5:
    A=IAI=∑i,j∣i⟩⟨i∣A∣j⟩⟨j∣=∑i,jAij ∣i⟩⟨j∣A=IAI=\sum_{i,j}\lvert i\rangle\langle i\vert A\vert j\rangle\langle j\rvert=\sum_{i,j}A_{ij}\,\lvert i\rangle\langle j\rvert
    Inserting completeness on both sides writes the operator itself as a sum of outer products weighted by its matrix elements.

Result

A  ⟷  [A]ij=⟨ei∣A∣ej⟩is a bijection  L(Cd)→Cd×d\boxed{A\;\longleftrightarrow\;[A]_{ij}=\langle e_i\rvert A\lvert e_j\rangle\qquad\text{is a bijection }\ \mathcal L(\mathbb C^d)\to\mathbb C^{d\times d}}

Worked example — the bit flip. Define XX on a qubit by X∣0⟩=∣1⟩X\lvert0\rangle=\lvert1\rangle and X∣1⟩=∣0⟩X\lvert1\rangle=\lvert0\rangle and extend linearly. Column 0 is the image of ∣0⟩\lvert0\rangle, i.e. (0,1)T(0,1)^T; column 1 is the image of ∣1⟩\lvert1\rangle, i.e. (1,0)T(1,0)^T. So X=(0110)=∣0⟩⟨1∣+∣1⟩⟨0∣,X=\begin{pmatrix}0&1\\1&0\end{pmatrix}=\lvert0\rangle\langle1\rvert+\lvert1\rangle\langle0\rvert, and for a general state X(α∣0⟩+β∣1⟩)=β∣0⟩+α∣1⟩X(\alpha\lvert0\rangle+\beta\lvert1\rangle)=\beta\lvert0\rangle+\alpha\lvert1\rangle. The matrix elements are ⟨0∣X∣1⟩=⟨0∣0⟩=1\langle0\vert X\vert1\rangle=\langle0\vert0\rangle=1 and ⟨0∣X∣0⟩=⟨0∣1⟩=0\langle0\vert X\vert0\rangle=\langle0\vert1\rangle=0, exactly as the formula Aij=⟨i∣A∣j⟩A_{ij}=\langle i\vert A\vert j\rangle predicts.

Worked example — a non-unitary operator. The operator σ−=∣0⟩⟨1∣\sigma^-=\lvert0\rangle\langle1\rvert ("lowering") sends ∣1⟩↦∣0⟩\lvert1\rangle\mapsto\lvert0\rangle and ∣0⟩↦0\lvert0\rangle\mapsto 0. Its matrix is (0100)\begin{pmatrix}0&1\\0&0\end{pmatrix}. It is perfectly linear but it destroys information (two different inputs, ∣0⟩\lvert0\rangle and 00, collapse together), so it can never be a quantum gate; it appears later as a Kraus operator of amplitude damping.

X=(0110)=∣0⟩⟨1∣+∣1⟩⟨0∣X=\begin{pmatrix}0&1\\1&0\end{pmatrix}=\lvert0\rangle\langle1\rvert+\lvert1\rangle\langle0\rvert
Pauli-X (bit flip) in the computational basis2×2

Unitary verified: U†U=IU^\dagger U = I (max deviation 0.0e+0)

Quick check

An operator satisfies A∣0⟩=12(∣0⟩+∣1⟩)A\lvert0\rangle=\tfrac{1}{\sqrt2}(\lvert0\rangle+\lvert1\rangle) and A∣1⟩=12(∣0⟩−∣1⟩)A\lvert1\rangle=\tfrac{1}{\sqrt2}(\lvert0\rangle-\lvert1\rangle). What is A10=⟨1∣A∣0⟩A_{10}=\langle1\vert A\vert0\rangle?

tolerance ±0.001

Composition is matrix multiplication#

Applying BB first and then AA gives the operator ABAB defined by (AB)∣v⟩=A(B∣v⟩)(AB)\lvert v\rangle=A(B\lvert v\rangle). It is linear because both factors are. In a quantum circuit read left to right, the gate applied first stands rightmost in the product: the circuit "BB then AA" has unitary ABAB. The matrix of ABAB follows from one insertion of the completeness relation.

Derivation

Matrix of a composition

  1. Step 1:
    (AB)ij=⟨i∣AB∣j⟩(AB)_{ij}=\langle i\vert AB\vert j\rangle
    Definition of the matrix element of the operator ABAB.
  2. Step 2:
    =⟨i∣A I B∣j⟩=\langle i\vert A\,I\,B\vert j\rangle
    Insert the identity operator between the two factors; this changes nothing.
  3. Step 3:
    =⟨i∣A(∑k∣k⟩⟨k∣)B∣j⟩=\langle i\vert A\Big(\sum_{k}\lvert k\rangle\langle k\rvert\Big)B\vert j\rangle
    Replace II by the completeness relation ∑k∣k⟩⟨k∣\sum_k\lvert k\rangle\langle k\rvert.
  4. Step 4:
    =∑k⟨i∣A∣k⟩⟨k∣B∣j⟩=\sum_{k}\langle i\vert A\vert k\rangle\langle k\vert B\vert j\rangle
    Linearity of the inner product lets the finite sum move outside.
  5. Step 5:
    =∑kAikBkj=\sum_{k}A_{ik}B_{kj}
    Recognise each bracket as a matrix element; this is exactly the row-times-column rule of matrix multiplication.

Result

[AB]=[A] [B](same orthonormal basis)\boxed{[AB]=[A]\,[B]\qquad\text{(same orthonormal basis)}}

Worked example — order matters. With X=(0110)X=\begin{pmatrix}0&1\\1&0\end{pmatrix} and Z=(100−1)Z=\begin{pmatrix}1&0\\0&-1\end{pmatrix}: XZ=(0⋅1+1⋅00⋅0+1⋅(−1)1⋅1+0⋅01⋅0+0⋅(−1))=(0−110),ZX=(01−10).XZ=\begin{pmatrix}0\cdot1+1\cdot0&0\cdot0+1\cdot(-1)\\1\cdot1+0\cdot0&1\cdot0+0\cdot(-1)\end{pmatrix}=\begin{pmatrix}0&-1\\1&0\end{pmatrix},\qquad ZX=\begin{pmatrix}0&1\\-1&0\end{pmatrix}. So XZ=−ZXXZ=-ZX: the two Pauli operators anticommute. Comparing with Y=(0−ii0)Y=\begin{pmatrix}0&-i\\i&0\end{pmatrix} we find XZ=−iYXZ=-iY and ZX=iYZX=iY. The commutator [X,Z]=XZ−ZX=−2iY[X,Z]=XZ-ZX=-2iY is non-zero, which is the algebraic root of the uncertainty relation between bit and phase measurements. Operator multiplication is associative, (AB)C=A(BC)(AB)C=A(BC), because matrix multiplication is, but it is not commutative.

XZ=(0−110)=−iYXZ=\begin{pmatrix}0&-1\\1&0\end{pmatrix}=-iY
Product XZ = -iY2×2

Unitary verified: U†U=IU^\dagger U = I (max deviation 0.0e+0)

Quick check

A circuit applies HH and then ZZ to one qubit. Which operator describes the whole circuit?

Select one answer

The adjoint operator#

Definition

Adjoint (Hermitian conjugate)

The adjoint of AA is the unique operator A†A^\dagger such that ⟨u∣Av⟩=⟨A†u∣v⟩\langle u\vert Av\rangle=\langle A^\dagger u\vert v\rangle for all ∣u⟩,∣v⟩∈H\lvert u\rangle,\lvert v\rangle\in\mathcal H. Uniqueness: if BB and B′B' both satisfy the identity then ⟨(B−B′)u∣v⟩=0\langle (B-B')u\vert v\rangle=0 for all vv, and choosing v=(B−B′)uv=(B-B')u gives ∥(B−B′)u∥2=0\lVert (B-B')u\rVert^2=0 for every uu.

Proposition

The adjoint is the conjugate transpose

In any orthonormal basis, (A†)ij=Aji‾(A^\dagger)_{ij}=\overline{A_{ji}}. Conversely, the operator whose matrix is the conjugate transpose of [Aij][A_{ij}] satisfies the defining identity, so the adjoint exists.

Proof (5 steps)
  1. Step 1:
    (A†)ij=⟨i∣A†j⟩(A^\dagger)_{ij}=\langle i\vert A^\dagger j\rangle
    Matrix element of A†A^\dagger written as an inner product of ∣i⟩\lvert i\rangle with A†∣j⟩A^\dagger\lvert j\rangle.
  2. Step 2:
    =⟨A†j∣i⟩‾=\overline{\langle A^\dagger j\vert i\rangle}
    Conjugate symmetry of the inner product: ⟨a∣b⟩=⟨b∣a⟩‾\langle a\vert b\rangle=\overline{\langle b\vert a\rangle}.
  3. Step 3:
    =⟨j∣Ai⟩‾=\overline{\langle j\vert A i\rangle}
    Defining identity of the adjoint with u=ju=j, v=iv=i: ⟨A†j∣i⟩=⟨j∣Ai⟩\langle A^\dagger j\vert i\rangle=\langle j\vert Ai\rangle.
  4. Step 4:
    =Aji‾=\overline{A_{ji}}
    ⟨j∣Ai⟩\langle j\vert Ai\rangle is the matrix element AjiA_{ji}.
  5. Step 5:
    ⟨u∣Av⟩=∑i,jui‾Aijvj=∑j(∑iAij‾ui)‾vj=⟨AˉTu∣v⟩\langle u\vert Av\rangle=\sum_{i,j}\overline{u_i}A_{ij}v_j=\sum_{j}\overline{\Big(\sum_i\overline{A_{ij}}u_i\Big)}v_j=\langle \bar A^{T}u\vert v\rangle
    Existence: expanding both sides in coordinates shows that the conjugate-transpose matrix AˉT\bar A^T satisfies the defining identity.

∎

Proposition

Adjoint of a product reverses the order

For all operators A,BA,B on H\mathcal H: (AB)†=B†A†(AB)^\dagger=B^\dagger A^\dagger. Also (A†)†=A(A^\dagger)^\dagger=A and (αA+βB)†=αˉA†+βˉB†(\alpha A+\beta B)^\dagger=\bar\alpha A^\dagger+\bar\beta B^\dagger.

Proof (5 steps)
  1. Step 1:
    ⟨u∣ABv⟩=⟨A†u∣Bv⟩\langle u\vert ABv\rangle=\langle A^\dagger u\vert Bv\rangle
    Apply the defining identity of A†A^\dagger with the vector BvBv in the second slot.
  2. Step 2:
    =⟨B†A†u∣v⟩=\langle B^\dagger A^\dagger u\vert v\rangle
    Apply the defining identity of B†B^\dagger with the vector A†uA^\dagger u in the first slot.
  3. Step 3:
    ⟹ (AB)†=B†A†\Longrightarrow\ (AB)^\dagger=B^\dagger A^\dagger
    B†A†B^\dagger A^\dagger satisfies the defining identity of (AB)†(AB)^\dagger for all u,vu,v, and the adjoint is unique.
  4. Step 4:
    ((A†)†)ij=(A†)ji‾=Aij‾‾=Aij((A^\dagger)^\dagger)_{ij}=\overline{(A^\dagger)_{ji}}=\overline{\overline{A_{ij}}}=A_{ij}
    Apply the conjugate-transpose rule twice.
  5. Step 5:
    ((αA+βB)†)ij=αAji+βBji‾=αˉ Aji‾+βˉ Bji‾((\alpha A+\beta B)^\dagger)_{ij}=\overline{\alpha A_{ji}+\beta B_{ji}}=\bar\alpha\,\overline{A_{ji}}+\bar\beta\,\overline{B_{ji}}
    Complex conjugation is additive and multiplicative, giving antilinearity of the dagger.

∎

Worked example. For A=(12i34−i)A=\begin{pmatrix}1&2i\\3&4-i\end{pmatrix} we transpose and conjugate: A†=(13−2i4+i)A^\dagger=\begin{pmatrix}1&3\\-2i&4+i\end{pmatrix}. For the phase gate S=diag(1,i)S=\mathrm{diag}(1,i) we get S†=diag(1,−i)S^\dagger=\mathrm{diag}(1,-i) and S†S=diag(1,(−i)(i))=diag(1,1)=IS^\dagger S=\mathrm{diag}(1,(-i)(i))=\mathrm{diag}(1,1)=I. The dagger also connects kets and bras: a ket is a d×1d\times1 matrix and (∣ψ⟩)†=⟨ψ∣\big(\lvert\psi\rangle\big)^\dagger=\langle\psi\rvert is the 1×d1\times d conjugate row, so (A∣ψ⟩)†=⟨ψ∣A†(A\lvert\psi\rangle)^\dagger=\langle\psi\rvert A^\dagger is just the product rule above.

S=(100i),S†=(100−i)S=\begin{pmatrix}1&0\\0&i\end{pmatrix},\qquad S^\dagger=\begin{pmatrix}1&0\\0&-i\end{pmatrix}
Phase gate S2×2

Unitary verified: U†U=IU^\dagger U = I (max deviation 0.0e+0)

Quick check

For A=(12i34−i)A=\begin{pmatrix}1&2i\\3&4-i\end{pmatrix}, what is the entry (A†)10(A^\dagger)_{10} (row 1, column 0, zero-based)?

Select one answer

Change of orthonormal basis and the trace#

The same operator has different matrices in different bases. In quantum computing we constantly switch between the computational basis E=(∣0⟩,∣1⟩)\mathcal E=(\lvert0\rangle,\lvert1\rangle) and, for instance, the Hadamard basis F=(∣+⟩,∣−⟩)\mathcal F=(\lvert+\rangle,\lvert-\rangle) with ∣±⟩=12(∣0⟩±∣1⟩)\lvert\pm\rangle=\tfrac1{\sqrt2}(\lvert0\rangle\pm\lvert1\rangle). Measuring "in the XX basis" on hardware literally means applying the change-of-basis unitary and then measuring in E\mathcal E. We now derive the transformation rule.

Theorem

Change of orthonormal basis

Let E={∣ei⟩}\mathcal E=\{\lvert e_i\rangle\} and F={∣fj⟩}\mathcal F=\{\lvert f_j\rangle\} be orthonormal bases and Pij=⟨ei∣fj⟩P_{ij}=\langle e_i\vert f_j\rangle. Then PP is unitary and for every operator AA, [A]F=P†[A]EP[A]_{\mathcal F}=P^\dagger[A]_{\mathcal E}P, where ([A]E)ij=⟨ei∣A∣ej⟩([A]_{\mathcal E})_{ij}=\langle e_i\vert A\vert e_j\rangle and ([A]F)ij=⟨fi∣A∣fj⟩([A]_{\mathcal F})_{ij}=\langle f_i\vert A\vert f_j\rangle.

Proof (6 steps)
  1. Step 1:
    ∣fj⟩=∑k∣ek⟩⟨ek∣fj⟩=∑kPkj∣ek⟩\lvert f_j\rangle=\sum_k\lvert e_k\rangle\langle e_k\vert f_j\rangle=\sum_k P_{kj}\lvert e_k\rangle
    Expand each new basis vector in the old basis: column jj of PP holds the E\mathcal E-coordinates of ∣fj⟩\lvert f_j\rangle.
  2. Step 2:
    (P†P)ij=∑kPki‾Pkj=∑k⟨fi∣ek⟩⟨ek∣fj⟩(P^\dagger P)_{ij}=\sum_k\overline{P_{ki}}P_{kj}=\sum_k\langle f_i\vert e_k\rangle\langle e_k\vert f_j\rangle
    Matrix product with (P†)ik=Pki‾=⟨ek∣fi⟩‾=⟨fi∣ek⟩(P^\dagger)_{ik}=\overline{P_{ki}}=\overline{\langle e_k\vert f_i\rangle}=\langle f_i\vert e_k\rangle.
  3. Step 3:
    =⟨fi∣fj⟩=δij=\langle f_i\vert f_j\rangle=\delta_{ij}
    Completeness ∑k∣ek⟩⟨ek∣=I\sum_k\lvert e_k\rangle\langle e_k\rvert=I and orthonormality of F\mathcal F; hence P†P=IP^\dagger P=I and PP is unitary.
  4. Step 4:
    ([A]F)ij=⟨fi∣A∣fj⟩=⟨fi∣ IAI ∣fj⟩([A]_{\mathcal F})_{ij}=\langle f_i\vert A\vert f_j\rangle=\langle f_i\vert\,I A I\,\vert f_j\rangle
    Insert identities on both sides of AA.
  5. Step 5:
    =∑k,l⟨fi∣ek⟩⟨ek∣A∣el⟩⟨el∣fj⟩=\sum_{k,l}\langle f_i\vert e_k\rangle\langle e_k\vert A\vert e_l\rangle\langle e_l\vert f_j\rangle
    Write each identity as the completeness relation of E\mathcal E.
  6. Step 6:
    =∑k,l(P†)ik ([A]E)kl Plj=(P†[A]EP)ij=\sum_{k,l}(P^\dagger)_{ik}\,([A]_{\mathcal E})_{kl}\,P_{lj}=(P^\dagger[A]_{\mathcal E}P)_{ij}
    Identify the three factors as matrix elements and apply the product rule twice.

∎

Derivation

Worked example: the Hadamard operator in the basis (∣+⟩,∣−⟩)(\lvert+\rangle,\lvert-\rangle)

  1. Step 1:
    P=(⟨0∣+⟩⟨0∣−⟩⟨1∣+⟩⟨1∣−⟩)=12(111−1)=HP=\begin{pmatrix}\langle0\vert+\rangle&\langle0\vert-\rangle\\\langle1\vert+\rangle&\langle1\vert-\rangle\end{pmatrix}=\frac1{\sqrt2}\begin{pmatrix}1&1\\1&-1\end{pmatrix}=H
    The change-of-basis matrix has the new basis vectors as columns; for the ±\pm basis it is HH itself.
  2. Step 2:
    [H]±=P†HP=H†HH[H]_{\pm}=P^\dagger H P=H^\dagger H H
    Apply the theorem with [A]E=H[A]_{\mathcal E}=H.
  3. Step 3:
    =H=H
    H†H=IH^\dagger H=I because HH is unitary (checked in the matrix block below).
  4. Step 4:
    ⟨+∣H∣+⟩=⟨+∣0⟩=12,⟨+∣H∣−⟩=⟨+∣1⟩=12\langle+\vert H\vert+\rangle=\langle+\vert0\rangle=\tfrac1{\sqrt2},\quad \langle+\vert H\vert-\rangle=\langle+\vert1\rangle=\tfrac1{\sqrt2}
    Direct check using H∣+⟩=∣0⟩H\lvert+\rangle=\lvert0\rangle and H∣−⟩=∣1⟩H\lvert-\rangle=\lvert1\rangle.
  5. Step 5:
    ⟨−∣H∣+⟩=⟨−∣0⟩=12,⟨−∣H∣−⟩=⟨−∣1⟩=−12\langle-\vert H\vert+\rangle=\langle-\vert0\rangle=\tfrac1{\sqrt2},\quad \langle-\vert H\vert-\rangle=\langle-\vert1\rangle=-\tfrac1{\sqrt2}
    Same computation for the second row; the four entries reproduce 12(111−1)\tfrac1{\sqrt2}\begin{pmatrix}1&1\\1&-1\end{pmatrix}.
  6. Step 6:
    [X]±=HXH=(100−1)=Z,[Z]±=HZH=X[X]_{\pm}=HXH=\begin{pmatrix}1&0\\0&-1\end{pmatrix}=Z,\qquad [Z]_{\pm}=HZH=X
    The same rule shows that XX is diagonal in the ±\pm basis (X∣±⟩=±∣±⟩X\lvert\pm\rangle=\pm\lvert\pm\rangle) and ZZ swaps ∣+⟩↔∣−⟩\lvert+\rangle\leftrightarrow\lvert-\rangle.

Result

[H]±=[H]01,[X]±=Z,[Z]±=X\boxed{[H]_{\pm}=[H]_{01},\qquad [X]_{\pm}=Z,\qquad [Z]_{\pm}=X}
H=12(111−1)H=\frac1{\sqrt2}\begin{pmatrix}1&1\\1&-1\end{pmatrix}
Hadamard H (also the change-of-basis matrix to the ± basis)2×2

Unitary verified: U†U=IU^\dagger U = I (max deviation 2.2e-16)

Corollary

The trace does not depend on the orthonormal basis

Define Tr A=∑iAii\mathrm{Tr}\,A=\sum_i A_{ii}. Then Tr(AB)=Tr(BA)\mathrm{Tr}(AB)=\mathrm{Tr}(BA) for all square A,BA,B, and consequently Tr [A]F=Tr [A]E\mathrm{Tr}\,[A]_{\mathcal F}=\mathrm{Tr}\,[A]_{\mathcal E} for any two orthonormal bases.

Proof (5 steps)
  1. Step 1:
    Tr(AB)=∑i(AB)ii=∑i∑kAikBki\mathrm{Tr}(AB)=\sum_i(AB)_{ii}=\sum_i\sum_k A_{ik}B_{ki}
    Definition of the trace and the product rule.
  2. Step 2:
    =∑k∑iBkiAik=∑k(BA)kk=Tr(BA)=\sum_k\sum_i B_{ki}A_{ik}=\sum_k(BA)_{kk}=\mathrm{Tr}(BA)
    Swap the finite sums and commute the scalar factors.
  3. Step 3:
    Tr [A]F=Tr(P†([A]EP))=Tr(([A]EP)P†)\mathrm{Tr}\,[A]_{\mathcal F}=\mathrm{Tr}\big(P^\dagger([A]_{\mathcal E}P)\big)=\mathrm{Tr}\big(([A]_{\mathcal E}P)P^\dagger\big)
    Change-of-basis theorem, then cyclicity with the two factors P†P^\dagger and [A]EP[A]_{\mathcal E}P.
  4. Step 4:
    (PP†)ij=∑k⟨ei∣fk⟩⟨fk∣ej⟩=⟨ei∣ej⟩=δij(PP^\dagger)_{ij}=\sum_k\langle e_i\vert f_k\rangle\langle f_k\vert e_j\rangle=\langle e_i\vert e_j\rangle=\delta_{ij}
    PP†=IPP^\dagger=I as well: (P†)kj=⟨ej∣fk⟩‾=⟨fk∣ej⟩(P^\dagger)_{kj}=\overline{\langle e_j\vert f_k\rangle}=\langle f_k\vert e_j\rangle, then completeness ∑k∣fk⟩⟨fk∣=I\sum_k\lvert f_k\rangle\langle f_k\rvert=I of the basis F\mathcal F and orthonormality of E\mathcal E. (The next lesson shows that P†P=IP^\dagger P=I implies PP†=IPP^\dagger=I for every square matrix.)
  5. Step 5:
    =Tr([A]EPP†)=Tr [A]E=\mathrm{Tr}\big([A]_{\mathcal E}PP^\dagger\big)=\mathrm{Tr}\,[A]_{\mathcal E}
    Associativity of the matrix product, then PP†=IPP^\dagger=I from the previous step.

∎

Quick check

What is the matrix of Pauli XX in the ordered basis (∣+⟩,∣−⟩)(\lvert+\rangle,\lvert-\rangle)?

Select one answer

Check it numerically. The following NumPy cell verifies the change-of-basis results of this lesson: [H]±=H[H]_\pm=H, [X]±=Z[X]_\pm=Z, the conjugate-transpose example, the basis independence of the trace and XZ=−iYXZ=-iY.

Pythonrunnable
import numpy as np

H = np.array([[1, 1], [1, -1]]) / np.sqrt(2)
X = np.array([[0, 1], [1, 0]])
Z = np.array([[1, 0], [0, -1]])
P = H  # columns are |+> and |->
print(np.allclose(P.conj().T @ H @ P, H))
print(np.allclose(P.conj().T @ X @ P, Z))
A = np.array([[1, 2j], [3, 4 - 1j]])
print(np.allclose(A.conj().T, [[1, 3], [-2j, 4 + 1j]]))
print(np.isclose(np.trace(P.conj().T @ A @ P), np.trace(A)))
print(np.allclose(X @ Z, -1j * np.array([[0, -1j], [1j, 0]])))

Expected output

True
True
True
True
True

References

  1. M. A. Nielsen and I. L. Chuang, Quantum Computation and Quantum Information, 10th anniversary ed., Cambridge University Press (2010), §2.1.2 (linear operators and matrices) and §2.1.6 (adjoints and Hermitian operators).
  2. S. Axler, Linear Algebra Done Right, 4th ed., Springer (2024), Chapters 3 and 7.linear.axler.net
  3. R. A. Horn and C. R. Johnson, Matrix Analysis, 2nd ed., Cambridge University Press (2013), Chapter 0, §0.4–0.10 (including change of basis in §0.10).

Hands-on labs

  • Hadamard in the ± basis

    1 step · auto-graded

    Represent the Hadamard operator in the ordered basis (∣+⟩,∣−⟩)(\lvert+\rangle,\lvert-\rangle) using matrix elements Aab=⟨a∣H∣b⟩A_{ab}=\langle a\rvert H\lvert b\rangle.

    Open lab