English static mirror for SEO/GEO · AI-assisted translation · Read Chinese original

Gates Are Matrices: The Processing Machine for Quantum States

Forum topic · 小凯 · 2026-11-07

Summary

This is part 14 of a Chinese-language beginner-friendly quantum computing series. It explains that a quantum gate is nothing more than a table of complex numbers, i.e., a matrix, acting on a quantum state. Using a coffee-recipe analogy, the author teaches how to read single-qubit gate matrices: rows are inputs, columns are outputs, and each cell is the amplitude contributed to a basis state. Three fundamental gates are introduced: X (bit flip), Z (phase flip multiplying the |1⟩ amplitude by -1 without changing measurement probabilities), and H (Hadamard, creating equal superpositions with 1/√2 amplitudes). The post emphasizes linearity: a gate processes each superposition component independently and sums the results, so one matrix covers all possible inputs. It also explains why quantum gates must be reversible (unitarity): information cannot be destroyed, so classical irreversible gates like AND are illegal in quantum circuits. The article closes by pointing to the next installment on two-qubit states and entanglement.

Gates Are Matrices: The Processing Machine for Quantum States

> Prerequisites: Part 013 (amplitude bookkeeping) and Part 012 (the state sphere). No high-school matrix knowledge needed — we start from tables. > Next up: Part 015, "Two Bits Growing Together."

A coffee bean goes into a machine, and a cup of coffee comes out — inside the machine there is a recipe table: how many beans, how much water, what temperature, executed by the recipe, reliably reproducible. Give it different beans (Arabica, Robusta) and the same recipe produces different cups, but the recipe itself never changes.

A quantum gate is exactly such a machine: a quantum state goes in, a quantum state comes out; the entire content of the gate is a recipe table — in textbooks this table is called a matrix. This post has only two tasks: understand how to read the recipe table, and meet the three most common gates.

How to Read the Recipe Table

For a single-qubit gate, the recipe table is a small 2×2 grid. Its reading rule (memorize it word for word):

> Each cell of the table is a complex number (an arrow, from Part 011). The left column is the input, the top row is the output; the number in row i, column j tells you how much amplitude "input basis state j" contributes to "output basis state i."

Start with the simplest gate, the X gate — the quantum "switch":

| X gate | Out |0⟩ | Out |1⟩ | | :--- | :--- | :--- | | In |0⟩ | 0 | 1 | | In |1⟩ | 1 | 0 |

Reading example: input |0⟩, look at the "|0⟩ row": amplitude 0 contributed to output |0⟩, amplitude 1 contributed to output |1⟩ — |0⟩ enters, and becomes entirely |1⟩. Input |1⟩ similarly becomes |0⟩. The X gate is a flip switch, turning the coin from "heads" to "tails."

The recipe numbers can also be negative or complex — because the output is not probability (always positive) but amplitude (with direction, Part 013). Behold the Z gate:

| Z gate | Out |0⟩ | Out |1⟩ | | :--- | :--- | :--- | | In |0⟩ | 1 | 0 | | In |1⟩ | 0 | -1 |

Input |0⟩ passes through unchanged; the amplitude of input |1⟩ is multiplied by -1 — a 180-degree rotation, phase inversion. The Z gate itself changes no measurement probability (the probability of |1⟩ stays the same, since squaring removes the sign), but it reverses the phase relationship between the |1⟩ component and other amplitudes — remember the noise-canceling headphones from Part 004? The Z gate is that "inverting speaker," a key part of interference choreography. Feed Z a superposition with equal halves of |0⟩ and |1⟩: the |1⟩ half flips phase, equivalent to sliding the arrow on the state sphere half a turn around the vertical axis (a 180° longitude slide from Part 012).

One Gate Handles All Inputs

The most powerful property of the recipe table: the table defines a rule, not individual cases.

The same X gate table applies to "pure |0⟩," to "pure |1⟩," and to any superposition — because quantum mechanics has one more rule, linearity: a superposition through a gate = each component through the gate, then add the results up.

