Dirac Notation

3.5 hours ~5 min read

Dirac Notation

Dirac's bra–ket notation is the language of the entire field. It is not new mathematics — it is a brilliant repackaging of the inner product spaces you just built, designed so that the algebra reads like sentences and the bookkeeping does itself. Every later lesson, every paper, and the Braket SDK's mental model all speak this dialect. Master it now and the rest of the program reads fluently.

Learning Objectives

After this lesson you will be able to:

  1. Translate fluently between column-vector/matrix notation and bra–ket notation.
  2. Interpret a bra ϕ\langle\phi| as a linear functional (the dual of a ket) via the Riesz lemma.
  3. Compute inner products ϕψ\langle\phi|\psi\rangle and outer products ψϕ|\psi\rangle\langle\phi|.
  4. Apply the completeness relation (resolution of the identity) to expand states and operators.
  5. Read and write matrix elements iAj\langle i|A|j\rangle.

Intuition

Write a state vector as a ket ψ|\psi\rangle. Its conjugate-transpose — the object that "eats a ket and returns a number via the inner product" — is the bra ψ\langle\psi|. Put a bra next to a ket and the notation literally forms a bra(c)ket ϕψ\langle\phi|\psi\rangle: a number, the overlap. Put them the other way, ψϕ|\psi\rangle\langle\phi|, and you get an operator (a matrix). The genius is that the symbols snap together exactly the way the math allows, so manipulations become almost mechanical:

ϕrow  ψcolumn=number,ψcolumn  ϕrow=matrix. \underbrace{\langle\phi|}_{\text{row}}\;\underbrace{|\psi\rangle}_{\text{column}} = \text{number}, \qquad \underbrace{|\psi\rangle}_{\text{column}}\;\underbrace{\langle\phi|}_{\text{row}} = \text{matrix}.

Theory

Kets

A ket ψ|\psi\rangle is just a vector in a Hilbert space H\mathcal{H} (for us Cn\mathbb{C}^n). In coordinates relative to the computational basis,

ψ=kckk    (c0c1cn1),ckC. |\psi\rangle = \sum_k c_k\,|k\rangle \;\longleftrightarrow\; \begin{pmatrix} c_0 \\ c_1 \\ \vdots \\ c_{n-1}\end{pmatrix}, \qquad c_k \in \mathbb{C}.

For a qubit, |0\rangle = \begin{psmallmatrix}1\\0\end{psmallmatrix}, |1\rangle = \begin{psmallmatrix}0\\1\end{psmallmatrix}. The labels inside the ket are mnemonic — |{\uparrow}\rangle, 0|0\rangle, ψ|\psi\rangle, 01|01\rangle are all just names for vectors.

The dual space and bras

The dual space H\mathcal{H}^* is the set of linear maps (functionals) f:HCf:\mathcal{H}\to\mathbb{C}. The Riesz representation theorem (finite-dimensional case) says every such ff is "take the inner product with some fixed vector ϕ\phi":

for each linear f  !ϕ such that f(ψ)=ϕψ  ψ. \text{for each linear } f \;\exists!\, |\phi\rangle \text{ such that } f(|\psi\rangle) = \langle\phi|\psi\rangle\ \ \forall|\psi\rangle.

We name this functional the bra ϕ\langle\phi|. So a bra is "the inner product, waiting for its second argument." In coordinates, if ϕ|\phi\rangle has components (dk)(d_k), then

ϕ=ϕ=(d0, d1, , dn1)(a row vector — conjugate transpose of the ket). \langle\phi| = |\phi\rangle^\dagger = \big(\overline{d_0},\ \overline{d_1},\ \dots,\ \overline{d_{n-1}}\big) \quad\text{(a row vector — conjugate transpose of the ket).}

The conjugation is the conjugate-linearity from 0.1.2: $\langle a\phi| = \overline{a},\langle\phi|,while, while |a\psi\rangle = a,|\psi\rangle$.

Inner product as a bracket

The inner product becomes the bracket

ϕψ=ϕ(ψ)=kdkck. \langle\phi|\psi\rangle = \langle\phi| \,\big(|\psi\rangle\big) = \sum_k \overline{d_k}\, c_k .

