QuantumCore

Lesson 4 · 55 min · core

Dirac Bra–Ket Notation & Outer Products

Loading progress…

Kets as column vectors, bras as their conjugate transposes (the Riesz map), inner products as bra–ket brackets, outer products ∣a⟩⟨b∣\lvert a\rangle\langle b\rvert as matrices, rank-one projectors, the completeness relation ∑i∣i⟩⟨i∣=I\sum_i\lvert i\rangle\langle i\rvert=I and the resolution of any operator into matrix elements ⟨i∣A∣j⟩\langle i\vert A\vert j\rangle.

Prerequisites: Inner Products, Norms & Gram–Schmidt

Objectives and key results
  • Translate between kets and column vectors, and between bras and row vectors (conjugate transposes).

  • Compute outer products ∣a⟩⟨b∣\lvert a\rangle\langle b\rvert and their matrices (∣a⟩⟨b∣)ij=aibj‾(\lvert a\rangle\langle b\rvert)_{ij}=a_i\overline{b_j}.

  • Recognise and verify projectors P=∣ψ⟩⟨ψ∣P=\lvert\psi\rangle\langle\psi\rvert: P2=P=P†P^2=P=P^\dagger, Tr P=1\mathrm{Tr}\,P=1.

  • Use the completeness relation ∑i∣i⟩⟨i∣=I\sum_i\lvert i\rangle\langle i\rvert=I to insert resolutions of the identity and expand operators as A=∑ij⟨i∣A∣j⟩∣i⟩⟨j∣A=\sum_{ij}\langle i\vert A\vert j\rangle\lvert i\rangle\langle j\rvert.

definition · Bra of a ket
⟨ψ∣=(∣ψ⟩)†=(ψ1‾,…,ψn‾),⟨cψ∣=cˉ ⟨ψ∣\langle\psi\rvert=\bigl(\lvert\psi\rangle\bigr)^\dagger=(\overline{\psi_1},\dots,\overline{\psi_n}),\qquad \langle c\psi\rvert=\bar c\,\langle\psi\rvert
identity · Outer product action
(∣a⟩⟨b∣)∣c⟩=⟨b∣c⟩ ∣a⟩,(∣a⟩⟨b∣)ij=aibj‾\bigl(\lvert a\rangle\langle b\rvert\bigr)\lvert c\rangle=\langle b\vert c\rangle\,\lvert a\rangle,\qquad \bigl(\lvert a\rangle\langle b\rvert\bigr)_{ij}=a_i\overline{b_j}
theorem · Rank-one projector
P=∣ψ⟩⟨ψ∣, ∥ψ∥=1 ⇒ P2=P=P†,  Tr P=1P=\lvert\psi\rangle\langle\psi\rvert,\ \lVert\psi\rVert=1\ \Rightarrow\ P^2=P=P^\dagger,\ \ \mathrm{Tr}\,P=1
identity · Completeness relation
∑i∣i⟩⟨i∣=I\sum_{i}\lvert i\rangle\langle i\rvert=I
identity · Operator resolution
A=∑i,j⟨i∣A∣j⟩ ∣i⟩⟨j∣,Aij=⟨i∣A∣j⟩A=\sum_{i,j}\langle i\vert A\vert j\rangle\,\lvert i\rangle\langle j\rvert,\qquad A_{ij}=\langle i\vert A\vert j\rangle

Kets, bras and brackets#

Paul Dirac introduced a notation in which the type of every object is visible at a glance. A ket ∣ψ⟩\lvert\psi\rangle is a vector of the state space, which for us is a column in Cn\mathbb{C}^n. A bra ⟨ϕ∣\langle\phi\rvert is the conjugate-transposed row. Putting a bra next to a ket closes the bracket and produces a number, the inner product ⟨ϕ∣ψ⟩\langle\phi\vert\psi\rangle ("bra-c-ket"). Putting a ket next to a bra, ∣a⟩⟨b∣\lvert a\rangle\langle b\rvert, leaves the bracket open and produces an operator. With these two rules, long calculations become mechanical: juxtapose symbols, and whenever a ⟨⋅∣\langle\cdot\rvert meets a ∣⋅⟩\lvert\cdot\rangle collapse them into a complex number.

