Week 1 | the language of amplitudes | reading: Watrous Ch. 1, de Wolf Appendix A
In Lecture 1 we met amplitudes: numbers attached to the outcomes of a qubit, whose squared sizes are probabilities, and which, unlike probabilities, can cancel. This lecture builds the language they are written in. By the end you should be able to compute with complex numbers in both rectangular and polar form; add up roots of unity; take inner products in \(\mathbb C^n\) without forgetting the conjugate; move freely between column vectors and Dirac's kets and bras; and recognise the two families of matrices that run the rest of the course, unitary and Hermitian.
The Lecture 1 example used real amplitudes, and a minus sign was enough to make two paths cancel. Why not stop there? Because between "reinforce" (+) and "cancel" (−) there is a whole circle of possibilities, and nature uses all of them. Two amplitudes of the same size can meet at any relative angle, and the result depends continuously on that angle. A plus or minus sign is just the two ends of that circle, and a complex number is exactly an arrow that can point anywhere on it.
There is also a practical reason. The six states that will appear in every lab this semester are \(|0\rangle,|1\rangle,|+\rangle,|-\rangle\) and two more, \(|{+i}\rangle\) and \(|{-i}\rangle\), and the last two cannot be written with real numbers at all. Neither can the gates that rotate one into another, and neither can the quantum Fourier transform at the heart of Shor's algorithm. So we need complex numbers. The good news is that you need them only as arrows: the algebra is the algebra of rotating and stretching.
Complex numbers were not invented to be useful; they forced their way in. In 1545 Gerolamo Cardano published a formula for solving cubic equations, and it had an embarrassing habit: for some cubics with three perfectly real answers, the formula passed through square roots of negative numbers on the way. In 1572 Rafael Bombelli simply wrote down rules for calculating with these objects and watched the imaginary parts cancel to give the right real answers. René Descartes named them "imaginary" in 1637, meaning it as an insult. In 1748 Leonhard Euler found \(e^{i\theta}=\cos\theta+i\sin\theta\), and around 1800 Caspar Wessel and Jean-Robert Argand drew them as points in a plane. Four centuries later, they are the native language of the smallest things in the universe.
A complex number is \(z=a+bi\) with \(a,b\) real and \(i^2=-1\). We draw it as the point, or arrow, \((a,b)\) in the plane. Its conjugate is its mirror image across the real axis, and its modulus is its length:
$$\bar z=a-bi,\qquad |z|=\sqrt{a^2+b^2},\qquad |z|^2=z\,\bar z .$$The identity \(|z|^2=z\bar z\) is the one to remember: multiplying a number by its own conjugate kills the imaginary part and leaves the squared length. It is why conjugates will appear in every inner product below.
An arrow can also be described by its length \(r=|z|\) and the angle \(\theta\) it makes with the positive real axis, its argument or phase. Euler's formula packages the pair into one symbol:
$$z=r\,(\cos\theta+i\sin\theta)=r\,e^{i\theta}.$$If \(z=r\,e^{i\theta}\) and \(w=s\,e^{i\varphi}\), then
$$z\,w=rs\;e^{i(\theta+\varphi)},\qquad \frac{z}{w}=\frac{r}{s}\;e^{i(\theta-\varphi)},\qquad \bar z=r\,e^{-i\theta}.$$Lengths multiply and angles add. In particular, multiplying by \(e^{i\varphi}\), a number of length 1, is a pure rotation by \(\varphi\). Multiplying by \(i=e^{i\pi/2}\) is a quarter turn, and multiplying by \(-1=e^{i\pi}\) is a half turn.
Expand with the angle-addition formulas:
$$\begin{aligned}(\cos\theta+i\sin\theta)(\cos\varphi+i\sin\varphi)&=(\cos\theta\cos\varphi-\sin\theta\sin\varphi)\\[4pt] &\quad+i(\sin\theta\cos\varphi+\cos\theta\sin\varphi)\\[4pt] &=\cos(\theta+\varphi)+i\sin(\theta+\varphi).\end{aligned}$$Multiply by \(rs\) for the first identity. The second follows because \(w\cdot\tfrac1s e^{-i\varphi}=1\), and the third because \(\overline{\cos\theta+i\sin\theta}=\cos(-\theta)+i\sin(-\theta)\).
Let \(z=2e^{i\pi/3}\) and \(w=3e^{i\pi/6}\). Find the length and the phase (in radians) of \(zw\).
Let \(z=\sqrt3+i\) and \(w=1+i\). Write both in polar form, then find \(zw\) and \(z/w\) in both forms. Check that the two methods agree.
\(|z|=\sqrt{3+1}=2\) at angle \(\pi/6\), and \(|w|=\sqrt2\) at angle \(\pi/4\). So
$$z=2e^{i\pi/6},\qquad w=\sqrt2\,e^{i\pi/4}.$$Polar: lengths multiply and angles add,
$$zw=2\sqrt2\;e^{i\,5\pi/12},\qquad \frac zw=\sqrt2\;e^{-i\pi/12}.$$Rectangular: expand, using \(i^2=-1\),
$$zw=(\sqrt3+i)(1+i)=\sqrt3+\sqrt3\,i+i+i^2=(\sqrt3-1)+(\sqrt3+1)\,i .$$Check the length: \((\sqrt3-1)^2+(\sqrt3+1)^2=2(3+1)=8\), and \(\sqrt8=2\sqrt2\). For the quotient, multiply top and bottom by \(\bar w\) so that the denominator becomes the real number \(|w|^2\):
$$\frac{z}{w}=\frac{z\,\bar w}{|w|^2}=\frac{(\sqrt3+i)(1-i)}{2}=\frac{(\sqrt3+1)+(1-\sqrt3)\,i}{2}.$$Rectangular form is best for adding; polar form is best for multiplying. Quantum computing does a lot of both.
Probabilities are squared lengths, \(|z|^2\), so they cannot see phase at all: \(e^{i\theta}\) has length 1 for every \(\theta\). Yet phase decides what happens when two amplitudes meet, because it decides whether their arrows line up or point apart. Much of quantum computing is the craft of steering phases you cannot observe directly so that, at the moment of measurement, they have arranged themselves into lengths you can.
Two amplitudes of length 1 meet with a relative phase of \(60^\circ\). Compute \(\big|1+e^{i\pi/3}\big|^2\).
For a whole number \(N\ge1\), let \(\omega=e^{2\pi i/N}\). The \(N\)th roots of unity are the \(N\) numbers
$$1,\;\omega,\;\omega^2,\;\dots,\;\omega^{N-1},$$equally spaced around the unit circle. Each satisfies \(z^N=1\), and \(\omega^N=1\) means the powers repeat with period \(N\).
For every whole number \(j\),
$$\sum_{k=0}^{N-1}\omega^{jk}=\begin{cases}N, & \text{if } N \text{ divides } j,\\[4pt] 0, & \text{otherwise.}\end{cases}$$Write \(q=\omega^j\). If \(N\) divides \(j\), then \(q=1\) and the sum is \(1+1+\dots+1=N\). Otherwise \(q\neq1\), and the geometric-series formula applies:
$$\sum_{k=0}^{N-1}q^k=\frac{q^N-1}{q-1}=\frac{(\omega^N)^j-1}{q-1}=\frac{1-1}{q-1}=0 .$$Geometrically, the arrows \(q^0,q^1,\dots,q^{N-1}\) are spread symmetrically around the circle, so they pull equally in every direction and cancel.
Let \(\omega=e^{2\pi i/10}\). Then \(\sum_{k=0}^{9}\omega^{5k}\) equals and \(\sum_{k=0}^{9}\omega^{20k}\) equals .
List the fourth roots of unity and compute \(\sum_{k=0}^{3} i^{2k}\) and \(\sum_{k=0}^{3} i^{4k}\) directly. Check the answers against Proposition 2.2.
Here \(\omega=e^{2\pi i/4}=i\), so the roots are \(1,\,i,\,-1,\,-i\): quarter turns around the circle. Then \(\sum i^{2k}=1-1+1-1=0\), matching \(j=2\), which 4 does not divide. And \(\sum i^{4k}=1+1+1+1=4\), matching \(j=4\), which 4 divides.
Proposition 2.2 looks like a curiosity. It is the single most important identity in this course. The quantum Fourier transform (Lecture 13) sends a state that repeats with some hidden period into a state concentrated on multiples of \(N\) divided by that period. It works because every other outcome collects a sum of roots of unity that cancels exactly. Shor's algorithm uses that to find the period of \(a^x \bmod N\), and from the period it factors \(N\) and breaks RSA. When you see a quantum speedup, look for a sum of roots of unity quietly adding up to zero.
A qubit state lives in \(\mathbb C^2\), and \(n\) qubits live in \(\mathbb C^{2^n}\). Vectors there add and scale exactly as in \(\mathbb R^n\). The one thing that changes is how we measure lengths and angles.
Try the real formula on \(u=(1,\,i)\): \(u_1^2+u_2^2=1+i^2=0\). A nonzero vector of "length zero" is useless, so the real dot product has to be repaired. The repair is the identity \(|z|^2=z\bar z\): conjugate one side.
For \(u,v\in\mathbb C^n\),
$$\langle u,v\rangle=\sum_{k=1}^{n}\overline{u_k}\,v_k,\qquad \lVert u\rVert=\sqrt{\langle u,u\rangle}=\sqrt{\sum_k |u_k|^2}.$$The conjugate goes on the first vector; this is the physicists' convention, and the one Qiskit and NumPy's vdot use. Two vectors are orthogonal if \(\langle u,v\rangle=0\). A basis of unit vectors that are pairwise orthogonal is orthonormal.
Three properties do all the work. The inner product is linear in the second slot; swapping the slots conjugates it, \(\langle v,u\rangle=\overline{\langle u,v\rangle}\); and \(\langle u,u\rangle\ge0\), with equality only for \(u=0\). The second property is new: in \(\mathbb C^n\) the order of an inner product matters.
Let \(u=(i,\;2)\) and \(v=(1+i,\;1)\). Compute \(\langle u,v\rangle\) and give its real and imaginary parts.
Let \(u=(1,\;i)\) and \(v=(2,\;1-i)\). Find \(\langle u,v\rangle\), \(\langle v,u\rangle\), \(\lVert u\rVert\) and \(\lVert v\rVert\). What does the unconjugated formula give?
Conjugate the entries of \(u\) first: \(\bar u=(1,\,-i)\). Then
$$\langle u,v\rangle=1\cdot2+(-i)(1-i)=2-i+i^2=1-i,$$ $$\langle v,u\rangle=\overline{1-i}=1+i .$$For the norms, \(\lVert u\rVert^2=|1|^2+|i|^2=2\) and \(\lVert v\rVert^2=4+|1-i|^2=4+2=6\), so \(\lVert u\rVert=\sqrt2\) and \(\lVert v\rVert=\sqrt6\). Without the conjugate you would get \(2+i(1-i)=3+i\), a different and meaningless number.
Orthonormal bases are useful because coordinates become inner products. If \(b_1,\dots,b_n\) is orthonormal, then every vector satisfies
$$v=\sum_k c_k\,b_k\qquad\text{with}\qquad c_k=\langle b_k,v\rangle .$$No linear system to solve: just take inner products. To check, take the inner product of both sides with \(b_j\); every term vanishes except \(c_j\langle b_j,b_j\rangle=c_j\).
Show that \(b_+=\tfrac{1}{\sqrt2}(1,\,1)\) and \(b_-=\tfrac{1}{\sqrt2}(1,\,-1)\) form an orthonormal basis of \(\mathbb C^2\), and find the coordinates of a general state \((\alpha,\beta)\) in this basis.
\(\langle b_+,b_+\rangle=\tfrac12(1+1)=1\), likewise \(\langle b_-,b_-\rangle=1\), and \(\langle b_+,b_-\rangle=\tfrac12(1-1)=0\). Two orthonormal vectors in a 2-dimensional space form a basis. The coordinates are inner products:
$$c_+=\langle b_+,(\alpha,\beta)\rangle=\frac{\alpha+\beta}{\sqrt2},\qquad c_-=\langle b_-,(\alpha,\beta)\rangle=\frac{\alpha-\beta}{\sqrt2}.$$For the Lecture 1 state \((0.6,\,0.8)\) this gives \(c_+=1.4/\sqrt2\approx0.990\) and \(c_-\approx-0.141\), exactly the numbers we got from the Hadamard gate. That is no coincidence, as Section 7 will show.
Reading a qubit "in the standard basis" gives outcome \(k\) with probability \(|\text{coordinate } k|^2\). Nothing is special about the standard basis. Pick any orthonormal basis, compute the coordinates of your state by inner products, and their squared lengths are the probabilities of a different measurement. The state stays the same; the question you ask it changes. This is the Born rule, and Lecture 3 makes it official.
Physicists write quantum states in a notation invented by Paul Dirac in 1939. It looks odd for about a week and then becomes indispensable, because the notation does half the algebra for you.
A ket \(|v\rangle\) is a column vector. Its bra \(\langle v|\) is the conjugate transpose, a row vector. Putting a bra next to a ket multiplies them as matrices and produces the inner product, a bracket:
$$|v\rangle=\begin{pmatrix}v_1\\[2pt] \vdots\\[2pt] v_n\end{pmatrix},\qquad \langle v|=\begin{pmatrix}\overline{v_1} & \cdots & \overline{v_n}\end{pmatrix},\qquad \langle u|v\rangle=\langle u|\,|v\rangle=\sum_k\overline{u_k}\,v_k .$$The label inside the ket is just a name. \(|0\rangle\), \(|+\rangle\) and \(|\psi\rangle\) are vectors named 0, plus and psi.
The six single-qubit states below will follow us all semester. The first two are the standard basis; each row pair is an orthonormal basis.
| ket | column | bra (conjugate row) | basis |
|---|---|---|---|
| \(|0\rangle\), \(|1\rangle\) | \((1,0)^{\mathsf T}\), \((0,1)^{\mathsf T}\) | \((1\;\;0)\), \((0\;\;1)\) | standard (Z) |
| \(|\pm\rangle\) | \(\tfrac{1}{\sqrt2}(1,\,\pm1)^{\mathsf T}\) | \(\tfrac{1}{\sqrt2}(1\;\;\pm1)\) | Hadamard (X) |
| \(|{\pm i}\rangle\) | \(\tfrac{1}{\sqrt2}(1,\,\pm i)^{\mathsf T}\) | \(\tfrac{1}{\sqrt2}(1\;\;\mp i)\) | circular (Y) |
Notice the \(\mp\) in the last bra: the conjugate flips the sign of \(i\). The standard basis turns any vector into kets immediately: \((\alpha,\beta)^{\mathsf T}=\alpha|0\rangle+\beta|1\rangle\).
What is the bra of \(|\psi\rangle=\tfrac12\big(\sqrt3\,|0\rangle-i|1\rangle\big)\)?
Show that \(|{+i}\rangle\) and \(|{-i}\rangle\) are orthogonal. Then compute the same product without the conjugate and see what goes wrong.
The bra of \(|{+i}\rangle\) is \(\tfrac1{\sqrt2}(1\;\;-i)\). So
$$\begin{aligned}\langle{+i}|{-i}\rangle&=\frac12\begin{pmatrix}1 & -i\end{pmatrix}\begin{pmatrix}1\\[2pt] -i\end{pmatrix}\\[4pt] &=\frac12\big(1+(-i)(-i)\big)=\frac12(1+i^2)=\frac12(1-1)=0 .\end{aligned}$$Forgetting to conjugate gives \(\tfrac12(1\cdot1+i\cdot(-i))=\tfrac12(1+1)=1\): the two states would look identical instead of perfectly distinguishable. This is the most common slip in all of this material.
In Dirac notation, a bra next to a ket is a number and a ket next to a bra is a matrix. The shapes enforce the algebra: \(\langle u|v\rangle\) can only be a scalar, and \(|u\rangle\langle v|\), coming next, can only be a matrix. Once you trust the shapes, long calculations become bookkeeping: move the brackets around and let the scalars fall out.
The outer product \(|u\rangle\langle v|\) is the matrix column times row. It acts on a ket by
$$\big(|u\rangle\langle v|\big)\,|w\rangle=|u\rangle\,\langle v|w\rangle=\langle v|w\rangle\,|u\rangle .$$If \(|u\rangle\) is a unit vector, \(P_u=|u\rangle\langle u|\) is the projector onto the line through \(|u\rangle\): it keeps the \(|u\rangle\)-component of any vector and discards the rest.
Two facts follow straight from the notation. Projecting twice changes nothing, \(P_u^2=|u\rangle\langle u|u\rangle\langle u|=P_u\), because \(\langle u|u\rangle=1\). And the projectors onto an orthonormal basis add up to the identity, the completeness relation:
$$\sum_k |b_k\rangle\langle b_k|=I.$$For example,
$$ |0\rangle\langle0|+|1\rangle\langle1|=|+\rangle\langle+|+|-\rangle\langle-|=I .$$Completeness is the expansion \(v=\sum_k c_k b_k\) of Section 4 written as a matrix identity, and it will save you pages of algebra: you can insert \(I=\sum_k|b_k\rangle\langle b_k|\) anywhere in a calculation.
Let \(|u\rangle=0.6|0\rangle+0.8|1\rangle\). Find the top row of the projector \(P_u=|u\rangle\langle u|\).
Write \(|+\rangle\langle+|\) as a matrix. Compare it with the fair-coin matrix \(F\) of Lecture 1. Then compute \(\langle\psi|\,P_+\,|\psi\rangle\) for \(|\psi\rangle=0.6|0\rangle+0.8|1\rangle\).
The fair coin was a projector all along, which explains why applying it twice gave nothing new: \(F^2=F\). Next,
$$\langle\psi|P_+|\psi\rangle=\langle\psi|+\rangle\langle+|\psi\rangle=|\langle+|\psi\rangle|^2=\Big(\frac{0.6+0.8}{\sqrt2}\Big)^2=0.98 .$$That is the probability 0.98 we found in Lecture 1, now computed as "how much of \(|\psi\rangle\) lies along \(|+\rangle\)". The pattern \(\langle\psi|P|\psi\rangle=\) probability is the general rule of measurement.
The adjoint (or conjugate transpose, or "dagger") of a matrix \(A\) is \(A^\dagger=\overline{A}^{\mathsf T}\). It is the matrix version of turning a ket into a bra: \((|v\rangle)^\dagger=\langle v|\). It reverses products and moves across brackets:
$$(AB)^\dagger=B^\dagger A^\dagger,\qquad \langle u|\,A\,v\rangle=\langle A^\dagger u\,|\,v\rangle .$$A square matrix \(U\) is unitary if
$$U^\dagger U=I,$$so \(U\) is invertible and its inverse is simply its adjoint. Unitary matrices are the quantum gates: every step of a quantum computation, short of measurement, is one.
If \(U\) is unitary, then (a) \(\langle Uu|Uv\rangle=\langle u|v\rangle\) for all \(u,v\), so \(U\) preserves lengths, angles and orthogonality; (b) the columns of \(U\) form an orthonormal basis; (c) every eigenvalue of \(U\) has \(|\lambda|=1\).
(a) Move \(U\) across the bracket: \(\langle Uu|Uv\rangle=\langle u|U^\dagger U v\rangle=\langle u|v\rangle\).
(b) The \((j,k)\) entry of \(U^\dagger U\) is (row \(j\) of \(U^\dagger\)) times (column \(k\) of \(U\)), which is \(\langle \text{col}_j|\text{col}_k\rangle\). Setting \(U^\dagger U=I\) says exactly that these brackets are 1 when \(j=k\) and 0 otherwise. (The converse, that orthonormal columns make \(U\) unitary, is HW1.)
(c) Save it for exercise 6.
A unitary matrix has an eigenvalue \(\lambda\). Which of these could \(\lambda\) be?
A square matrix \(A\) is Hermitian if \(A^\dagger=A\): it equals its own conjugate transpose. Hermitian matrices are the quantum version of real numbers. They will describe measurements and energies, and their key property is that their eigenvalues are real.
Tick every Hermitian matrix.
If \(A^\dagger=A\) and \(A|v\rangle=\lambda|v\rangle\) with \(|v\rangle\neq0\), then \(\lambda\) is real. Eigenvectors for different eigenvalues are orthogonal.
Compute \(\langle v|A|v\rangle\) two ways. Using \(A|v\rangle=\lambda|v\rangle\) gives \(\lambda\langle v|v\rangle\). Moving \(A\) to the bra, \(\langle A^\dagger v|v\rangle=\langle Av|v\rangle=\bar\lambda\langle v|v\rangle\), where the conjugate appears because the first slot is conjugated. Since \(\langle v|v\rangle>0\), \(\lambda=\bar\lambda\). For orthogonality, if \(A|w\rangle=\mu|w\rangle\) with \(\mu\neq\lambda\), the same trick gives \(\lambda\langle w|v\rangle=\langle w|A|v\rangle=\mu\langle w|v\rangle\), so \(\langle w|v\rangle=0\).
Decide which of these matrices are unitary and which are Hermitian:
$$X=\begin{pmatrix}0 & 1\\[2pt] 1 & 0\end{pmatrix},\qquad Y=\begin{pmatrix}0 & -i\\[2pt] i & 0\end{pmatrix},\qquad Z=\begin{pmatrix}1 & 0\\[2pt] 0 & -1\end{pmatrix},$$ $$H=\frac{1}{\sqrt2}\begin{pmatrix}1 & 1\\[2pt] 1 & -1\end{pmatrix},\qquad S=\begin{pmatrix}1 & 0\\[2pt] 0 & i\end{pmatrix},\qquad F=\frac12\begin{pmatrix}1 & 1\\[2pt] 1 & 1\end{pmatrix}.$$| matrix | unitary? | Hermitian? | reason |
|---|---|---|---|
| \(X,\;Y,\;Z\) | yes | yes | columns orthonormal, and each equals its conjugate transpose |
| \(H\) | yes | yes | real and symmetric, and \(H^2=I\), so \(H^\dagger H=H^2=I\) |
| \(S\) | yes | no | \(S^\dagger=\mathrm{diag}(1,-i)\neq S\), but \(S^\dagger S=\mathrm{diag}(1,|i|^2)=I\) |
| \(F\) | no | yes | \(\det F=0\): not invertible, so it cannot be unitary |
So unitary and Hermitian are independent properties. The Pauli matrices and \(H\) happen to be both, which is why they turn up both as gates and as measurements.
One more look at \(H\): its rows are the bras \(\langle+|\) and \(\langle-|\), so \(H|\psi\rangle=(\langle+|\psi\rangle,\;\langle-|\psi\rangle)\) lists the coordinates of \(|\psi\rangle\) in the plus/minus basis. That is why Example 2.4 reproduced the Lecture 1 numbers.
| stochastic (Lecture 1) | unitary (from now on) | |
|---|---|---|
| acts on | probability vectors | amplitude vectors |
| preserves | 1-norm \(\sum p_k=1\) | 2-norm \(\sum|\psi_k|^2=1\) |
| entries | nonnegative reals | any complex numbers |
| inverse | usually none: information is lost | always, \(U^{-1}=U^\dagger\): nothing is lost |
| example | fair coin \(F\) | Hadamard \(H\) |
The last row of the table is profound. A fair coin destroys information: after flipping it you cannot tell what it was before. A unitary destroys nothing, since \(U^\dagger\) undoes it exactly. Between measurements a quantum computer is perfectly reversible, and the only irreversible step is measurement itself. This is why, in Lecture 7, even ordinary AND gates must be rebuilt in reversible form before a quantum computer can run them.
Let \(A\) be Hermitian or unitary (more generally, normal: \(A^\dagger A=AA^\dagger\)). Then \(A\) has an orthonormal basis of eigenvectors \(|e_1\rangle,\dots,|e_n\rangle\) with eigenvalues \(\lambda_1,\dots,\lambda_n\), and
$$A=\sum_{k=1}^{n}\lambda_k\,|e_k\rangle\langle e_k| .$$In words: every such matrix is a weighted sum of projectors onto perpendicular lines. It stretches each line by its own eigenvalue and leaves the lines perpendicular.
A matrix has eigenvector \(|+\rangle\) with eigenvalue 2 and eigenvector \(|-\rangle\) with eigenvalue 4, so \(A=2|+\rangle\langle+|+4|-\rangle\langle-|\). Find the top row of \(A\).
Many matrices have no orthonormal basis of eigenvectors. The shear
$$\begin{pmatrix}1&1\\[2pt] 0&1\end{pmatrix}$$has the single eigenvalue 1 and only one eigenvector direction, so it cannot be diagonalised at all. Lecture 5 needs to analyse arbitrary \(2\times2\) matrices (the coefficient matrices of two-qubit states), and there we meet the singular value decomposition, which works for every matrix by using two orthonormal bases instead of one. It is built from this theorem, applied to the Hermitian matrix \(A^\dagger A\).
Find the eigenvalues and eigenvectors of \(X\) and write its spectral decomposition.
\(X\) swaps the two entries of a vector, so it fixes \((1,1)\) and negates \((1,-1)\): \(X|+\rangle=|+\rangle\) and \(X|-\rangle=-|-\rangle\). Hence
$$\begin{aligned}X&=(+1)\,|+\rangle\langle+|+(-1)\,|-\rangle\langle-|\\[4pt] &=\frac12\begin{pmatrix}1 & 1\\[2pt] 1 & 1\end{pmatrix}-\frac12\begin{pmatrix}1 & -1\\[2pt] -1 & 1\end{pmatrix}=\begin{pmatrix}0 & 1\\[2pt] 1 & 0\end{pmatrix}.\end{aligned}$$| Pauli matrix | eigenvalue \(+1\) | eigenvalue \(-1\) | spectral form |
|---|---|---|---|
| \(Z\) | \(|0\rangle\) | \(|1\rangle\) | \(|0\rangle\langle0|-|1\rangle\langle1|\) |
| \(X\) | \(|+\rangle\) | \(|-\rangle\) | \(|+\rangle\langle+|-|-\rangle\langle-|\) |
| \(Y\) | \(|{+i}\rangle\) | \(|{-i}\rangle\) | \(|{+i}\rangle\langle{+i}|-|{-i}\rangle\langle{-i}|\) |
This is why the three bases in the Section 5 table are named Z, X and Y: each is the eigenbasis of one Pauli matrix.
The spectral form lets you apply any function to a matrix by applying it to the eigenvalues:
$$f(A)=\sum_k f(\lambda_k)\,|e_k\rangle\langle e_k| .$$Here is a gate that no classical machine can have. Take \(f(\lambda)=\sqrt\lambda\) for \(X\), choosing \(\sqrt{1}=1\) and \(\sqrt{-1}=i\):
$$\sqrt{X}=|+\rangle\langle+|+i\,|-\rangle\langle-|=\frac12\begin{pmatrix}1+i & 1-i\\[2pt] 1-i & 1+i\end{pmatrix}.$$It is unitary, and applying it twice gives \(|+\rangle\langle+|+i^2|-\rangle\langle-|=X\): a genuine "half of a NOT".
There is no \(2\times2\) stochastic matrix \(M\) with \(M^2=\mathrm{NOT}\).
Every \(2\times2\) stochastic matrix has the form
$$M=\begin{pmatrix}a & b\\[2pt] 1-a & 1-b\end{pmatrix},\qquad 0\le a,b\le1 .$$Its columns sum to 1, so \((1\;\;1)\,M=(1\;\;1)\) and \(1\) is an eigenvalue. The eigenvalues add up to the trace \(a+1-b\), so the other eigenvalue is the real number \(a-b\). The eigenvalues of \(M^2\) are therefore \(1\) and \((a-b)^2\ge0\). But NOT has eigenvalue \(-1\), so \(M^2\neq\mathrm{NOT}\).
Probabilities are stuck on the nonnegative half of the number line, so they cannot take the square root of \(-1\). Amplitudes live on the whole complex plane, where \(i\) is waiting. That single extra degree of freedom is enough to create operations with no classical counterpart, and "half a NOT" is the simplest one you can hold in your hand.
import numpy as np u = np.array([1, 1j]) v = np.array([2, 1 - 1j]) print(np.vdot(u, v)) # <u|v>: vdot conjugates its FIRST argument print(u @ v) # plain dot product: no conjugate, wrong for C^n H = np.array([[1, 1], [1, -1]]) / np.sqrt(2) S = np.array([[1, 0], [0, 1j]]) print((S.conj().T @ S).round(12)) # S-dagger S: the identity, so S is unitary print(np.allclose(S.conj().T, S)) # is S Hermitian? X = np.array([[0, 1], [1, 0]]) vals, vecs = np.linalg.eigh(X) # eigh: for Hermitian matrices print(vals) print(vecs.round(4)) # columns: eigenvectors, each up to a sign
(1-1j) (3+1j) [[1.+0.j 0.+0.j] [0.+0.j 1.+0.j]] False [-1. 1.] [[-0.7071 0.7071] [ 0.7071 0.7071]]
The first eigenvector column is \(-|-\rangle\) rather than \(|-\rangle\). Both are fine: an eigenvector times any nonzero number, including \(-1\), is still an eigenvector. In HW1 you will package the unitarity check into a function of your own.
import numpy as np
from qiskit.quantum_info import Operator, Statevector
from qiskit.circuit.library import HGate, SGate
plus_i = Statevector([1, 1j] / np.sqrt(2))
minus_i = Statevector([1, -1j] / np.sqrt(2))
print(plus_i.inner(minus_i)) # <+i|-i>, conjugate included
print(Operator(HGate()).is_unitary(), Operator(SGate()).is_unitary())
print(Operator(SGate()).data)
0j True True [[1.+0.j 0.+0.j] [0.+0.j 0.+1.j]]
Next time: the qubit made official: the Born rule, global versus relative phase, and the Bloch sphere. HW1 is due at the start of Week 2, and Lab 1 launches in Lecture 4.
all numbers and figures in these notes are computed in python (verify_L02.py) and follow the page theme