All the 0.1.2 facts restated: ψψ=ψ20\langle\psi|\psi\rangle = \||\psi\rangle\|^2 \ge 0; ϕψ=ψϕ\langle\phi|\psi\rangle = \overline{\langle\psi|\phi\rangle}; orthonormal basis ij=δij\langle i|j\rangle = \delta_{ij}; a normalized state has ψψ=1\langle\psi|\psi\rangle = 1.

Outer products are operators

Reverse the order: ψϕ|\psi\rangle\langle\phi| is (column)(row) = an n×nn\times n matrix, hence a linear operator. It acts on a ket by the associativity of the notation:

(ψϕ)χ=ψϕχnumber=ϕχψ. \big(|\psi\rangle\langle\phi|\big)\,|\chi\rangle = |\psi\rangle\,\underbrace{\langle\phi|\chi\rangle}_{\text{number}} = \langle\phi|\chi\rangle\,|\psi\rangle .

The most important case is a projector onto a normalized state: Pψ=ψψP_\psi = |\psi\rangle\langle\psi| satisfies Pψ2=PψP_\psi^2 = P_\psi (it projects, idempotently). Example for a qubit:

00=(10)(10)=(1000). |0\rangle\langle 0| = \begin{pmatrix}1\\0\end{pmatrix}\begin{pmatrix}1 & 0\end{pmatrix} = \begin{pmatrix}1 & 0\\0 & 0\end{pmatrix}.

The completeness relation (resolution of identity)

For any orthonormal basis {k}\{|k\rangle\},

 kkk=I  \boxed{\ \sum_k |k\rangle\langle k| = I\ }

This single identity is the most-used trick in the subject. Derivation: apply the left side to an arbitrary ψ|\psi\rangle: kkkψ=kkψk\sum_k |k\rangle\langle k|\psi\rangle = \sum_k \langle k|\psi\rangle\,|k\rangle, which is exactly the ONB expansion of ψ|\psi\rangle from 0.1.2 — i.e. ψ|\psi\rangle itself. Since it returns every ψ|\psi\rangle unchanged, the operator is II. ∎

You "insert a complete set of states" I=kkkI = \sum_k|k\rangle\langle k| anywhere to switch into a basis:

ϕψ=ϕIψ=kϕkkψ. \langle\phi|\psi\rangle = \langle\phi|\,I\,|\psi\rangle = \sum_k \langle\phi|k\rangle\langle k|\psi\rangle .

Matrix elements

The (i,j)(i,j) entry of an operator AA in the basis {k}\{|k\rangle\} is the matrix element

Aij=iAj. A_{ij} = \langle i|A|j\rangle .

Two completeness insertions reconstruct the whole operator from its matrix elements:

A=IAI=i,jiiAjj=i,jAijij. A = I A I = \sum_{i,j} |i\rangle\langle i|A|j\rangle\langle j| = \sum_{i,j} A_{ij}\,|i\rangle\langle j| .

So "AA as a matrix" and "A=ijAijijA = \sum_{ij} A_{ij}|i\rangle\langle j|" are the same statement.

Endianness reminder. For multi-qubit kets we use big-endian labels: q0q1|q_0 q_1\cdots\rangle with qubit 0 leftmost, matching Braket's bit-strings (see Appendix C). E.g. 01=01|01\rangle = |0\rangle\otimes|1\rangle — tensor products are formalized in 0.1.7.


Worked Examples

Example 1 — Brackets, bras, and a projector

Let ψ=12(0+i1)|\psi\rangle = \tfrac1{\sqrt2}(|0\rangle + i|1\rangle).

Bra: ψ=12(0i1)\langle\psi| = \tfrac1{\sqrt2}(\langle 0| - i\langle 1|) (note the sign flip from conjugation). Norm: $\langle\psi|\psi\rangle = \tfrac12(\langle0|0\rangle - i\langle0|1\rangle + i\langle1|0\rangle - i\cdot i\langle1|1\rangle) = \tfrac12(1 + 0 + 0 + 1) = 1$. ✓ Projector:

ψψ=12(0+i1)(0i1)=12(00i01+i10+11)=12(1ii1). |\psi\rangle\langle\psi| = \tfrac12(|0\rangle + i|1\rangle)(\langle0| - i\langle1|) = \tfrac12\big(|0\rangle\langle0| - i|0\rangle\langle1| + i|1\rangle\langle0| + |1\rangle\langle1|\big) = \tfrac12\begin{pmatrix}1 & -i\\ i & 1\end{pmatrix}.

