Lecture 2 · Dr Ittoop Puthoor & Dr Jonte Hance · about 60 min

Complex linear algebra

The toolkit for the rest of the module. Vectors and kets, matrices, complex numbers, Euler's formula and phase, built up from nothing.

How much help?
How well do you know this?
By the end you can
  • Read and write kets ∣ψ⟩\ket{\psi} and bras ⟨ψ∣\bra{\psi}, and compute ⟨a|b⟩\braket{a}{b}
  • Compute norms, dot products, traces, matrix sums and products
  • Explain why matrix multiplication is not commutative, and what an eigenvector is
  • Do arithmetic with complex numbers, including conjugate, modulus and division
  • Convert between a+bia + bi and polar form reiθre^{i\theta}

Builds on: Lecture 1

Why this lecture matters

Every later lecture is this maths in disguise. A qubit is a vector with two complex entries. A gate is a matrix. A measurement probability is the squared size of a complex number. If you are solid here, the rest of the module is mostly bookkeeping.

Vectors

A scalar is just a number. A vector has size and direction. In 3D you can write it as amounts along three unit directions ex,ey,eze_x, e_y, e_z:

v⃗=vxex+vyey+vzez=(vxvyvz).\vec v = v_x e_x + v_y e_y + v_z e_z = \begin{pmatrix} v_x \\ v_y \\ v_z\end{pmatrix}.

Dot product. Multiply matching entries and add them. It measures how much two vectors point the same way:

a⃗⋅b⃗=axbx+ayby+azbz.\vec a\cdot\vec b = a_xb_x + a_yb_y + a_zb_z.

Norm (length). ∥v⃗∥=v⃗⋅v⃗=vx2+vy2+vz2\|\vec v\| = \sqrt{\vec v\cdot\vec v} = \sqrt{v_x^2+v_y^2+v_z^2}. Dividing by it gives a unit vector (length 1) in the same direction: v^=v⃗/∥v⃗∥\hat v = \vec v/\|\vec v\|.

Kets and bras: the quantum notation

A bra times a ket is a row times a column, which gives one number: the inner product.

⟨a|b⟩=(aˉ1aˉ2)(b1b2)=aˉ1b1+aˉ2b2.\braket{a}{b} = \begin{pmatrix} \bar a_1 & \bar a_2\end{pmatrix}\begin{pmatrix} b_1 \\ b_2\end{pmatrix} = \bar a_1 b_1 + \bar a_2 b_2.

A ket times a bra is a column times a row, which gives a matrix:

∣a⟩⟨b∣=(a1bˉ1a1bˉ2a2bˉ1a2bˉ2).\ket{a}\bra{b} = \begin{pmatrix} a_1\bar b_1 & a_1\bar b_2 \\ a_2\bar b_1 & a_2\bar b_2\end{pmatrix}.

Matrices

A matrix is a grid of numbers. AijA_{ij} is the entry in row ii, column jj. An m×nm\times n matrix has mm rows and nn columns; a vector is an n×1n\times 1 matrix.

  • Adding: only same-size matrices, entry by entry.
  • Scalar times matrix: multiply every entry.
  • Trace of a square matrix: add the diagonal. Tr(1234)=1+4=5\mathrm{Tr}\begin{pmatrix}1&2\\3&4\end{pmatrix} = 1+4 = 5.
  • Multiplying: ABAB is allowed only if (columns of AA) = (rows of BB). Entry (i,j)(i,j) is “row ii of AA dotted with column jj of BB”:
(AB)ij=∑kAikBkj.(AB)_{ij} = \sum_k A_{ik}B_{kj}.

An m×nm\times n times an n×pn\times p gives an m×pm\times p.

Order matters

Addition commutes (A+B=B+AA + B = B + A), multiplication usually does not. With the matrices you will meet again in Lecture 4:

XZ=(0110)(100−1)=(0−110),ZX=(01−10).XZ = \begin{pmatrix}0&1\\1&0\end{pmatrix}\begin{pmatrix}1&0\\0&-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. In quantum mechanics this non-commuting is physics: it is the uncertainty principle from Lecture 1.

