08 — The Unitary Test
Two operations. One equation. That's the whole test for "is this a valid quantum gate?"
Where we left off

From the reversibility page: a quantum gate is valid if and only if its outputs are orthonormal (no overlap + no scaling). The formal one-line test for this is:

$$U^\dagger U = I$$

But what is \(U^\dagger\)? And how do you actually compute this? Two steps.

1 The Dagger (†) — Conjugate Transpose

The dagger \(U^\dagger\) (read "U-dagger") does two things to a matrix:

Step A: Transpose — flip rows and columns

$$\begin{pmatrix} a & b \\ c & d \end{pmatrix}^T = \begin{pmatrix} a & c \\ b & d \end{pmatrix}$$

Row 1 becomes column 1, row 2 becomes column 2. The diagonal stays put. The off-diagonal entries swap.

Step B: Complex conjugate — flip the sign of every \(i\)

$$\text{If } z = a + bi, \quad \text{then } z^* = a - bi$$

Every \(i\) becomes \(-i\). Real numbers don't change. That's it.

Dagger = both steps combined

$$U^\dagger = (U^T)^* = \text{transpose, then conjugate every entry}$$

(Order doesn't matter — conjugate then transpose gives the same result.)

Worked example: dagger of the Y gate

The Pauli Y gate is:

$$Y = \begin{pmatrix} 0 & -i \\ i & 0 \end{pmatrix}$$

Transpose (swap off-diagonal):

$$Y^T = \begin{pmatrix} 0 & i \\ -i & 0 \end{pmatrix}$$

Conjugate (flip sign of \(i\)):

$$Y^\dagger = \begin{pmatrix} 0 & -i \\ i & 0 \end{pmatrix}$$

Y† = Y

The dagger gave us back the same matrix. That's not always the case — it's a special property. (Matrices where \(U^\dagger = U\) are called Hermitian. All Pauli matrices are Hermitian.)

More daggers — build the pattern

X gate (bit flip)

$$X = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}$$

Transpose: swap 1 and 1 → same.
Conjugate: no \(i\)'s → same.

$$X^\dagger = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix} = X$$

Real symmetric → dagger = itself.

Z gate (phase flip)

$$Z = \begin{pmatrix} 1 & 0 \\ 0 & -1 \end{pmatrix}$$

Transpose: diagonal → same.
Conjugate: no \(i\)'s → same.

$$Z^\dagger = \begin{pmatrix} 1 & 0 \\ 0 & -1 \end{pmatrix} = Z$$

Real diagonal → dagger = itself.

H gate (Hadamard)

$$H = \frac{1}{\sqrt{2}}\begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix}$$

Transpose: swap (1,2) and (2,1) — both are \(\frac{1}{\sqrt{2}}\) → same.
Conjugate: no \(i\)'s → same.

$$H^\dagger = H$$

Real symmetric → dagger = itself.

S gate (quarter turn)

$$S = \begin{pmatrix} 1 & 0 \\ 0 & i \end{pmatrix}$$

Transpose: diagonal → same.
Conjugate: \(i \to -i\).

$$S^\dagger = \begin{pmatrix} 1 & 0 \\ 0 & -i \end{pmatrix} \neq S$$

Has complex entries → dagger is different!

Pattern: when does dagger change the matrix?

If the matrix is real and symmetric (like X, Z, H) — dagger does nothing. Transpose swaps entries that are already equal, conjugate has no \(i\)'s to flip.

If the matrix has complex entries (like Y, S, T) — dagger gives you something different. The conjugate flips the \(i\)'s.

2 The Test: \(U^\dagger U = I\)

Now we can state the full test. A matrix \(U\) is unitary (= valid quantum gate) if and only if:

$$U^\dagger U = I = \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix}$$

This single equation checks both orthonormality conditions at once:

What each entry of \(U^\dagger U\) checks

The columns of \(U\) are the gate's outputs: column 1 = \(|\text{out}_0\rangle\), column 2 = \(|\text{out}_1\rangle\).

When you compute \(U^\dagger U\), each entry is a braket between columns:

$$U^\dagger U = \begin{pmatrix} \langle\text{out}_0|\text{out}_0\rangle & \langle\text{out}_0|\text{out}_1\rangle \\ \langle\text{out}_1|\text{out}_0\rangle & \langle\text{out}_1|\text{out}_1\rangle \end{pmatrix} = \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix}$$

Identity matrix = columns are orthonormal. That's literally what \(I\) means.

Worked example: is X unitary?

$$X = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}, \quad X^\dagger = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}$$

