|q⟩ Bad Qubits

beginner · Physics · Math Foundations: Linear Algebra

Checkpoint: Linear Algebra for Qubits

This lesson brings together every linear-algebra tool from Module 2 and shows how each one has a direct role in describing single-qubit operations.

The qubit state space

A single qubit lives in C2\mathbb{C}^2. Any pure state is a normalised column vector

∣ψ⟩=α∣0⟩+β∣1⟩=(αβ),∣α∣2+∣β∣2=1.|\psi\rangle = \alpha|0\rangle + \beta|1\rangle = \begin{pmatrix} \alpha \\ \beta \end{pmatrix}, \quad |\alpha|^2 + |\beta|^2 = 1.

The computational basis vectors ∣0⟩=(10)|0\rangle = \begin{pmatrix}1\\0\end{pmatrix} and ∣1⟩=(01)|1\rangle = \begin{pmatrix}0\\1\end{pmatrix} are orthonormal: their inner products satisfy ⟨0∣0⟩=⟨1∣1⟩=1\langle 0|0\rangle = \langle 1|1\rangle = 1 and ⟨0∣1⟩=0\langle 0|1\rangle = 0. The norm condition ∥ ∣ψ⟩ ∥=1\|\,|\psi\rangle\,\| = 1 is therefore equivalent to the Born-rule requirement that probabilities sum to 1.

Single-qubit gates as 2×22 \times 2 unitary matrices

Every physically allowed operation on a qubit is a unitary linear map: a 2×22 \times 2 matrix UU satisfying U†U=IU^\dagger U = I. Two gates that appear constantly are the Pauli-X and the Hadamard.

The Pauli-X gate flips the two basis states. Its matrix is

X=(0110).X = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}.

One can verify X†X=IX^\dagger X = I directly: XX is real and symmetric, so X†=XX^\dagger = X, and X2=IX^2 = I.

The Hadamard gate creates an equal superposition:

H=12(111−1).H = \frac{1}{\sqrt{2}}\begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix}.

A short calculation confirms it is unitary:

H†H=12(111−1)12(111−1)=12(2002)=I.H^\dagger H = \frac{1}{\sqrt{2}}\begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix} \frac{1}{\sqrt{2}}\begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix} = \frac{1}{2}\begin{pmatrix} 2 & 0 \\ 0 & 2 \end{pmatrix} = I.

Composing gates: matrix multiplication

Applying HH and then XX to ∣0⟩|0\rangle means computing the matrix product X⋅(H∣0⟩)X \cdot (H|0\rangle), or equivalently (XH)∣0⟩(XH)|0\rangle. Working step by step:

Step 1 — apply HH to ∣0⟩|0\rangle:

H∣0⟩=12(111−1)(10)=12(11)=12(∣0⟩+∣1⟩)≡∣+⟩.H|0\rangle = \frac{1}{\sqrt{2}}\begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix} \begin{pmatrix} 1 \\ 0 \end{pmatrix} = \frac{1}{\sqrt{2}}\begin{pmatrix} 1 \\ 1 \end{pmatrix} = \frac{1}{\sqrt{2}}\bigl(|0\rangle + |1\rangle\bigr) \equiv |{+}\rangle.

This is the ∣+⟩|{+}\rangle eigenstate of XX, with both amplitudes equal to 12\tfrac{1}{\sqrt{2}}.

Step 2 — apply XX to ∣+⟩|{+}\rangle:

X∣+⟩=(0110)12(11)=12(11)=∣+⟩.X|{+}\rangle = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix} \frac{1}{\sqrt{2}}\begin{pmatrix} 1 \\ 1 \end{pmatrix} = \frac{1}{\sqrt{2}}\begin{pmatrix} 1 \\ 1 \end{pmatrix} = |{+}\rangle.

The state is unchanged: ∣+⟩|{+}\rangle is an eigenvector of XX with eigenvalue +1+1. This is a direct consequence of the eigenvalue equation X∣+⟩=(+1)∣+⟩X|{+}\rangle = (+1)|{+}\rangle, which can be verified by the characteristic polynomial of XX:

det⁡(X−λI)=det⁡(−λ11−λ)=λ2−1=0  ⟹  λ=±1.\det(X - \lambda I) = \det\begin{pmatrix} -\lambda & 1 \\ 1 & -\lambda \end{pmatrix} = \lambda^2 - 1 = 0 \implies \lambda = \pm 1.

The eigenvalue +1+1 eigenvector satisfies (X−I)v=0(X - I)\mathbf{v} = 0, giving v1=v2v_1 = v_2, i.e. the normalised form 12(11)=∣+⟩\tfrac{1}{\sqrt{2}}\begin{pmatrix}1\\1\end{pmatrix} = |{+}\rangle.

Eigenvalues and measurement outcomes

The eigenvalue equation connects linear algebra directly to physics: measuring a qubit in the eigenbasis of the observable XX (the Pauli-X operator) gives outcome +1+1 with certainty when the state is ∣+⟩|{+}\rangle, because ∣+⟩|{+}\rangle is the +1+1 eigenstate of XX. More generally, if the state is ∣ψ⟩|\psi\rangle and we measure observable AA with eigenvalues λj\lambda_j and normalised eigenvectors ∣j⟩|j\rangle, the probability of outcome λj\lambda_j is ∣⟨j∣ψ⟩∣2|\langle j|\psi\rangle|^2 (the Born rule) and the expected value is

⟨A⟩=⟨ψ∣A∣ψ⟩=∑jλj∣⟨j∣ψ⟩∣2.\langle A \rangle = \langle \psi | A | \psi \rangle = \sum_j \lambda_j |\langle j|\psi\rangle|^2.

This expectation value formula is a direct application of matrix multiplication and inner products — the same operations practised throughout this module.

Try it

Build a one-qubit circuit that applies HH and then XX to qubit 0. After pressing Run you should see both amplitudes equal 12≈0.707\tfrac{1}{\sqrt{2}} \approx 0.707 — confirming that XH∣0⟩=∣+⟩XH|0\rangle = |{+}\rangle exactly as computed above.

Run your code to see the quantum state.

Sign in on the full site to ask questions and join the discussion.