Eigenvectors and eigenvalues

If a matrix only stretches a vector (no change of direction), that vector is an eigenvector and the stretch factor is its eigenvalue:

A∣v⟩=a∣v⟩.A\ket{v} = a\ket{v}.
Lock it in · answer in your head, then reveal
What is a ket? What is a bra?
A ket ∣ψ⟩\ket{\psi} is a column vector. A bra ⟨ψ∣\bra{\psi} is its conjugate transpose: a row vector with every entry complex-conjugated.
What do you get from bra × ket, and from ket × bra?
⟨a|b⟩\braket{a}{b} is a single number. ∣a⟩⟨b∣\ket{a}\bra{b} is a square matrix.
When can you multiply an m×nm\times n matrix by an m′×n′m'\times n' one?
Only if n=m′n = m' (columns of the first = rows of the second). The result is m×n′m \times n'.
Is matrix multiplication commutative?
Not in general: usually AB≠BAAB \ne BA. Addition is commutative.
What is an eigenvector of AA?
A vector whose direction AA does not change: A∣v⟩=a∣v⟩A\ket v = a\ket v. The number aa is the eigenvalue.

Complex numbers

Number systems grew to solve equations: x+5=2x + 5 = 2 needs negatives; 3x=23x = 2 needs fractions; x2=2x^2 = 2 needs irrationals like 2\sqrt2. And x2=−1x^2 = -1 needs something new: the imaginary unit ii, defined by

i2=−1.i^2 = -1.

A complex number is z=a+biz = a + bi with a,ba, b real. The fundamental theorem of algebra says every degree-nn polynomial has exactly nn complex roots (counted with multiplicity), so complex numbers are “enough” for all of algebra.

Multiplying: expand like brackets and use i2=−1i^2=-1:

(a+bi)(c+di)=ac+adi+bci+bd i2=(ac−bd)+(ad+bc)i.(a+bi)(c+di) = ac + adi + bci + bd\,i^2 = (ac - bd) + (ad + bc)i.

A number times its conjugate is always real and equals the size squared:

zzˉ=(a+bi)(a−bi)=a2+b2=∣z∣2.z\bar z = (a+bi)(a-bi) = a^2 + b^2 = |z|^2.

Dividing: multiply top and bottom by the conjugate of the bottom, which makes the bottom real:

wz=w zˉz zˉ=w zˉ∣z∣2.\frac{w}{z} = \frac{w\,\bar z}{z\,\bar z} = \frac{w\,\bar z}{|z|^2}.

Polar form, Euler’s formula and phase

Plot z=a+biz = a + bi as the point (a,b)(a, b): real part across, imaginary part up. Then zz is an arrow with length r=∣z∣r = |z| and angle θ\theta from the positive real axis (the argument or phase). Trigonometry gives a=rcos⁡θa = r\cos\theta, b=rsin⁡θb = r\sin\theta.

Euler’s formula packs this together:

eiθ=cos⁡θ+isin⁡θ⟹z=reiθ.e^{i\theta} = \cos\theta + i\sin\theta \quad\Longrightarrow\quad z = r e^{i\theta}.
Explore · the complex plane

Drag the purple dot (or focus it and use the arrow keys). Notice: the conjugate is always the mirror image in the real axis, and |z| is just the length of the arrow.

ReImzz̄
z
Re z, Im z
Conjugate z̄
|z| = √(a² + b²)
arg z (phase θ)
Polar form
z · z̄ = |z|²

Scale: the dashed circle has radius 1. Multiplying by eiθ only rotates; it never changes the length, which is why a phase never changes a probability.

Polar form makes multiplication easy: lengths multiply, angles add:

r1eiθ1⋅r2eiθ2=r1r2 ei(θ1+θ2),zn=rneinθ.r_1e^{i\theta_1}\cdot r_2e^{i\theta_2} = r_1r_2\,e^{i(\theta_1+\theta_2)}, \qquad z^n = r^n e^{in\theta}.

