|q⟩ Bad Qubits

beginner · Physics · Math Foundations: Linear Algebra

Matrices as Linear Maps

A matrix is more than a table of numbers — it is a precise rule for transforming one vector into another. That rule is called a linear map, and it sits at the heart of every quantum gate, observable, and evolution operator you will encounter.

Vectors as columns, matrices as grids

A 2×22 \times 2 matrix MM has four entries arranged in two rows and two columns:

M=(abcd).M = \begin{pmatrix} a & b \\ c & d \end{pmatrix}.

A column vector v\mathbf{v} with two entries is written

v=(v1v2).\mathbf{v} = \begin{pmatrix} v_1 \\ v_2 \end{pmatrix}.

Applying MM to v\mathbf{v} — written MvM\mathbf{v} — produces a new column vector whose entries are computed by taking dot products of each row of MM with the column v\mathbf{v}:

Mv=(abcd)(v1v2)=(av1+bv2cv1+dv2).M\mathbf{v} = \begin{pmatrix} a & b \\ c & d \end{pmatrix} \begin{pmatrix} v_1 \\ v_2 \end{pmatrix} = \begin{pmatrix} a\,v_1 + b\,v_2 \\ c\,v_1 + d\,v_2 \end{pmatrix}.

The first output component is the dot product of row 0 with v\mathbf{v}; the second is the dot product of row 1 with v\mathbf{v}.

Why "linear map"?

The map vMv\mathbf{v} \mapsto M\mathbf{v} is linear because it preserves two operations:

  1. Addition: M(u+v)=Mu+MvM(\mathbf{u} + \mathbf{v}) = M\mathbf{u} + M\mathbf{v}.
  2. Scalar multiplication: M(cv)=c(Mv)M(c\,\mathbf{v}) = c\,(M\mathbf{v}) for any scalar cc.

Both follow directly from the row-dot-column definition above. Linearity is not a coincidence — it is the property behind the superposition principle, which makes quantum evolution predictable. (Reversibility is a separate, stronger requirement: it comes from the gate being unitary, not from linearity alone.)

A concrete example

Let

M=(1234),v=(10).M = \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}, \qquad \mathbf{v} = \begin{pmatrix} 1 \\ 0 \end{pmatrix}.

Applying the rule:

Mv=(11+2031+40)=(13).M\mathbf{v} = \begin{pmatrix} 1 \cdot 1 + 2 \cdot 0 \\ 3 \cdot 1 + 4 \cdot 0 \end{pmatrix} = \begin{pmatrix} 1 \\ 3 \end{pmatrix}.

Notice what happened geometrically: v=0=(1,0)T\mathbf{v} = |0\rangle = (1,0)^T is the first standard basis vector, and MvM\mathbf{v} is exactly the first column of MM. This is a general fact: applying any matrix to a basis vector simply reads off the corresponding column.

Matrices as quantum gates

Every single-qubit quantum gate is a 2×22 \times 2 matrix acting on the two-component state vector (α,β)T(\alpha, \beta)^T. For example, the Pauli-X gate

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

swaps the two components: X0=1X|0\rangle = |1\rangle and X1=0X|1\rangle = |0\rangle — a quantum bit-flip. You can verify this by applying the matrix-times-column recipe to each basis vector.

Try it

This is a numerical exercise — your code should return a number. Apply the matrix M=(1234)M = \bigl(\begin{smallmatrix}1 & 2\\ 3 & 4\end{smallmatrix}\bigr) to the vector v=(1,0)T\mathbf{v} = (1,\,0)^T and return the first component of the result.

Run your code to see the quantum state.

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