Example 2 — Completeness in action

Compute +0\langle + | 0\rangle by inserting the computational-basis completeness I=00+11I = |0\rangle\langle0| + |1\rangle\langle1|:

+0=+(00+11)0=+000++110=121+120=12. \langle +|0\rangle = \langle +|\big(|0\rangle\langle0| + |1\rangle\langle1|\big)|0\rangle = \langle+|0\rangle\langle0|0\rangle + \langle+|1\rangle\langle1|0\rangle = \tfrac1{\sqrt2}\cdot 1 + \tfrac1{\sqrt2}\cdot 0 = \tfrac1{\sqrt2}.

(Trivial here, but the technique — insert II, split into known overlaps — is exactly how QFT and phase-estimation derivations proceed in Term 2.)


Hands-on (Python)

NumPy makes the bra/ket/outer correspondence literal.

import numpy as np

ket0 = np.array([[1], [0]], dtype=complex)   # column vector = ket |0>
ket1 = np.array([[0], [1]], dtype=complex)   # column vector = ket |1>

def bra(ket):
    """⟨ψ| = |ψ⟩† : conjugate transpose turns a column ket into a row bra."""
    return ket.conj().T

# Bracket ⟨0|1⟩ is a 1x1 matrix (a number):
print((bra(ket0) @ ket1).item())             # 0j   (orthogonal)

psi = (ket0 + 1j * ket1) / np.sqrt(2)
print((bra(psi) @ psi).item())               # (1+0j)  normalized

# Outer product |ψ⟩⟨ψ| is a 2x2 operator (projector):
P = psi @ bra(psi)
print(np.round(P, 3))
# [[0.5+0.j  0. -0.5j]
#  [0. +0.5j 0.5+0.j ]]
print(np.allclose(P @ P, P))                 # True: projectors are idempotent
# Completeness relation: sum_k |k><k| = I
basis = [ket0, ket1]
completeness = sum(k @ bra(k) for k in basis)
print(np.allclose(completeness, np.eye(2)))  # True

# Matrix element A_ij = <i|A|j>:
A = np.array([[1, 2], [3, 4]], dtype=complex)
A01 = (bra(ket0) @ A @ ket1).item()
print(A01)                                   # (2+0j)  -> the (0,1) entry

Many people work with 1-D arrays (np.array([1,0])) and rely on np.vdot/np.outer instead of explicit columns. Both are fine; we use explicit (n,1) columns here so @ mirrors the bra–ket algebra one-to-one. Pick one convention per project and stay consistent.


Exercises

E1 (easy). Write the bra corresponding to ψ=(2+i)03i1|\psi\rangle = (2+i)|0\rangle - 3i|1\rangle and compute ψψ\langle\psi|\psi\rangle.

Solution

ψ=(2i)0+3i1\langle\psi| = (2-i)\langle0| + 3i\langle1|. Then ψψ=2+i2+3i2=(4+1)+9=14\langle\psi|\psi\rangle = |2+i|^2 + |{-3i}|^2 = (4+1) + 9 = 14. (So ψ|\psi\rangle is not normalized; dividing by 14\sqrt{14} would normalize it.)

E2 (easy). Compute the outer product 01|0\rangle\langle 1| as a 2×22\times2 matrix and describe what operator it is.

Solution