So multiplying by eiθe^{i\theta} (length 1) just rotates an arrow. Keep this picture: in Lecture 3 a phase factor eiθe^{i\theta} will rotate an amplitude without changing any probability.

Useful values: ei0=1e^{i0} = 1, eiπ/2=ie^{i\pi/2} = i, eiπ=−1e^{i\pi} = -1 (Euler’s identity, eiπ+1=0e^{i\pi}+1=0), ei3π/2=−ie^{i3\pi/2} = -i, eiπ/4=12(1+i)e^{i\pi/4} = \tfrac{1}{\sqrt2}(1+i).

Lock it in · answer in your head, then reveal
∣a+bi∣|a + bi| = ?
a2+b2\sqrt{a^2 + b^2}, which also equals zzˉ\sqrt{z\bar z}.
Conjugate of 3−4i3 - 4i?
3+4i3 + 4i (flip the sign of the imaginary part only).
Euler's formula
eiθ=cos⁡θ+isin⁡θe^{i\theta} = \cos\theta + i\sin\theta, so any z=reiθz = r e^{i\theta} with r=∣z∣r = |z| and θ\theta the argument (phase).

Worked exercises

2.1 · Bra-ket with complex entries

Lecture 2 style

Let ∣a⟩=(1i)\ket{a} = \begin{pmatrix} 1 \\ i\end{pmatrix} and ∣b⟩=(23i)\ket{b} = \begin{pmatrix} 2 \\ 3i\end{pmatrix}. Find ⟨a|b⟩\braket{a}{b}, ⟨b|a⟩\braket{b}{a} and ∥∣b⟩∥\|\ket b\|.

Worked solution
  1. Make the bra by transposing and conjugating: ⟨a∣=(1, −i)\bra{a} = (1,\ -i).
  2. ⟨a|b⟩=1⋅2+(−i)(3i)=2−3i2=2+3=5\braket{a}{b} = 1\cdot 2 + (-i)(3i) = 2 - 3i^2 = 2 + 3 = 5.
  3. ⟨b∣=(2, −3i)\bra{b} = (2,\ -3i), so ⟨b|a⟩=2⋅1+(−3i)(i)=2+3=5\braket{b}{a} = 2\cdot1 + (-3i)(i) = 2 + 3 = 5. (In general ⟨b|a⟩=⟨a|b⟩‾\braket{b}{a} = \overline{\braket{a}{b}}; here the result happens to be real.)
  4. ⟨b|b⟩=2⋅2+(−3i)(3i)=4+9=13\braket{b}{b} = 2\cdot 2 + (-3i)(3i) = 4 + 9 = 13, so ∥∣b⟩∥=13\|\ket b\| = \sqrt{13}.
Answer: ⟨a|b⟩=⟨b|a⟩=5\braket{a}{b} = \braket{b}{a} = 5, ∥∣b⟩∥=13≈3.61\|\ket b\| = \sqrt{13} \approx 3.61.

2.2 · Ket times bra

Lecture 2 slide: bras and kets

Compute ∣0⟩⟨1∣\ket{0}\bra{1} and ∣1⟩⟨1∣\ket{1}\bra{1}, where ∣0⟩=(10)\ket0 = \begin{pmatrix}1\\0\end{pmatrix}, ∣1⟩=(01)\ket1 = \begin{pmatrix}0\\1\end{pmatrix}.

Worked solution
  1. Column times row gives a 2×22\times2 matrix whose entry (i,j)(i,j) is (entry ii of the ket) × (entry jj of the bra).
  2. ∣0⟩⟨1∣=(10)(01)=(0100)\ket0\bra1 = \begin{pmatrix}1\\0\end{pmatrix}\begin{pmatrix}0&1\end{pmatrix} = \begin{pmatrix}0&1\\0&0\end{pmatrix}.
  3. ∣1⟩⟨1∣=(01)(01)=(0001)\ket1\bra1 = \begin{pmatrix}0\\1\end{pmatrix}\begin{pmatrix}0&1\end{pmatrix} = \begin{pmatrix}0&0\\0&1\end{pmatrix}.