The label inside the ket is just a name. For a qubit, ∣0⟩=(1,0)T\lvert0\rangle=(1,0)^T and ∣1⟩=(0,1)T\lvert1\rangle=(0,1)^T are the computational basis vectors; ∣+⟩\lvert+\rangle, ∣−⟩\lvert-\rangle, ∣+i⟩\lvert{+i}\rangle, ∣−i⟩\lvert{-i}\rangle are the vectors met in the previous lessons, and for several qubits ∣q0q1⋯qn−1⟩\lvert q_0q_1\cdots q_{n-1}\rangle names the computational basis vector with index k=∑jqj2n−1−jk=\sum_jq_j2^{n-1-j}.

Definition

Ket and bra

For ∣ψ⟩=(ψ1,…,ψn)T∈Cn\lvert\psi\rangle=(\psi_1,\dots,\psi_n)^T\in\mathbb{C}^n the corresponding bra is the row vector ⟨ψ∣=(∣ψ⟩)†=(ψ1‾,…,ψn‾)\langle\psi\rvert=(\lvert\psi\rangle)^\dagger=(\overline{\psi_1},\dots,\overline{\psi_n}). As a function, ⟨ψ∣\langle\psi\rvert sends a ket ∣ϕ⟩\lvert\phi\rangle to the number ⟨ψ∣ϕ⟩=∑iψi‾ϕi\langle\psi\vert\phi\rangle=\sum_i\overline{\psi_i}\phi_i, which is precisely the inner product of the previous lesson written as a row times a column.

Theorem

Riesz representation: every linear functional is a bra

Let f:Cn→Cf:\mathbb{C}^n\to\mathbb{C} be linear. There is exactly one ∣ϕ⟩∈Cn\lvert\phi\rangle\in\mathbb{C}^n with f(∣v⟩)=⟨ϕ∣v⟩f(\lvert v\rangle)=\langle\phi\vert v\rangle for all ∣v⟩\lvert v\rangle; its entries are ϕi=f(∣ei⟩)‾\phi_i=\overline{f(\lvert e_i\rangle)}. Hence bras are exactly the linear functionals (the dual space), and the map ∣ϕ⟩↦⟨ϕ∣\lvert\phi\rangle\mapsto\langle\phi\rvert is a bijection.

Proof (5 steps)
  1. Step 1:
    ∣v⟩=∑i=1nvi∣ei⟩ ⇒ f(∣v⟩)=∑i=1nvi f(∣ei⟩)\lvert v\rangle=\sum_{i=1}^{n}v_i\lvert e_i\rangle\ \Rightarrow\ f(\lvert v\rangle)=\sum_{i=1}^{n}v_i\,f(\lvert e_i\rangle)
    Expand vv in the standard basis and use linearity of ff.
  2. Step 2:
    ϕi:=f(∣ei⟩)‾ ⇒ f(∣ei⟩)=ϕi‾\phi_i:=\overline{f(\lvert e_i\rangle)}\ \Rightarrow\ f(\lvert e_i\rangle)=\overline{\phi_i}
    Define ϕ\phi entry by entry; conjugating twice returns the original number.
  3. Step 3:
    f(∣v⟩)=∑i=1nϕi‾ vi=⟨ϕ∣v⟩f(\lvert v\rangle)=\sum_{i=1}^{n}\overline{\phi_i}\,v_i=\langle\phi\vert v\rangle
    Substitute; this is the definition of the inner product. Existence is proved.
  4. Step 4:
    ⟨ϕ∣v⟩=⟨ϕ′∣v⟩ ∀v ⇒ ⟨ϕ−ϕ′∣v⟩=0 ∀v\langle\phi\vert v\rangle=\langle\phi'\vert v\rangle\ \forall v\ \Rightarrow\ \langle\phi-\phi'\vert v\rangle=0\ \forall v
    Uniqueness: suppose two vectors represent ff; subtract using antilinearity in the first slot.
  5. Step 5:
    v=ϕ−ϕ′: ∥ϕ−ϕ′∥2=0 ⇒ ϕ=ϕ′v=\phi-\phi':\ \lVert\phi-\phi'\rVert^2=0\ \Rightarrow\ \phi=\phi'
    Choose v=ϕ−ϕ′v=\phi-\phi' and use positive-definiteness.

∎

Derivation