Multiply \(X^\dagger X\):

$$X^\dagger X = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix} \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}$$

Top-left: row 1 · col 1 = \(0 \cdot 0 + 1 \cdot 1 = 1\) ← \(\langle\text{out}_0|\text{out}_0\rangle\) = normalized ✓

Top-right: row 1 · col 2 = \(0 \cdot 1 + 1 \cdot 0 = 0\) ← \(\langle\text{out}_0|\text{out}_1\rangle\) = orthogonal ✓

Bottom-left: row 2 · col 1 = \(1 \cdot 0 + 0 \cdot 1 = 0\) ← \(\langle\text{out}_1|\text{out}_0\rangle\) = orthogonal ✓

Bottom-right: row 2 · col 2 = \(1 \cdot 1 + 0 \cdot 0 = 1\) ← \(\langle\text{out}_1|\text{out}_1\rangle\) = normalized ✓

$$X^\dagger X = \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix} = I \quad\checkmark$$

Worked example: is S unitary?

This one has complex entries — the dagger actually changes the matrix.

$$S = \begin{pmatrix} 1 & 0 \\ 0 & i \end{pmatrix}, \quad S^\dagger = \begin{pmatrix} 1 & 0 \\ 0 & -i \end{pmatrix}$$

$$S^\dagger S = \begin{pmatrix} 1 & 0 \\ 0 & -i \end{pmatrix} \begin{pmatrix} 1 & 0 \\ 0 & i \end{pmatrix}$$

Top-left: \(1 \cdot 1 + 0 \cdot 0 = 1\) ✓

Top-right: \(1 \cdot 0 + 0 \cdot i = 0\) ✓

Bottom-left: \(0 \cdot 1 + (-i) \cdot 0 = 0\) ✓

Bottom-right: \(0 \cdot 0 + (-i)(i) = -i^2 = -(-1) = 1\) ✓

$$S^\dagger S = \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix} = I \quad\checkmark$$

The \(-i \cdot i = 1\) step is the key — complex conjugates multiply to give a real positive number. That's exactly why the dagger uses conjugation.

Failed example: is the "2X" gate unitary?

What if we scale X by 2? Outputs would be orthogonal but not normalized.

$$2X = \begin{pmatrix} 0 & 2 \\ 2 & 0 \end{pmatrix}, \quad (2X)^\dagger = \begin{pmatrix} 0 & 2 \\ 2 & 0 \end{pmatrix}$$

$$(2X)^\dagger (2X) = \begin{pmatrix} 0 & 2 \\ 2 & 0 \end{pmatrix} \begin{pmatrix} 0 & 2 \\ 2 & 0 \end{pmatrix} = \begin{pmatrix} 4 & 0 \\ 0 & 4 \end{pmatrix} \neq I$$

Off-diagonal = 0 → orthogonal ✓ (no pileup)

Diagonal = 4 → not normalized ✗ (outputs are too long — they'd scale up amplitudes)

This is the "direction is fine but magnitude is wrong" case from our earlier discussion.

Why the dagger? — The conjugate isn't arbitrary

You might wonder: why conjugate? Why not just transpose?

Because the inner product of complex vectors uses conjugation. For two vectors \(|a\rangle = \binom{a_1}{a_2}\) and \(|b\rangle = \binom{b_1}{b_2}\):

$$\langle a|b\rangle = a_1^* b_1 + a_2^* b_2$$

The left vector gets conjugated. That's not a choice — it's what makes inner products work correctly for complex numbers. (Without conjugation, \(\langle a|a\rangle\) could be zero or negative for nonzero vectors, which would break the idea of "length.")

The dagger is designed so that matrix multiplication \(U^\dagger U\) computes exactly the inner products between columns. Transpose lines up the rows and columns. Conjugation handles the complex part. Together they give you the braket.

Summary

The complete picture

  1. Dagger (†) = transpose + conjugate — a mechanical operation on any matrix
  2. U†U = I checks that the columns are orthonormal:
    • Diagonal entries = 1 → each column normalized (no scaling)
    • Off-diagonal entries = 0 → columns orthogonal (no pileup)
  3. Unitary matrix = matrix that passes U†U = I = valid quantum gate

← Why this matters: orthonormal outputs prevent amplitude pileup on superpositions.

Bonus property: U† is the inverse

If \(U^\dagger U = I\), then \(U^\dagger = U^{-1}\). The dagger is the undo button. Apply a gate, then apply its dagger, and you're back where you started. This is quantum reversibility in one equation.

Next: Meet the actual gates → X, Y, Z, H, S, T