Answer: ∣0⟩⟨1∣=(0100)\ket0\bra1 = \begin{pmatrix}0&1\\0&0\end{pmatrix} and ∣1⟩⟨1∣=(0001)\ket1\bra1 = \begin{pmatrix}0&0\\0&1\end{pmatrix}. You can build any 2×22\times2 matrix from four such pieces, e.g. X=∣0⟩⟨1∣+∣1⟩⟨0∣X = \ket0\bra1 + \ket1\bra0.

2.3 · Matrix product, both orders

Lecture 2: commutativity

With A=(1201)A = \begin{pmatrix}1&2\\0&1\end{pmatrix} and B=(0110)B = \begin{pmatrix}0&1\\1&0\end{pmatrix}, compute ABAB and BABA.

Worked solution
  1. (AB)11=(AB)_{11} = row 1 of AA · column 1 of BB =1⋅0+2⋅1=2= 1\cdot0 + 2\cdot1 = 2; (AB)12=1⋅1+2⋅0=1(AB)_{12} = 1\cdot1 + 2\cdot0 = 1.
  2. (AB)21=0⋅0+1⋅1=1(AB)_{21} = 0\cdot0 + 1\cdot1 = 1; (AB)22=0⋅1+1⋅0=0(AB)_{22} = 0\cdot1 + 1\cdot0 = 0. So AB=(2110)AB = \begin{pmatrix}2&1\\1&0\end{pmatrix}.
  3. (BA)(BA): row 1 of BB is (0,1)(0,1), giving (0⋅1+1⋅0, 0⋅2+1⋅1)=(0,1)(0\cdot1+1\cdot0,\ 0\cdot2+1\cdot1) = (0, 1); row 2 is (1,0)(1,0), giving (1,2)(1, 2).
  4. So BA=(0112)≠ABBA = \begin{pmatrix}0&1\\1&2\end{pmatrix} \ne AB.
Answer: AB=(2110)AB = \begin{pmatrix}2&1\\1&0\end{pmatrix}, BA=(0112)BA = \begin{pmatrix}0&1\\1&2\end{pmatrix}: different, so they do not commute.

2.4 · Complex arithmetic

Lecture 2: complex definitions

For w=3+4iw = 3 + 4i and z=1−2iz = 1 - 2i find wzwz, wˉ\bar w, ∣w∣|w| and w/zw/z.

Worked solution
  1. wz=(3+4i)(1−2i)=3−6i+4i−8i2=3−2i+8=11−2iwz = (3+4i)(1-2i) = 3 - 6i + 4i - 8i^2 = 3 - 2i + 8 = 11 - 2i.
  2. wˉ=3−4i\bar w = 3 - 4i and ∣w∣=32+42=25=5|w| = \sqrt{3^2 + 4^2} = \sqrt{25} = 5.
  3. For w/zw/z, multiply top and bottom by zˉ=1+2i\bar z = 1 + 2i. Bottom: zzˉ=12+22=5z\bar z = 1^2 + 2^2 = 5.
  4. Top: (3+4i)(1+2i)=3+6i+4i+8i2=−5+10i(3+4i)(1+2i) = 3 + 6i + 4i + 8i^2 = -5 + 10i.
  5. So w/z=(−5+10i)/5=−1+2iw/z = (-5 + 10i)/5 = -1 + 2i. Check: (−1+2i)(1−2i)=−1+2i+2i−4i2=3+4i(-1+2i)(1-2i) = -1 + 2i + 2i - 4i^2 = 3 + 4i ✓.
Answer: wz=11−2iwz = 11 - 2i, wˉ=3−4i\bar w = 3 - 4i, ∣w∣=5|w| = 5, w/z=−1+2iw/z = -1 + 2i.

2.5 · Polar form and powers

Lecture 2: polar coordinates

