Mathematical foundations

Matrices and unitary transformations

Read a gate by its columns and derive its inverse from its adjoint.

18 minFoundations

Intuition

A matrix tells you where a linear transformation sends each basis vector. Its first column is the image of the first basis vector. Linearity extends that information to every superposition.

A unitary transformation preserves all inner products. In particular, a normalized input stays normalized. Its inverse is its adjoint, formed by conjugating and transposing the matrix.

Learning objectives

  • Apply a matrix to basis states
  • Distinguish unitary and Hermitian operators
  • Explain why gates preserve normalization

Interactive exploration

Use the controls to change the state and see its calculated readout. You can return to this experiment as you work through the derivation.

Circuit composer

q0 = leftmost bit
q0HS
  1. H q0
  2. S q0
Step 2 / 2

State at step 2

2 amplitudes
BasisAmplitudeProbability
|0⟩0.70750%
|1⟩0.707i50%

Each shot independently prepares this step’s state. A dense simulator stores 2ⁿ complex amplitudes for n wires. The composer is capped at six wires.

Mathematical foundation

The adjoint of U satisfies this identity precisely when the columns form an orthonormal basis. For square matrices this gives the inverse.

U†U=I,∥Uψ∥2=⟨ψ∣U†U∣ψ⟩=∥ψ∥2U^\dagger U=I,\qquad \|U\psi\|^2=\langle\psi|U^\dagger U|\psi\rangle=\|\psi\|^2

A Hermitian operator equals its adjoint and has real eigenvalues. Some operators, such as X, are both Hermitian and unitary. A phase gate with diagonal (1, i) is unitary and has adjoint diagonal (1, −i).

X=(0110),X∣+⟩=∣+⟩,X∣−⟩=−∣−⟩X=\begin{pmatrix}0&1\\1&0\end{pmatrix},\qquad X|+\rangle=|+\rangle,\quad X|-\rangle=-|-\rangle

Worked example

The vector |+⟩ has equal coordinates. X swaps them and leaves the ket unchanged. The coordinates of |−⟩ are opposite, so swapping them multiplies the vector by −1.

X12(1−1)=12(−11)X\tfrac{1}{\sqrt{2}}\binom{1}{-1}=\tfrac{1}{\sqrt{2}}\binom{-1}{1}

Guided experiment

Build an S gate and its inverse using P with angle −90°. Insert an initial H so the phase effect is visible, then step between the gates.

Go to the controls
Compare with the expected result

The inverse undoes the relative phase. The probabilities are normalized at every intermediate stage.

Understanding check

1. What is the inverse of S = diag(1, i)?
2. What property do all unitary gates preserve?

Next steps

Want to keep your results? Start your learning journey

Open Circuit Composer