Matrices move arrows
Four numbers that turn, flip or stretch every arrow at once. Every quantum gate is one.
Lesson 3 of 5 about 11 min
A machine for moving arrows
In the last lesson, a qubit turned out to be an arrow. A quantum computer works by moving that arrow: turning it, flipping it. Each of those moves is called a gate.
Every gate is written as a matrix: a small square of four numbers. Before we look at any numbers, let's see what matrices do. Pick a move and watch the whole grid follow it.
The matrix
1001Watch just two arrows
Here's the secret to reading any matrix. Keep your eye on just two arrows: right, (1, 0), and up, (0, 1). Once you know where those two land, you know where everything lands.
And the matrix simply writes them down. Its first column is where “right” lands. Its second column is where “up” lands.
Your matrix
1001right → (1, 0)
up → (0, 1)
Using a matrix on any arrow
So where does any other arrow, say (x, y), end up? Take x steps along the first column, then y steps along the second column, and add them up.
0110× (3, 1) =
3 × (0, 1) + 1 × (1, 0) = (1, 3)
Your turn
A flip you can't see
Here's another gate, called Z: 100−1. Its first column says right stays where it is. Its second column says up flips to point down.
Your turn
Now think of (0.6, 0.8) as a qubit. Its chances were 0.6² = 0.36 for 0 and 0.8² = 0.64 for 1.
Your turn
Gates never stretch
A qubit's arrow must always have length 1, so that its chances add up to 1. That's a strict rule for gates: they may turn arrows and flip them, but never stretch or shrink them.
One move after another
Quantum programs are just gates in a row: do one, then the next. But careful. With matrices, the order can change the result.
Turn, then flip
Flip, then turn
Your turn
The gate that makes a coin
One last gate, and it's a famous one: the Hadamard gate, or H. It takes the “right” arrow, a definite 0, and turns it to point exactly halfway between right and up.
The H gate
0.710.710.71−0.710.71 is 1/√2
One H gives a perfect 50-50 coin. A second H turns it straight back into a definite 0. Flip a real coin twice and it's still random. A qubit can “un-flip” itself, because the arrow remembers more than the chances do.
Your turn
What you now know
- A matrix moves every arrow at once: it can turn, flip, stretch or slant them.
- Its columns tell you where right (1, 0) and up (0, 1) land.
- Matrix × (x, y) = x × first column + y × second column.
- Quantum gates are matrices that never change an arrow's length. X swaps 0 and 1, Z flips a hidden sign, H makes a 50-50.
- In a sequence of gates, order matters.
Next: complex numbers, the last ingredient. They're what let quantum chances cancel out.