Example: input is a superposition with equal amplitude halves of |0⟩ and |1⟩. Through the X gate: the |0⟩ component becomes |1⟩, the |1⟩ component becomes |0⟩, and the two results add back with the original proportions — the output is still half-and-half, only the two amplitudes have swapped positions. The table swallows the entire superposition in one bite, no dismantling required.

This is the weight of the word "linear": the gate doesn't care what combination arrives; it faithfully processes each basis component. You'll see later that complex algorithms, for all their variety, decompose into repeated instances of this "table processing component by component." Linearity is both quantum computing's gift and the boundary of its power (one of the traps of the HHL algorithm, Part 046, lies exactly here).

The Third Gate: H, the Watershed Among Recipe Tables

Meet the third table — the H gate (the H of Hadamard; the name, as usual, is just terminology):

| H gate | Out |0⟩ | Out |1⟩ | | :--- | :--- | :--- | | In |0⟩ | +1/√2 | +1/√2 | | In |1⟩ | +1/√2 | -1/√2 |

It does two things: turns |0⟩ into an equal superposition of |0⟩ and |1⟩ (both + in the first row), and turns |1⟩ into two halves, with the |1⟩ component carrying a minus sign (one positive, one negative in the second row).

Note that it uses every weapon learned in this installment: recipes are complex numbers (011), recipes can be negative and phase-inverted (the negative-number magic of 013), and gates act on superpositions as wholes (linearity). Part 021 will devote a whole article to it — nearly every quantum algorithm begins with H, because it is "the machine that manufactures superposition." Today you only need to read the table: 1/√2 is the precise way to write "half an amplitude" (squared it is exactly a probability of one half — the first live-fire exercise of Part 013's "add first, square later").

Why Gates Must Be Reversible

Finally, a foreshadowing for Part 018: the recipe table of a quantum gate has a strict qualification requirement — no information loss. Different inputs must give different outputs (otherwise you couldn't trace back from output to input); in table language, each gate's inverse must also be a legal gate.

X, Z, and H all satisfy this: X applied twice returns to the start, Z twice returns, and H twice also returns. This is not coincidence — it is the fundamental law of quantum mechanics (unitarity): the universe, at its deepest level, does not allow "computation" to quietly destroy information. The classical AND gate (two inputs, one output) is outright illegal in the quantum world; all quantum circuits must be redesigned as reversible versions — in the circuits installment you'll see how this constraint shapes every single wire.

Taking the Analogy Apart

Where the coffee-recipe analogy borrows and where it breaks:

  • Disanalogy 1: Coffee recipes are positive-number proportions; gate recipes are directional complex amplitudes — "negative half a cup of coffee" doesn't exist, but "-1/√2 amplitude" is used every day.
  • Disanalogy 2: A coffee machine handles one batch at a time; under the linear law, a quantum gate processes all superposition components simultaneously — this "swallowing the whole superposition in one bite" ability is the biggest overshoot of the analogy.
  • Disanalogy 3: Recipe tables allow losses (the grounds are discarded after extraction); a quantum gate may not lose a single cell — reversibility is the law, not a craft preference.

What to Take Away

1. Gate = recipe table (matrix): cells hold complex amplitudes; X = switch, Z = phase flip, H = superposition maker — memorize these three tables, every later post uses them. 2. Linearity: a gate acts on a superposition as a whole = processing each component then recombining; the table is a rule covering all inputs. 3. Reversibility is the qualification line: quantum gates must not lose information; classical logic gates (like AND) are illegal in the quantum world — this constraint shapes everything up to error-correcting code design.

Hook for the next stop: you can now read single-qubit tables — what about two qubits? The table over four bases (|00⟩, |01⟩, |10⟩, |11⟩) is 4×4, four qubits give 16×16 — exponential growth... but entangled states have an even more astonishing reading: the ledger of two qubits cannot be split back into two books. Next: Part 015, "Two Bits Growing Together."

*(Original hashtags: quantum computing, from-coin-to-error-correction, quantum gates, matrices)*

Tags

#quantum-computing#quantum-gates#matrices#linear-algebra#hadamard-gate#unitarity#reversible-computation#tutorial

This page is an English static mirror generated for search and AI citation. It may be a full translation or structured summary of the Chinese original. Canonical interactive discussion lives on the Chinese page: https://zhichai.net/topic/178636848