The ket-to-bra map is antilinear: ⟨cψ∣=cˉ⟨ψ∣\langle c\psi\rvert=\bar c\langle\psi\rvert

  1. Step 1:
    ∣cψ⟩:=c∣ψ⟩=(cψ1,…,cψn)T\lvert c\psi\rangle:=c\lvert\psi\rangle=(c\psi_1,\dots,c\psi_n)^T
    Scalar multiplication of a ket is entry-wise.
  2. Step 2:
    ⟨cψ∣=(c∣ψ⟩)†=(cψ1‾,…,cψn‾)\langle c\psi\rvert=\bigl(c\lvert\psi\rangle\bigr)^\dagger=(\overline{c\psi_1},\dots,\overline{c\psi_n})
    Definition of the bra as conjugate transpose.
  3. Step 3:
    =(cˉ ψ1‾,…,cˉ ψn‾)=cˉ ⟨ψ∣=(\bar c\,\overline{\psi_1},\dots,\bar c\,\overline{\psi_n})=\bar c\,\langle\psi\rvert
    Conjugation respects products, cψi‾=cˉ ψi‾\overline{c\psi_i}=\bar c\,\overline{\psi_i}.
  4. Step 4:
    (α∣ψ⟩+β∣ϕ⟩)†=αˉ⟨ψ∣+βˉ⟨ϕ∣\bigl(\alpha\lvert\psi\rangle+\beta\lvert\phi\rangle\bigr)^\dagger=\bar\alpha\langle\psi\rvert+\bar\beta\langle\phi\rvert
    Combine with additivity of the conjugate transpose: sums go to sums, scalars get conjugated.

Worked example. Let ∣ψ⟩=13∣0⟩+1+i3∣1⟩=13(1, 1+i)T\lvert\psi\rangle=\tfrac{1}{\sqrt3}\lvert0\rangle+\tfrac{1+i}{\sqrt3}\lvert1\rangle=\tfrac1{\sqrt3}(1,\ 1+i)^T. It is normalised because 13+∣1+i∣23=13+23=1\tfrac13+\tfrac{\lvert1+i\rvert^2}{3}=\tfrac13+\tfrac23=1. Its bra is

⟨ψ∣=13⟨0∣+1−i3⟨1∣=13(1, 1−i).\langle\psi\rvert=\tfrac{1}{\sqrt3}\langle0\rvert+\tfrac{1-i}{\sqrt3}\langle1\rvert=\tfrac{1}{\sqrt3}\bigl(1,\ 1-i\bigr).

The amplitude of ∣1⟩\lvert1\rangle is ⟨1∣ψ⟩=1+i3\langle1\vert\psi\rangle=\tfrac{1+i}{\sqrt3}, while ⟨ψ∣1⟩=1−i3\langle\psi\vert1\rangle=\tfrac{1-i}{\sqrt3} is its conjugate. The overlap with ∣+⟩\lvert+\rangle is ⟨+∣ψ⟩=12⋅13(1+(1+i))=2+i6\langle+\vert\psi\rangle=\tfrac{1}{\sqrt2}\cdot\tfrac{1}{\sqrt3}\bigl(1+(1+i)\bigr)=\tfrac{2+i}{\sqrt6}, so measuring ∣ψ⟩\lvert\psi\rangle in the ±\pm basis gives ++ with probability ∣2+i∣26=56\tfrac{\lvert2+i\rvert^2}{6}=\tfrac56.

Outer products#

Definition

Outer product

For kets ∣a⟩∈Cm\lvert a\rangle\in\mathbb{C}^m and ∣b⟩∈Cn\lvert b\rangle\in\mathbb{C}^n the outer product ∣a⟩⟨b∣\lvert a\rangle\langle b\rvert is the linear map Cn→Cm\mathbb{C}^n\to\mathbb{C}^m defined by ∣c⟩↦∣a⟩⟨b∣c⟩=⟨b∣c⟩∣a⟩\lvert c\rangle\mapsto\lvert a\rangle\langle b\vert c\rangle=\langle b\vert c\rangle\lvert a\rangle. As a matrix it is the column ∣a⟩\lvert a\rangle times the row ⟨b∣\langle b\rvert, an m×nm\times n matrix of rank one (when a,b≠0a,b\ne0).

Proposition

Action and matrix of an outer product