$|0\rangle\langle1| = \begin{psmallmatrix}1\0\end{psmallmatrix}\begin{psmallmatrix}0 & 1\end{psmallmatrix} = \begin{psmallmatrix}0 & 1\ 0 & 0\end{psmallmatrix}.Itmaps. It maps |1\rangle \mapsto |0\rangle$ and 00|0\rangle\mapsto 0 — a "lowering"-type operator (it's the qubit σ\sigma_- -like map, not unitary).

E3 (medium). Using completeness kkk=I\sum_k|k\rangle\langle k| = I, prove that for any operator AA, Tr(A)=kkAk\operatorname{Tr}(A) = \sum_k \langle k|A|k\rangle is independent of the orthonormal basis chosen.

Solution

Let {k}\{|k\rangle\} and {m}\{|m'\rangle\} be two ONBs. Insert completeness of the primed basis: kkAk=kk(mmm)Ak\sum_k\langle k|A|k\rangle = \sum_k \langle k| \big(\sum_{m}|m'\rangle\langle m'|\big) A |k\rangle. Rearranging the scalars and using kkk=I\sum_k |k\rangle\langle k| = I again, =mmA(kkk)m=mmAm= \sum_m \langle m'|A\big(\sum_k|k\rangle\langle k|\big)|m'\rangle = \sum_m\langle m'|A|m'\rangle. So the trace is basis-independent. ∎

E4 (medium). Show (ψϕ)=ϕψ\big(|\psi\rangle\langle\phi|\big)^\dagger = |\phi\rangle\langle\psi|.

Solution

For matrices (AB)=BA(AB)^\dagger = B^\dagger A^\dagger. Here A=ψA = |\psi\rangle (column) and B=ϕB = \langle\phi| (row =ϕ= |\phi\rangle^\dagger). So $\big(|\psi\rangle\langle\phi|\big)^\dagger = \langle\phi|^\dagger |\psi\rangle^\dagger = |\phi\rangle\langle\psi|.(Henceprojectors. ∎ (Hence projectors |\psi\rangle\langle\psi|$ are Hermitian.)

E5 (hard). Let {uk}\{|u_k\rangle\} be an ONB. Prove the "trace trick" $\langle\phi|A|\psi\rangle = \operatorname{Tr}!\big(A,|\psi\rangle\langle\phi|\big)$, and use it to express an expectation value ψAψ\langle\psi|A|\psi\rangle as a trace.

Solution

$\operatorname{Tr}(A|\psi\rangle\langle\phi|) = \sum_k \langle u_k|A|\psi\rangle\langle\phi|u_k\rangle = \langle\phi|\Big(\sum_k |u_k\rangle\langle u_k|\Big)A|\psi\rangle = \langle\phi|A|\psi\rangle$, using completeness and reordering the scalar ϕuk\langle\phi|u_k\rangle. Setting ϕ=ψ\phi = \psi: ψAψ=Tr(Aψψ)=Tr(Aρ)\langle\psi|A|\psi\rangle = \operatorname{Tr}(A|\psi\rangle\langle\psi|) = \operatorname{Tr}(A\rho) with ρ=ψψ\rho = |\psi\rangle\langle\psi| — the density-matrix expectation formula previewed for Term 1.5. ∎


Checkpoint

  1. What is a bra, formally, and how does the Riesz theorem justify the notation?
  2. Why does forming ϕψ\langle\phi|\psi\rangle give a number but ψϕ|\psi\rangle\langle\phi| give an operator?
  3. State the completeness relation and explain the "insert the identity" technique.
  4. How do you read off the matrix element AijA_{ij} in bra–ket notation?
  5. Show in one line that ψψ|\psi\rangle\langle\psi| is a projector when ψψ=1\langle\psi|\psi\rangle=1.
Answers
  1. A bra ϕ\langle\phi| is the linear functional ψϕψ|\psi\rangle\mapsto\langle\phi|\psi\rangle; Riesz guarantees every linear functional has this form for a unique ϕ|\phi\rangle, so bras ↔ kets bijectively (via conjugate transpose).
  2. (row)(column) contracts all indices → scalar; (column)(row) leaves two free indices → matrix.
  3. kkk=I\sum_k|k\rangle\langle k| = I for any ONB; you may insert II in this form anywhere to expand in that basis without changing the expression.
  4. Aij=iAjA_{ij} = \langle i|A|j\rangle.
  5. (ψψ)2=ψψψψ=ψψ(|\psi\rangle\langle\psi|)^2 = |\psi\rangle\langle\psi|\psi\rangle\langle\psi| = |\psi\rangle\langle\psi| since ψψ=1\langle\psi|\psi\rangle = 1.

Further Reading

  • [NC] Nielsen & Chuang, §2.1.3–2.1.6 — the Dirac formalism, outer products, completeness.
  • [Sak] Sakurai & Napolitano, §1.2–1.3 — kets, bras, and operators, the physicist's introduction.
  • [Pre] Preskill, Ph219, Ch. 2.

← Prev: Inner Products & Norms · Up: Term 0 · Next: Linear Operators & Matrices

Ready to measure your state?

5 exercises · 10 checkpoint questions

Start the quiz