L12 Matrix Trace and Hadamard Gate
Watch on YouTube →
Overview
Hiu-Yung Wong reviews matrix trace and the Hadamard gate, then derives how applying Hadamard gates to an n-qubit computational-basis state produces a superposition whose signs depend on the bitwise inner product. The central result is H^⊗n|y⟩ = 2^(-n/2) Σ_x (-1)^(x·y)|x⟩, with x·y computed modulo 2; the lecture also covers trace invariance under unitary basis changes and the identity H⁻¹ = H.
Key takeaways
- The trace is both the sum of a matrix’s diagonal entries and the sum of its eigenvalues, and it remains invariant under a unitary basis transformation A′ = M†AM.
- The normalized Hadamard matrix is H = (1/√2)[[1, 1], [1, −1]]; it is self-inverse, so H² = I.
- Applying H to every qubit of |0…0⟩ creates an equal-amplitude superposition of all 2ⁿ computational-basis states, with amplitude 2^(-n/2) per state.
- For an arbitrary n-bit input y, the amplitude of output |x⟩ is 2^(-n/2)(−1)^(x·y), where x·y is the parity of positions where x and y both contain 1.
- In the arbitrary-input Hadamard expansion, the output sign is negative exactly when the two bit strings share an odd number of one-bits.
Chapters
- Hiu-Yung Wong recommends at least 10 hours of weekly study, including class preparation, homework, exam practice, and discussion.
- Assignment 2 has no late submissions; students should preserve the original file and begin the IBM Quantum hardware task early.
- The course IBM Quantum invitation provides accounts without requiring a credit card; Wong warns that quantum-computer usage can otherwise be expensive.
- For an n × n matrix A with entries aᵢⱼ, the trace is defined as Tr(A) = Σᵢ₌₀ⁿ⁻¹ aᵢᵢ.
- The diagonal entries use matching row and column indices, from a₀₀ through aₙ₋₁,ₙ₋₁.
- Wong distinguishes this definition from an equivalent interpretation involving eigenvalues, which is developed later.
- The Pauli X matrix has diagonal entries 0 and 0, so Tr(σₓ) = 0.
- The Pauli Z matrix has diagonal entries 1 and −1, which also sum to zero; σᵧ is traceless as well.
- The examples reinforce that trace is calculated from diagonal entries even when the matrix is not diagonalized.
- For compatible matrices, Tr(AB) = Tr(BA), even though matrix multiplication generally does not commute.
- Under a unitary change of basis, A′ = M†AM; cyclically rearranging the trace and using M M† = I gives Tr(A′) = Tr(A).
- Because a matrix’s trace is also the sum of its eigenvalues, the sum is unchanged when the matrix is represented in an eigenbasis.
- The one-qubit Hadamard gate is H = (1/√2)[[1, 1], [1, −1]], using the computational basis |0⟩ and |1⟩.
- Its action is H|0⟩ = (|0⟩ + |1⟩)/√2 and H|1⟩ = (|0⟩ − |1⟩)/√2.
- The plus and minus states are superpositions of one qubit’s basis states, not two-qubit tensor products such as |1⟩⊗|1⟩.
- The matrix element Hᵢⱼ can be obtained as ⟨i|H|j⟩ by applying H to the input basis state |j⟩ and taking its overlap with |i⟩.
- For example, H|1⟩ = (|0⟩ − |1⟩)/√2, so the second column of H is (1/√2, −1/√2)ᵀ.
- Wong emphasizes tracking row and column indices from zero and performing matrix–column-vector multiplication carefully.
- The general 2 × 2 determinant rule is ad − bc; for H, whose entries are normalized by 1/√2, det(H) = −1.
- Wong demonstrates the cofactor-and-transpose method for a matrix inverse, including the alternating signs (−1)^(i+j).
- The calculation gives H⁻¹ = H, so consecutive Hadamard gates cancel: H·H = I, avoiding unnecessary circuit matrix multiplication.
- The n-qubit Hadamard is shorthand for H⊗H⊗…⊗H, with one one-qubit H acting on each of n separate qubits.
- The tensor-product order matches the qubit positions; each gate acts on its own subsystem.
- Applying this operator to |0⟩⊗…⊗|0⟩ sets up the derivation of the full-register output.
- Each zero qubit becomes (|0⟩ + |1⟩)/√2 under H.
- Taking the tensor product of n such superpositions contributes an overall amplitude of (1/√2)ⁿ = 2^(-n/2).
- Distributing the tensor products generates every ordered n-bit string, rather than combining terms as if they were ordinary identical variables.
- The expansion contains all computational-basis states from |00…0⟩ through |11…1⟩.
- These n-bit strings correspond to the decimal labels x = 0, 1, …, 2ⁿ − 1.
- Thus H^⊗n|0…0⟩ = 2^(-n/2) Σₓ₌₀^{2ⁿ−1}|x⟩, an equal-amplitude superposition of all 2ⁿ basis states.
- An input label y is written in binary as yₙ₋₁…y₁y₀, where each digit yᵢ is either 0 or 1.
- For example, decimal 8 on four qubits is |1000⟩, since 1·2³ + 0·2² + 0·2¹ + 0·2⁰ = 8.
- The register state |y⟩ factors into one-qubit states |yₙ₋₁⟩⊗…⊗|y₀⟩, allowing H to be evaluated one bit at a time.
- For a single bit yᵢ, H|yᵢ⟩ = (|0⟩ + (−1)ʸⁱ|1⟩)/√2.
- When yᵢ = 0, the result has a plus sign; when yᵢ = 1, the coefficient of |1⟩ is negative.
- Writing the coefficient of |0⟩ as (−1)⁰ makes both output amplitudes fit the same bit-dependent expression.
- Applying the single-bit expression across all n positions yields 2ⁿ output strings, each with magnitude 2^(-n/2).
- For each output string x, its coefficient is a product of factors (−1)^(xᵢyᵢ), one from each qubit position.
- The resulting coefficient is always +1 or −1 because it is a product of signs; the binary patterns of x and y determine which.
- A factor contributes −1 only at a bit position where both xᵢ = 1 and yᵢ = 1; other positions contribute +1.
- The total sign is positive when the number of shared one-bits is even and negative when it is odd.
- Equivalently, the parity is the mod-2 inner product x·y = ⊕ᵢ(xᵢ ∧ yᵢ).
- The complete transformation is H^⊗n|y⟩ = 2^(-n/2) Σₓ₌₀^{2ⁿ−1}(−1)^(x·y)|x⟩, with x·y evaluated modulo 2.
- For y = 0, every phase is +1, recovering the uniform superposition derived earlier; other inputs change the signs according to bitwise parity.
- Wong connects the formula to the assignment’s numerical evaluation of an n-qubit Hadamard on a specified basis state and recommends working through concrete binary examples.
Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Quantum Computing, TCAD, Semicond by Hiu-Yung Wong.