(∣a⟩⟨b∣)∣c⟩=⟨b∣c⟩ ∣a⟩(\lvert a\rangle\langle b\rvert)\lvert c\rangle=\langle b\vert c\rangle\,\lvert a\rangle, and the matrix entries are (∣a⟩⟨b∣)ij=aibj‾(\lvert a\rangle\langle b\rvert)_{ij}=a_i\overline{b_j}.

Proof (4 steps)
  1. Step 1:
    (∣a⟩⟨b∣)∣c⟩=∣a⟩(⟨b∣ ∣c⟩)\bigl(\lvert a\rangle\langle b\rvert\bigr)\lvert c\rangle=\lvert a\rangle\bigl(\langle b\rvert\,\lvert c\rangle\bigr)
    Matrix multiplication (column times row times column) is associative.
  2. Step 2:
    =∣a⟩ ⟨b∣c⟩=⟨b∣c⟩ ∣a⟩=\lvert a\rangle\,\langle b\vert c\rangle=\langle b\vert c\rangle\,\lvert a\rangle
    A row times a column is the 1×11\times1 matrix ⟨b∣c⟩\langle b\vert c\rangle, a scalar, which commutes with the vector.
  3. Step 3:
    (∣a⟩⟨b∣)ij=∑k=11(∣a⟩)ik(⟨b∣)kj\bigl(\lvert a\rangle\langle b\rvert\bigr)_{ij}=\sum_{k=1}^{1}(\lvert a\rangle)_{ik}(\langle b\rvert)_{kj}
    Product of an m×1m\times1 matrix and a 1×n1\times n matrix: the inner index runs over a single value.
  4. Step 4:
    =ai bj‾=a_i\,\overline{b_j}
    The column has entries aia_i and the bra has entries bj‾\overline{b_j}.

∎

Worked examples. The four outer products of computational basis vectors are the matrix units:

∣0⟩⟨0∣=(1000),∣0⟩⟨1∣=(0100),∣1⟩⟨0∣=(0010),∣1⟩⟨1∣=(0001).\lvert0\rangle\langle0\rvert=\begin{pmatrix}1&0\\0&0\end{pmatrix},\quad \lvert0\rangle\langle1\rvert=\begin{pmatrix}0&1\\0&0\end{pmatrix},\quad \lvert1\rangle\langle0\rvert=\begin{pmatrix}0&0\\1&0\end{pmatrix},\quad \lvert1\rangle\langle1\rvert=\begin{pmatrix}0&0\\0&1\end{pmatrix}.

Adding them gives the Pauli operators in Dirac form: X=∣0⟩⟨1∣+∣1⟩⟨0∣X=\lvert0\rangle\langle1\rvert+\lvert1\rangle\langle0\rvert (it maps ∣1⟩↦∣0⟩\lvert1\rangle\mapsto\lvert0\rangle and ∣0⟩↦∣1⟩\lvert0\rangle\mapsto\lvert1\rangle), Z=∣0⟩⟨0∣−∣1⟩⟨1∣Z=\lvert0\rangle\langle0\rvert-\lvert1\rangle\langle1\rvert and Y=−i∣0⟩⟨1∣+i∣1⟩⟨0∣Y=-i\lvert0\rangle\langle1\rvert+i\lvert1\rangle\langle0\rvert. For example X∣0⟩=∣0⟩⟨1∣0⟩+∣1⟩⟨0∣0⟩=0+∣1⟩X\lvert0\rangle=\lvert0\rangle\langle1\vert0\rangle+\lvert1\rangle\langle0\vert0\rangle=0+\lvert1\rangle.

A complex example: with ∣a⟩=(1, i)T\lvert a\rangle=(1,\ i)^T and ∣b⟩=(2, 1+i)T\lvert b\rangle=(2,\ 1+i)^T the rule aibj‾a_i\overline{b_j} gives

∣a⟩⟨b∣=(1⋅21⋅(1−i)i⋅2i(1−i))=(21−i2i1+i),\lvert a\rangle\langle b\rvert=\begin{pmatrix}1\cdot2&1\cdot(1-i)\\ i\cdot2&i(1-i)\end{pmatrix}=\begin{pmatrix}2&1-i\\2i&1+i\end{pmatrix},

