Lean, informalized

Nielsen & Chuang · Chapter 2, Introduction to quantum mechanics · p. 74

Exercise 2.33 - The entries of the Hadamard transform on nn qubits in closed form, and its matrix on two

The Hadamard transform as a matrix of signs.

Hover over a blue or green term in the text, or a node in the graph, to find it in the other. Select it to read its declaration both in Lean and in words.

The Exercise

The Hadamard gate acts on one qubit as the matrix H=12(111−1)H = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix}(1) in the computational basis |0⟩,|1⟩|0\rangle, |1\rangle; its entries are written HabH_{ab}, for bits aa and bb. Applied to each of nn qubits at once it gives the Hadamard transform H⊗nH^{\otimes n}. The exercise asks for its matrix elements ⟨x|H⊗n|y⟩\langle x | H^{\otimes n} | y \rangle between computational basis states, labelled by strings xx and yy of nn bits, in closed form for every nn, and for the matrix of H⊗2H^{\otimes 2} written out in full.

The Hadamard Transform

The Hadamard transform H⊗nH^{\otimes n} on nn qubits is the real matrix with rows and columns labelled by the strings x=x1x2…xnx = x_1 x_2 \dots x_n of nn bits, defined by recursion on nn: H⊗0=1,Hxy⊗(n+1)=Hx1y1Hx′y′⊗n,H^{\otimes 0} = 1, \qquad H^{\otimes (n+1)}_{xy} = H_{x_1 y_1} \, H^{\otimes n}_{x' y'},(2)✦ where x′x' and y′y' are xx and yy with their first bits removed. On no qubits there is a single string, the empty one. The recursion is the tensor product H⊗(n+1)=H⊗H⊗nH^{\otimes (n+1)} = H \otimes H^{\otimes n} written entry by entry, with the first qubit split off. The entry in row xx and column yy is the matrix element Hxy⊗n=⟨x|H⊗n|y⟩H^{\otimes n}_{xy} = \langle x | H^{\otimes n} | y \rangle.

The basis order bb for two qubits is the list of the four strings of two bits in the order of the computational basis |00⟩,|01⟩,|10⟩,|11⟩|00\rangle, |01\rangle, |10\rangle, |11\rangle: b0=00,b1=01,b2=10,b3=11.b_0 = 00, \qquad b_1 = 01, \qquad b_2 = 10, \qquad b_3 = 11.(3)✦ In this order H⊗2H^{\otimes 2} is the 4×44 \times 4 matrix whose entry in row jj and column kk is Hbjbk⊗2H^{\otimes 2}_{b_j b_k}.

The Claim

For strings xx and yy of nn bits, x⋅y=x1y1+…+xnynx \cdot y = x_1 y_1 + \dots + x_n y_n counts the places where both carry a 11, and (−1)x⋅y(-1)^{x \cdot y} is −1-1 exactly when that count is odd.

Theorem 1. Let nn be a number of qubits and let xx and yy be strings of nn bits. The matrix element of the Hadamard transform between them is Hxy⊗n=12n(−1)x⋅y.H^{\otimes n}_{xy} = \frac{1}{\sqrt{2^n}} \, (-1)^{x \cdot y}.(4)✦ On two qubits, in the order (3), the Hadamard transform is the matrix H⊗2=12(11111−11−111−1−11−1−11).H^{\otimes 2} = \frac{1}{2} \begin{pmatrix} 1 & 1 & 1 & 1 \\ 1 & -1 & 1 & -1 \\ 1 & 1 & -1 & -1 \\ 1 & -1 & -1 & 1 \end{pmatrix}.(5)✦

What Is Checked

The claim is stated over the Hadamard transform H⊗nH^{\otimes n} built from the gate (1) by the recursion (2), and, on two qubits, over the basis order (3). The library proves that every matrix element of H⊗nH^{\otimes n}, for every number of qubits, has the closed form (4), and that the transform on two qubits, read in that order, is the matrix (5).