Write z=1+iz = 1 + i in polar form and use it to find z8z^8.

Worked solution
  1. r=∣z∣=12+12=2r = |z| = \sqrt{1^2+1^2} = \sqrt2.
  2. The point (1,1)(1,1) is in the first quadrant, so θ=tan⁡−1(1/1)=π/4\theta = \tan^{-1}(1/1) = \pi/4 (45°).
  3. So z=2 eiπ/4z = \sqrt2\,e^{i\pi/4}.
  4. z8=(2)8ei⋅8π/4=16 e2πiz^8 = (\sqrt2)^8 e^{i\cdot 8\pi/4} = 16\,e^{2\pi i}.
  5. e2πi=cos⁡2π+isin⁡2π=1e^{2\pi i} = \cos 2\pi + i\sin2\pi = 1, so z8=16z^8 = 16.
Answer: z=2eiπ/4z = \sqrt2 e^{i\pi/4} and z8=16z^8 = 16. Expanding (1+i)8(1+i)^8 by hand would take far longer.

2.6 · Eigenvectors of Z

Lecture 2: eigenvalues

Show that ∣0⟩\ket0 and ∣1⟩\ket1 are eigenvectors of Z=(100−1)Z = \begin{pmatrix}1&0\\0&-1\end{pmatrix} and find the eigenvalues. Is 12(11)\tfrac{1}{\sqrt2}\begin{pmatrix}1\\1\end{pmatrix} an eigenvector?

Worked solution
  1. Z∣0⟩=(100−1)(10)=(10)=(+1)∣0⟩Z\ket0 = \begin{pmatrix}1&0\\0&-1\end{pmatrix}\begin{pmatrix}1\\0\end{pmatrix} = \begin{pmatrix}1\\0\end{pmatrix} = (+1)\ket0: eigenvalue +1+1.
  2. Z∣1⟩=(0−1)=(−1)∣1⟩Z\ket1 = \begin{pmatrix}0\\-1\end{pmatrix} = (-1)\ket1: eigenvalue −1-1.
  3. Z12(11)=12(1−1)Z\tfrac1{\sqrt2}\begin{pmatrix}1\\1\end{pmatrix} = \tfrac1{\sqrt2}\begin{pmatrix}1\\-1\end{pmatrix}, which is not a multiple of (11)\begin{pmatrix}1\\1\end{pmatrix}.
Answer: Eigenvalues +1+1 (for ∣0⟩\ket0) and −1-1 (for ∣1⟩\ket1). The vector (1,1)/2(1,1)/\sqrt2 is not an eigenvector, so in the language above it has no definite “Z value”.
Check yourself

What is ∣2−i∣|2 - i|?

↧ Go deeper: Hilbert spaces, adjoints and spectral theorem MSc

The space of qubit states is C2\mathbb{C}^2 with the inner product ⟨a|b⟩\braket{a}{b}: a (finite-dimensional) Hilbert space. The adjoint A†A^\dagger is defined by ⟨a|Ab⟩=⟨A†a|b⟩\braket{a}{Ab} = \braket{A^\dagger a}{b} for all vectors, which for matrices is the conjugate transpose. The spectral theorem says every normal matrix (AA†=A†AAA^\dagger = A^\dagger A), including every Hermitian and every unitary matrix, can be written A=∑kλk∣k⟩⟨k∣A = \sum_k \lambda_k \ket{k}\bra{k} with orthonormal eigenvectors ∣k⟩\ket{k}. That one fact underlies measurement (Lecture 3) and gates (Lecture 4). Read: Nielsen & Chuang §2.1; Axler, Linear Algebra Done Right, ch. 6–7.

↧ Go deeper: Why complex numbers, not just real? PhD

Could quantum theory work with real amplitudes only? For single systems you can always fake it with more dimensions, but in 2021 Renou et al. (Nature 600, 625) showed that real-number quantum theory makes different predictions in a network Bell-type experiment, and experiments since agree with the complex version. Complex numbers are not just a convenience.