and applying it to ∣c⟩=(1, 0)T\lvert c\rangle=(1,\ 0)^T yields the first column (2, 2i)T=2∣a⟩=⟨b∣c⟩∣a⟩(2,\ 2i)^T=2\lvert a\rangle=\langle b\vert c\rangle\lvert a\rangle, since ⟨b∣c⟩=2ˉ⋅1=2\langle b\vert c\rangle=\bar2\cdot1=2.

Projectors#

Theorem

Rank-one projectors

If ∥ψ∥=1\lVert\psi\rVert=1, the operator P=∣ψ⟩⟨ψ∣P=\lvert\psi\rangle\langle\psi\rvert satisfies P2=PP^2=P (idempotent), P†=PP^\dagger=P (Hermitian) and Tr P=1\mathrm{Tr}\,P=1. It maps every ∣v⟩\lvert v\rangle to its component ⟨ψ∣v⟩∣ψ⟩\langle\psi\vert v\rangle\lvert\psi\rangle along ∣ψ⟩\lvert\psi\rangle.

Proof (5 steps)
  1. Step 1:
    P2=∣ψ⟩⟨ψ∣ ∣ψ⟩⟨ψ∣=∣ψ⟩ ⟨ψ∣ψ⟩ ⟨ψ∣P^2=\lvert\psi\rangle\langle\psi\rvert\,\lvert\psi\rangle\langle\psi\rvert=\lvert\psi\rangle\,\langle\psi\vert\psi\rangle\,\langle\psi\rvert
    Associativity: the middle bra and ket close into a bracket.
  2. Step 2:
    =∥ψ∥2 ∣ψ⟩⟨ψ∣=P=\lVert\psi\rVert^2\,\lvert\psi\rangle\langle\psi\rvert=P
    ⟨ψ∣ψ⟩=∥ψ∥2=1\langle\psi\vert\psi\rangle=\lVert\psi\rVert^2=1.
  3. Step 3:
    (P†)ij=Pji‾=ψjψi‾‾=ψiψj‾=Pij\bigl(P^\dagger\bigr)_{ij}=\overline{P_{ji}}=\overline{\psi_j\overline{\psi_i}}=\psi_i\overline{\psi_j}=P_{ij}
    The adjoint is the conjugate transpose; use the entry formula Pij=ψiψj‾P_{ij}=\psi_i\overline{\psi_j} from the outer-product proposition.
  4. Step 4:
    Tr P=∑iPii=∑iψiψi‾=∑i∣ψi∣2=1\mathrm{Tr}\,P=\sum_{i}P_{ii}=\sum_i\psi_i\overline{\psi_i}=\sum_i\lvert\psi_i\rvert^2=1
    The trace is the sum of the diagonal entries; each is a modulus squared; normalisation.
  5. Step 5:
    P∣v⟩=⟨ψ∣v⟩ ∣ψ⟩P\lvert v\rangle=\langle\psi\vert v\rangle\,\lvert\psi\rangle
    Outer-product action with a=b=ψa=b=\psi.

∎

Worked example. For ∣+⟩=12(1,1)T\lvert+\rangle=\tfrac1{\sqrt2}(1,1)^T the rule ψiψj‾\psi_i\overline{\psi_j} gives P+=∣+⟩⟨+∣=12(1111)P_+=\lvert+\rangle\langle+\rvert=\tfrac12\begin{pmatrix}1&1\\1&1\end{pmatrix}. Squaring, P+2=14(2222)=P+P_+^2=\tfrac14\begin{pmatrix}2&2\\2&2\end{pmatrix}=P_+, and Tr P+=12+12=1\mathrm{Tr}\,P_+=\tfrac12+\tfrac12=1. Applied to ∣0⟩\lvert0\rangle it returns ⟨+∣0⟩∣+⟩=12∣+⟩\langle+\vert0\rangle\lvert+\rangle=\tfrac{1}{\sqrt2}\lvert+\rangle, whose squared length 12\tfrac12 is the probability of the outcome ++ when ∣0⟩\lvert0\rangle is measured in the ±\pm basis. In general ∥P∣v⟩∥2=∣⟨ψ∣v⟩∣2=⟨v∣P∣v⟩\lVert P\lvert v\rangle\rVert^2=\lvert\langle\psi\vert v\rangle\rvert^2=\langle v\vert P\vert v\rangle, which is how the Born rule will be written in the measurement postulate.

For the circular state ∣+i⟩=12(1, i)T\lvert{+i}\rangle=\tfrac1{\sqrt2}(1,\ i)^T the projector has complex off-diagonal entries: P01=ψ0ψ1‾=12⋅−i2=−i2P_{01}=\psi_0\overline{\psi_1}=\tfrac1{\sqrt2}\cdot\tfrac{-i}{\sqrt2}=-\tfrac i2 and P10=i2P_{10}=\tfrac{i}{2}, so the matrix is Hermitian but not symmetric. Writing +i2+\tfrac i2 in the top-right corner is the classic symptom of forgetting to conjugate the bra.

∣+⟩⟨+∣=12(1111),P+2=P+=P+†,  Tr P+=1\lvert+\rangle\langle+\rvert=\frac12\begin{pmatrix}1&1\\1&1\end{pmatrix},\qquad P_+^2=P_+=P_+^\dagger,\ \ \mathrm{Tr}\,P_+=1
Projector onto |+> : P+ = |+><+|2×2

Completeness and operator resolution#

Theorem

Completeness relation (resolution of the identity)

For any orthonormal basis ∣1⟩,…,∣n⟩\lvert1\rangle,\dots,\lvert n\rangle of Cn\mathbb{C}^n: ∑i=1n∣i⟩⟨i∣=I\sum_{i=1}^n\lvert i\rangle\langle i\rvert=I.

Proof (4 steps)
  1. Step 1:
    ∣v⟩=∑i=1n⟨i∣v⟩ ∣i⟩∀ ∣v⟩\lvert v\rangle=\sum_{i=1}^{n}\langle i\vert v\rangle\,\lvert i\rangle\qquad\forall\,\lvert v\rangle
    Expansion in an orthonormal basis (Parseval theorem of the previous lesson).
  2. Step 2:
    =∑i=1n∣i⟩⟨i∣v⟩=(∑i=1n∣i⟩⟨i∣)∣v⟩=\sum_{i=1}^{n}\lvert i\rangle\langle i\vert v\rangle=\Bigl(\sum_{i=1}^{n}\lvert i\rangle\langle i\rvert\Bigr)\lvert v\rangle
    The scalar ⟨i∣v⟩\langle i\vert v\rangle may be written on either side; then factor out ∣v⟩\lvert v\rangle by linearity of matrix multiplication.
  3. Step 3:
    (∑i=1n∣i⟩⟨i∣)∣v⟩=I∣v⟩∀ ∣v⟩\Bigl(\sum_{i=1}^{n}\lvert i\rangle\langle i\rvert\Bigr)\lvert v\rangle=I\lvert v\rangle\quad\forall\,\lvert v\rangle
    The operator in brackets acts as the identity on every vector.
  4. Step 4:
    ⇒ ∑i=1n∣i⟩⟨i∣=I\Rightarrow\ \sum_{i=1}^{n}\lvert i\rangle\langle i\rvert=I
    Two matrices that agree on every vector (in particular on each standard basis vector, which reads off every column) are equal.

∎

Worked example. In the computational basis, ∣0⟩⟨0∣+∣1⟩⟨1∣=diag(1,0)+diag(0,1)=I\lvert0\rangle\langle0\rvert+\lvert1\rangle\langle1\rvert=\mathrm{diag}(1,0)+\mathrm{diag}(0,1)=I. In the ±\pm basis, ∣−⟩⟨−∣=12(1−1−11)\lvert-\rangle\langle-\rvert=\tfrac12\begin{pmatrix}1&-1\\-1&1\end{pmatrix} and

∣+⟩⟨+∣+∣−⟩⟨−∣=12(1111)+12(1−1−11)=12(2002)=I.\lvert+\rangle\langle+\rvert+\lvert-\rangle\langle-\rvert=\frac12\begin{pmatrix}1&1\\1&1\end{pmatrix}+\frac12\begin{pmatrix}1&-1\\-1&1\end{pmatrix}=\frac12\begin{pmatrix}2&0\\0&2\end{pmatrix}=I .

The completeness relation is the single most useful trick in Dirac notation: you may insert I=∑i∣i⟩⟨i∣I=\sum_i\lvert i\rangle\langle i\rvert anywhere in an expression. Inserting it between a bra and a ket gives ⟨ϕ∣ψ⟩=∑i⟨ϕ∣i⟩⟨i∣ψ⟩=∑iϕi‾ψi\langle\phi\vert\psi\rangle=\sum_i\langle\phi\vert i\rangle\langle i\vert\psi\rangle=\sum_i\overline{\phi_i}\psi_i, recovering the component formula for the inner product.

Derivation

Every operator is a sum of its matrix elements times outer products

  1. Step 1:
    A=I A IA=I\,A\,I
    Multiplying by the identity on both sides changes nothing.
  2. Step 2:
    =(∑i∣i⟩⟨i∣)A(∑j∣j⟩⟨j∣)=\Bigl(\sum_{i}\lvert i\rangle\langle i\rvert\Bigr)A\Bigl(\sum_{j}\lvert j\rangle\langle j\rvert\Bigr)
    Insert the completeness relation twice, with independent summation indices.
  3. Step 3:
    =∑i,j∣i⟩ (⟨i∣A∣j⟩) ⟨j∣=\sum_{i,j}\lvert i\rangle\,\bigl(\langle i\rvert A\lvert j\rangle\bigr)\,\langle j\rvert
    Distribute the sums (matrix multiplication is bilinear) and regroup by associativity.
  4. Step 4:
    =∑i,j⟨i∣A∣j⟩ ∣i⟩⟨j∣=\sum_{i,j}\langle i\vert A\vert j\rangle\,\lvert i\rangle\langle j\rvert
    ⟨i∣A∣j⟩\langle i\vert A\vert j\rangle is a 1×11\times1 matrix, i.e. a scalar, so it can be moved to the front.
  5. Step 5:
    ⟨i∣A∣j⟩=ei†A ej=Aij\langle i\vert A\vert j\rangle=e_i^\dagger A\,e_j=A_{ij}
    In the standard basis AejA e_j is column jj of AA and ei†e_i^\dagger picks its ii-th entry; so the matrix elements are the ordinary entries, and the sum is the matrix written as a combination of matrix units.

Worked example (matrix elements in another basis). Compute the matrix elements of X=(0110)X=\begin{pmatrix}0&1\\1&0\end{pmatrix} in the ±\pm basis. Since X∣+⟩=12(1,1)T=∣+⟩X\lvert+\rangle=\tfrac1{\sqrt2}(1,1)^T=\lvert+\rangle and X∣−⟩=12(−1,1)T=−∣−⟩X\lvert-\rangle=\tfrac1{\sqrt2}(-1,1)^T=-\lvert-\rangle, we get ⟨+∣X∣+⟩=1\langle+\vert X\vert+\rangle=1, ⟨−∣X∣−⟩=−1\langle-\vert X\vert-\rangle=-1, and ⟨+∣X∣−⟩=−⟨+∣−⟩=0=⟨−∣X∣+⟩\langle+\vert X\vert-\rangle=-\langle+\vert-\rangle=0=\langle-\vert X\vert+\rangle. The resolution formula therefore gives

X=∣+⟩⟨+∣−∣−⟩⟨−∣=12(1111)−12(1−1−11)=(0110).X=\lvert+\rangle\langle+\rvert-\lvert-\rangle\langle-\rvert=\frac12\begin{pmatrix}1&1\\1&1\end{pmatrix}-\frac12\begin{pmatrix}1&-1\\-1&1\end{pmatrix}=\begin{pmatrix}0&1\\1&0\end{pmatrix}.

In the ±\pm basis XX is diagonal, exactly as Z=∣0⟩⟨0∣−∣1⟩⟨1∣Z=\lvert0\rangle\langle0\rvert-\lvert1\rangle\langle1\rvert is diagonal in the computational basis. This is a first glimpse of the spectral theorem studied in the next module: an operator written as a weighted sum of projectors onto an orthonormal basis.

Worked example (an expectation value, symbolically). Take ∣ψ⟩=13∣0⟩+1+i3∣1⟩\lvert\psi\rangle=\tfrac1{\sqrt3}\lvert0\rangle+\tfrac{1+i}{\sqrt3}\lvert1\rangle from the first section and Z=∣0⟩⟨0∣−∣1⟩⟨1∣Z=\lvert0\rangle\langle0\rvert-\lvert1\rangle\langle1\rvert. Sandwiching ZZ between the bra and the ket and closing every bracket,

⟨ψ∣Z∣ψ⟩=⟨ψ∣0⟩⟨0∣ψ⟩−⟨ψ∣1⟩⟨1∣ψ⟩=∣⟨0∣ψ⟩∣2−∣⟨1∣ψ⟩∣2=13−23=−13.\langle\psi\vert Z\vert\psi\rangle=\langle\psi\vert0\rangle\langle0\vert\psi\rangle-\langle\psi\vert1\rangle\langle1\vert\psi\rangle=\lvert\langle0\vert\psi\rangle\rvert^2-\lvert\langle1\vert\psi\rangle\rvert^2=\frac13-\frac23=-\frac13 .

We used ⟨ψ∣i⟩=⟨i∣ψ⟩‾\langle\psi\vert i\rangle=\overline{\langle i\vert\psi\rangle}, so each term is a modulus squared. No matrix was ever written down: the calculation is pure symbol manipulation, and it would read the same in C1024\mathbb{C}^{1024}. This is the practical reason for Dirac notation. Matrices are best for small numeric checks and for code; bra–ket algebra is best for proofs and for reasoning about structure. Throughout the curriculum you should be able to move freely between the two, and the translator widget above exists precisely to train that reflex.

TypeScriptrunnable
import { c, cconj, cmul, type Complex } from '@/lib/quantum-simulator/complex';

/** Outer product |a><b| as a dense matrix: entry (i, j) = a_i * conj(b_j). */
function outer(a: Complex[], b: Complex[]): Complex[][] {
  return a.map((ai) => b.map((bj) => cmul(ai, cconj(bj))));
}

const s = Math.SQRT1_2;
const plusI = [c(s), c(0, s)]; // |+i> = (|0> + i|1>)/sqrt(2)
const P = outer(plusI, plusI);
// P = [[0.5, -0.5i], [0.5i, 0.5]] : Hermitian, idempotent, trace 1
console.log(P.map((row) => row.map((z) => z.re.toFixed(2) + (z.im < 0 ? '-' : '+') + Math.abs(z.im).toFixed(2) + 'i').join('  ')).join('; '));

Expected output

0.50+0.00i  0.00-0.50i; 0.00+0.50i  0.50+0.00i

Check your understanding#

Quick check

If ∣ψ⟩=α∣0⟩+β∣1⟩\lvert\psi\rangle=\alpha\lvert0\rangle+\beta\lvert1\rangle, which row vector is ⟨ψ∣\langle\psi\rvert?

Select one answer

Quick check

Evaluate the matrix element ⟨1∣X∣0⟩\langle1\vert X\vert0\rangle for X=∣0⟩⟨1∣+∣1⟩⟨0∣X=\lvert0\rangle\langle1\rvert+\lvert1\rangle\langle0\rvert.

tolerance ±0.001

Quick check

What is Tr(∣ψ⟩⟨ψ∣)\mathrm{Tr}\bigl(\lvert\psi\rangle\langle\psi\rvert\bigr) for ∣ψ⟩=13(1, 1+i)T\lvert\psi\rangle=\tfrac{1}{\sqrt3}(1,\ 1+i)^T?

tolerance ±0.001

Quick check

Which matrix is ∣0⟩⟨1∣\lvert0\rangle\langle1\rvert?

Select one answer

References

  1. M. A. Nielsen, I. L. Chuang, Quantum Computation and Quantum Information, 10th anniversary ed., Cambridge University Press (2010), §2.1.4 (outer products, completeness relation) and §2.1.2 (matrix representations).
  2. P. A. M. Dirac, The Principles of Quantum Mechanics, 4th ed., Oxford University Press (1958), Ch. II (bra and ket vectors).
  3. J. J. Sakurai, J. Napolitano, Modern Quantum Mechanics, 3rd ed., Cambridge University Press (2020), §1.2–1.3 (kets, bras, operators, base kets and matrix representations).
  4. S. Axler, Linear Algebra Done Right, 4th ed., Springer (2024), §6B (Riesz representation theorem) and Ch. 3 (matrices of linear maps).linear.axler.net

Hands-on labs

  • Build a rank-one projector

    1 step · auto-graded

    Write the matrix of P=∣+i⟩⟨+i∣P=\lvert{+i}\rangle\langle{+i}\rvert using (∣a⟩⟨b∣)jk=ajbk‾(\lvert a\rangle\langle b\rvert)_{jk}=a_j\overline{b_k}.

    Open lab