
Quantum Gates: Matrices, Mirrors, and Beam Splitters#
Part 28 of the Learning Quantum Physics series.
A quantum gate is a matrix multiplied by the qubit column. On one photon that matrix is a mirror, a glass plate, a wave plate, or a beam splitter.
On one photon, the same rule is a piece of hardware. A mirror can swap two paths. A glass plate can change the phase of one path. A beam splitter can mix the two paths. A wave plate does the matching job when the qubit is the direction of the light wave.
This article gives each standard gate three things: the matrix, one use, and the piece of glass. Operators in Quantum Mechanics sorts a matrix into a gate, a measurement instruction, or a projector. Building a 20-Qubit Quantum System Using Photons builds a larger optical machine. Start here when the word gate is new.
1. A qubit is a column of two numbers#
A qubit is the smallest piece of quantum information. In this article the physical object is one photon. The photon carries two labels. The column stores one complex number on each label.
The two labels and their columns are
\[ |0\rangle = \begin{pmatrix} 1 \\ 0 \end{pmatrix}, \qquad |1\rangle = \begin{pmatrix} 0 \\ 1 \end{pmatrix}. \]The upper entry is the amplitude of label 0. The lower entry is the amplitude of label 1. An amplitude is the complex number written on that label.
A complex number has the form \(a + bi\). The number \(i\) satisfies \(i^{2} = -1\). The squared length of \(a + bi\) is \(a^{2} + b^{2}\). The squared length of a real number \(a\) is \(a^{2}\). The squared length of \(i\) is \(0^{2} + 1^{2} = 1\). The squared length of \(-1\) is 1. The squared length of \(-i\) is 1.
The chance of a label is the squared length of its amplitude. The two chances add to 1. For the column \(\alpha|0\rangle + \beta|1\rangle\),
\[ |\alpha|^{2} + |\beta|^{2} = 1. \]The vertical bars mean squared length. How Many Numbers Does a Qubit Need? counts the real numbers inside \(\alpha\) and \(\beta\). The vocabulary map keeps the column, the physical photon, and the laboratory reading as three separate objects.
A basis is a pair of state columns that can build every other state column by scaling and adding. \(|0\rangle\) and \(|1\rangle\) are that pair for one qubit. A state column with a nonzero amplitude on each label is a superposition. Superposition means the column is a mix of the two labels. The mix is in the numbers. One later reading still returns one label.
Two named mixes appear throughout this article:
\[ |+\rangle = \frac{|0\rangle + |1\rangle}{\sqrt{2}}, \qquad |-\rangle = \frac{|0\rangle - |1\rangle}{\sqrt{2}}. \]\(\sqrt{2}\) is the positive number whose square is 2. Then \(1/\sqrt{2}\) has squared length \(1/2\). Each label in \(|+\rangle\) has chance \(1/2\). Each label in \(|-\rangle\) has chance \(1/2\). The minus sign is the difference between those two columns.
2. A gate is a matrix, and this is how you use it#
A matrix is a grid of numbers. A gate on one qubit has 2 rows and 2 columns. Matrix multiplication is the general rule. One example is enough to use every later gate.
Pauli \(X\) is the matrix
\[ X = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}. \]Apply it to \(|0\rangle\):
\[ \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix} \begin{pmatrix} 1 \\ 0 \end{pmatrix} = \begin{pmatrix} 0 \\ 1 \end{pmatrix} = |1\rangle. \]The upper entry of the product is \(0\cdot 1 + 1\cdot 0 = 0\). The lower entry is \(1\cdot 1 + 0\cdot 0 = 1\). The same multiplication sends \(|1\rangle\) to \(|0\rangle\).
Read any one-qubit gate from the two columns of its matrix. The left column of the matrix is the result on \(|0\rangle\). The right column of the matrix is the result on \(|1\rangle\). In \(X\), the left column is \(|1\rangle\) and the right column is \(|0\rangle\). That is the swap. The state itself is also written as a column. In this article, “column of the matrix” means one vertical strip of the grid. “State column” means the list of amplitudes.
In a product of matrices, the rightmost matrix acts first. The product \(ZH\) means: apply \(H\), then apply \(Z\). §9 uses that order on a drawing.
Each gate in this article keeps the total of the chances equal to 1. The operators article writes the matrix test for that property. A global phase is a number of squared length 1 that multiplies every entry of the state column. The chances of the labels stay the same. A phase that multiplies only one label can change the next gate. §6 separates those two cases.
3. One photon, two paths#
One photon can carry the two labels in more than one way. This article uses two ways. The matrices stay the same. The glass changes.
Path qubit. The photon travels on one of two routes. The upper route is \(|0\rangle\). The lower route is \(|1\rangle\). A mirror, a glass plate, and a beam splitter act on these routes.
Polarization qubit. Polarization is the line along which the light wave moves back and forth. A horizontal line is \(|0\rangle\). A vertical line is \(|1\rangle\). A wave plate acts on that line. The photon article uses polarization for a larger machine.
A wavelength is the distance from one crest of the light wave to the next crest. A delay of one wavelength is a phase of \(2\pi\), a full turn. A delay of half a wavelength is a phase of \(\pi\), half a turn, 180 degrees. A delay of a quarter of a wavelength is a phase of \(\pi/2\), 90 degrees. A delay of one eighth of a wavelength is a phase of \(\pi/4\), 45 degrees.
The angle \(\phi\) in the next section is that delay, written in radians. \(\pi\) radians is 180 degrees.
A polarizing beam splitter is a different device from the beam splitter in §4. It sends horizontal light one way and vertical light the other way. In this article that device sits with the detectors, in the measurement step. §13 is that step. The vocabulary map shows the same device next to the detectors.
4. Mirror, glass plate, and beam splitter#
Three pieces cover the one-qubit path gates. Each piece has a matrix.
Straight path. The photon stays on its route. The matrix is the identity
\[ I = \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix}. \]\(I\) leaves every state column unchanged. In a drawing, \(I\) is an empty line on that qubit. You still write \(I\) when one qubit waits while another qubit goes through a gate. §10 uses that wait.
Mirrors that exchange the paths. The upper path leaves on the lower rail. The lower path leaves on the upper rail. When each reflection adds the same phase, the matrix is \(X\) from §2.
A reflection can multiply the amplitude by \(-1\). That factor is a phase of \(\pi\). If each path picks up the same \(-1\), each entry of the state column is multiplied by \(-1\). That is a global phase. The chances stay the same. If only the lower path picks up \(-1\), the matrix is \(Z\) in §6.
Glass plate on the lower path. The plate delays that path. The delay angle is \(\phi\). The matrix is
\[ P(\phi) = \begin{pmatrix} 1 & 0 \\ 0 & e^{i\phi} \end{pmatrix}. \]\(e^{i\phi}\) means \(\cos\phi + i\sin\phi\). On a circle of radius 1, \(\cos\phi\) is the horizontal coordinate and \(\sin\phi\) is the vertical coordinate, at angle \(\phi\) from the horizontal axis. Six Trigonometric Functions — One Diagram draws those coordinates. The squared length of \(e^{i\phi}\) is \(\cos^{2}\phi + \sin^{2}\phi = 1\), so the chance of label 1 stays the same.
The plate changes the phase and leaves the chance. The next beam splitter is where that phase changes the output path.
Symmetric 50/50 beam splitter. One photon enters. Each output route receives chance \(1/2\). In the symmetric coating, each reflection contributes a factor \(i\). The matrix is
\[ BS = \frac{1}{\sqrt{2}}\begin{pmatrix} 1 & i \\ i & 1 \end{pmatrix}. \]Applied to \(|0\rangle\),
\[ BS|0\rangle = \frac{|0\rangle + i|1\rangle}{\sqrt{2}}. \]The chance of each label is \(1/2\). The factor \(i\) is a phase, not a change of chance. §7 turns this matrix into the Hadamard gate with two phase plates.
%%{init: {"flowchart": {"rankSpacing": 18, "wrappingWidth": 480}}}%%
flowchart TD
A["Photon enters"]
B["50/50 beam splitter"]
C["Upper path, label 0"]
D["Lower path, label 1"]
A --> B
B --> C
B --> D
A beam splitter mixes the two paths of one photon. A gate on two photons needs the larger arrangement in §10.
5. Identity, X, and Y#
\(I\) and \(X\) are the straight path and the path exchange from §4.
On a polarization qubit, a half-wave plate does the swap. A half-wave plate delays its slow axis by half a wavelength relative to its fast axis. The fast axis is the direction in the glass that delays the wave less. The slow axis delays the wave more. Half a wavelength is a phase of \(\pi\).
Put the fast axis at 45 degrees to the horizontal. The matrix on horizontal and vertical light is \(X\). Horizontal becomes vertical. Vertical becomes horizontal.
Pauli \(Y\) swaps the labels and attaches the factors \(i\) and \(-i\):
\[ Y = \begin{pmatrix} 0 & -i \\ i & 0 \end{pmatrix}. \]The left column of the matrix says \(Y|0\rangle = i|1\rangle\). The right column of the matrix says \(Y|1\rangle = -i|0\rangle\). Each result has chance 1 on one label. The factors \(i\) and \(-i\) show up when this path later meets another path.
\(Y\) is \(X\) and \(Z\) with a global phase:
\[ Y = iXZ. \]Apply \(Z\) first, then \(X\). The product \(XZ\) equals \(-i\) times \(Y\). The factor \(-i\) multiplies each entry. On one qubit, with no second path to compare, the chances match the chances from \(Y\). The named matrix \(Y\) includes the factor \(i\) so that two copies of \(Y\) equal \(I\).
Hardware for that order: a phase of \(\pi\) on the lower path, then the mirrors that exchange the paths. On a polarization qubit, a half-wave plate with a horizontal fast axis is \(Z\), and a second half-wave plate at 45 degrees is \(X\). §6 writes \(Z\).
Pauli \(X\), Pauli \(Y\), and Pauli \(Z\) are three named matrices. Each one is a gate in this article. The same three matrices are also measurement instructions, with readings \(+1\) and \(-1\). The operators article lists those readings. This article uses the three matrices as gates.
6. Phase gates#
A phase gate multiplies label 1 and leaves label 0. The general plate is \(P(\phi)\) from §4. Three angles have names.
\[ Z = P(\pi) = \begin{pmatrix} 1 & 0 \\ 0 & -1 \end{pmatrix}, \qquad S = P(\pi/2) = \begin{pmatrix} 1 & 0 \\ 0 & i \end{pmatrix}, \qquad T = P(\pi/4) = \begin{pmatrix} 1 & 0 \\ 0 & e^{i\pi/4} \end{pmatrix}. \]\(e^{i\pi} = -1\), so \(Z\) multiplies label 1 by \(-1\). \(e^{i\pi/2} = i\), so \(S\) multiplies label 1 by \(i\). \(T\) multiplies label 1 by a phase of \(\pi/4\), which is 45 degrees.
Two copies multiply the phases:
\[ S^{2} = Z, \qquad T^{2} = S, \qquad Z^{2} = I. \]\(S\) then \(S\) is a phase of \(\pi\), which is \(Z\). \(T\) then \(T\) is a phase of \(\pi/2\), which is \(S\). \(Z\) then \(Z\) returns the original column.
Some books call \(T\) the \(\pi/8\) gate. That second name uses half of \(\pi/4\). This article uses the name \(T\) and the angle \(\pi/4\), the phase that multiplies the label-1 entry. The operators article records one extra common factor between \(T\) and a \(z\)-turn of \(\pi/4\).
On a path qubit, \(Z\), \(S\), and \(T\) are one glass plate on the lower path, at delays of half a wavelength, a quarter of a wavelength, and one eighth of a wavelength.
On a polarization qubit, a half-wave plate with its fast axis horizontal has the matrix \(Z\). A quarter-wave plate whose axes lie along horizontal and vertical multiplies one polarization by \(i\) relative to the other. The fast axis chooses \(S\), the matrix with lower entry \(i\), or the matrix with lower entry \(-i\). Two plates of either choice give \(Z\), because \(i^{2} = -1\) and \((-i)^{2} = -1\).
A plate whose delay is half the delay of a quarter-wave plate, with the same axes, is \(T\) up to that same choice of sign. The path plate of angle \(\pi/4\) is the unambiguous piece: it multiplies label 1 by \(e^{i\pi/4}\) and leaves label 0.
Use of a phase, before any second gate: the chances stay put. \(Z|0\rangle = |0\rangle\). \(Z|1\rangle = -|1\rangle\), and the chance of label 1 is still 1. The use shows up in §9, where \(Z\) sits between two Hadamard gates and moves the photon from the upper output to the lower output.
\(H\) and \(T\), repeated in the right order, can approximate any one-qubit gate as closely as you ask. \(S\) is two copies of \(T\). The kit uses the smaller step, \(T\).
7. The Hadamard gate and the beam splitter#
The Hadamard gate is
\[ H = \frac{1}{\sqrt{2}}\begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix}. \]The left column of the matrix is \(|+\rangle\). The right column of the matrix is \(|-\rangle\). So
\[ H|0\rangle = |+\rangle, \qquad H|1\rangle = |-\rangle. \]Apply \(H\) again and the original label returns: \(H|+\rangle = |0\rangle\) and \(H|-\rangle = |1\rangle\). Two copies of \(H\) equal \(I\).
One use of a single \(H\): start at \(|0\rangle\), where the chance of label 0 is 1, and produce an equal mix. Each label then has chance \(1/2\). A second \(H\) gathers that mix back to one label. A phase plate between the two \(H\) gates changes which label you get back. That is §9.
Polarization, direct match. A half-wave plate with its fast axis at 22.5 degrees to the horizontal has the matrix \(H\) on horizontal and vertical light. That plate is the Hadamard gate for a polarization qubit. The 45-degree plate from §5 is \(X\). The horizontal fast axis from §6 is \(Z\). One kind of plate, three angles, three gates.
Paths, symmetric beam splitter. The beam splitter matrix \(BS\) from §4 is not \(H\). The reflections carry a factor \(i\). Two phase plates remove it. The plate is
\[ P = P(-\pi/2) = \begin{pmatrix} 1 & 0 \\ 0 & -i \end{pmatrix}. \]The angle \(-\pi/2\) is \(-90\) degrees. \(e^{-i\pi/2} = -i\).
Walk \(|0\rangle\) through plate, then beam splitter, then plate.
The first plate sits on the lower path. \(|0\rangle\) has nothing on the lower path, so the column stays \(|0\rangle\). The beam splitter then produces
\[ \frac{|0\rangle + i|1\rangle}{\sqrt{2}}. \]The second plate multiplies the lower entry by \(-i\). The product \(i\cdot(-i) = 1\), so the column becomes
\[ \frac{|0\rangle + |1\rangle}{\sqrt{2}} = |+\rangle = H|0\rangle. \]Walk \(|1\rangle\) through the same three pieces.
The first plate multiplies \(|1\rangle\) by \(-i\). The beam splitter sends \(|1\rangle\) to \((i|0\rangle + |1\rangle)/\sqrt{2}\), so \(-i\) times that column is
\[ \frac{|0\rangle - i|1\rangle}{\sqrt{2}}. \]The second plate multiplies the lower entry by \(-i\). The product \((-i)\cdot(-i) = -1\), so the column becomes
\[ \frac{|0\rangle - |1\rangle}{\sqrt{2}} = |-\rangle = H|1\rangle. \]The result on \(|0\rangle\) matches the left column of \(H\). The result on \(|1\rangle\) matches the right column of \(H\). The product of the three matrices, with the rightmost plate acting first, equals \(H\):
\[ P\, BS\, P = H. \]A 50/50 beam splitter always splits the chance in half. The phase on a reflection depends on the thin layer on the glass. The symmetric layer puts \(i\) on each reflection. That matrix is \(BS\). A layer that puts a minus on one reflection, and no factor \(i\), gives the turn \(R_y(\pi/2)\) from §8. Either layer can build \(H\). The symmetric layer uses the two plates above. The minus layer uses one \(Z\) plate before the splitter, because \(H = R_y(\pi/2)\, Z\).
8. Turns and the square root of X#
A turn gate changes the mix of \(|0\rangle\) and \(|1\rangle\) by an angle \(\theta\). The matrix uses half of that angle, \(\theta/2\). One pure qubit can be drawn as a point on a sphere. \(\theta\) is the angle of the turn of that point. The pictures are in Seeing Three Dimensions. The matrices are these three.
\[ R_x(\theta) = \begin{pmatrix} \cos(\theta/2) & -i\sin(\theta/2) \\ -i\sin(\theta/2) & \cos(\theta/2) \end{pmatrix} \]\[ R_y(\theta) = \begin{pmatrix} \cos(\theta/2) & -\sin(\theta/2) \\ \sin(\theta/2) & \cos(\theta/2) \end{pmatrix} \]\[ R_z(\theta) = \begin{pmatrix} e^{-i\theta/2} & 0 \\ 0 & e^{i\theta/2} \end{pmatrix} \]\(R_z(\theta)\) multiplies label 0 by \(e^{-i\theta/2}\) and label 1 by \(e^{i\theta/2}\). The phase of label 1 minus the phase of label 0 is \(\theta\). The single plate \(P(\theta)\) multiplies only label 1, by \(e^{i\theta}\). The two matrices differ by the common factor \(e^{i\theta/2}\) on each entry. On one qubit the chances match. On a path qubit, \(R_z\) is a glass plate up to that common factor.
\(R_y(\theta)\) mixes the labels with real sines and cosines. At \(\theta = \pi/2\),
\[ R_y(\pi/2) = \frac{1}{\sqrt{2}}\begin{pmatrix} 1 & -1 \\ 1 & 1 \end{pmatrix}. \]\(Z\) first, then this matrix, equals \(H\):
\[ R_y(\pi/2)\, Z = H. \]\(R_x(\theta)\) is the mix that also carries factors of \(-i\). At \(\theta = \pi/2\),
\[ R_x(\pi/2) = \frac{1}{\sqrt{2}}\begin{pmatrix} 1 & -i \\ -i & 1 \end{pmatrix}. \]The square root of \(X\) is the gate you apply twice to get \(X\):
\[ \sqrt{X} = \frac{1}{2}\begin{pmatrix} 1+i & 1-i \\ 1-i & 1+i \end{pmatrix}, \qquad (\sqrt{X})^{2} = X. \]That matrix equals \(R_x(\pi/2)\) times the common factor \(e^{i\pi/4}\). A machine that can apply \(R_x(\pi/2)\) can apply \(\sqrt{X}\). The common factor is a global phase.
A turn of 180 degrees, \(\theta = \pi\), matches \(X\), \(Y\), or \(Z\) up to a global phase. The operators article writes the three factors. The chances match.
9. Gate order, and one full use#
Draw the gates from left to right. Time moves to the right. This drawing applies \(H\), then \(Z\), then \(H\), to a photon that starts at \(|0\rangle\):
|0⟩ —— H —— Z —— H ——
The matrix product for that order is \(HZH\). The rightmost \(H\) is the first box. The leftmost \(H\) is the last box.
Hadamard first:
\[ H|0\rangle = \frac{1}{\sqrt{2}}\begin{pmatrix} 1 \\ 1 \end{pmatrix}. \]Then \(Z\), which multiplies the lower entry by \(-1\):
\[ ZH|0\rangle = \frac{1}{\sqrt{2}}\begin{pmatrix} 1 \\ -1 \end{pmatrix}. \]Then \(H\) again. The state column from the line above is \(\frac{1}{\sqrt{2}}\) times the integer column \((1,\ -1)\). \(H\) already includes one factor \(\frac{1}{\sqrt{2}}\). The product of those two factors is \(\frac{1}{2}\):
\[ HZH|0\rangle = \frac{1}{2}\begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix}\begin{pmatrix} 1 \\ -1 \end{pmatrix}. \]The upper entry is \(\frac{1}{2}(1\cdot 1 + 1\cdot(-1)) = 0\). The lower entry is \(\frac{1}{2}(1\cdot 1 + (-1)\cdot(-1)) = 1\). The result is \(|1\rangle\).
The two amplitudes of label 0 canceled. The two amplitudes of label 1 added. That cancel-or-add step is interference. The minus sign from \(Z\) chose which label survived.
The same product, applied to every state column, is the matrix \(X\):
\[ HZH = X. \]So this row of three gates is another way to build the path exchange. The direct hardware for \(X\) is still the pair of mirrors, or the half-wave plate at 45 degrees. The three-gate row shows what a phase does when paths meet again.
Replace each drawn \(H\) by the glass from §7: plate \(P\), symmetric beam splitter, plate \(P\). Between those two stacks, put a phase of \(\pi\) on the lower path. A photon that enters on the upper path leaves on the lower path.
Two beam splitters in a row, with a phase plate on one path between them, are a Mach–Zehnder interferometer. With the symmetric layer, each beam splitter still needs the two plates \(P\), so that splitter-plus-plates equals the \(H\) in the drawing. Without those plates the output path is different, because \(BS\) and \(H\) are different matrices.
The other order is \(Z\) first and \(H\) second. \(Z|0\rangle = |0\rangle\), and then \(H|0\rangle = |+\rangle\). The product \(HZ\) applied to \(|0\rangle\) is \(|+\rangle\). The product \(HZH\) applied to \(|0\rangle\) is \(|1\rangle\). The two orders give two different state columns. Order is part of the gate.
10. Two-qubit gates#
Two qubits have four labels. This article writes them in this order: \(|00\rangle\), \(|01\rangle\), \(|10\rangle\), \(|11\rangle\). The first digit is qubit 1. The second digit is qubit 2. A two-qubit gate is a 4 by 4 matrix. The left column of the matrix is the result on \(|00\rangle\). The next column is the result on \(|01\rangle\). The next is the result on \(|10\rangle\). The right column is the result on \(|11\rangle\).
The symbol \(\otimes\) builds a 4 by 4 matrix from two 2 by 2 matrices. Every Kind of Product gives the rule. \(I \otimes X\) applies \(X\) to qubit 2 and leaves qubit 1:
\[ I \otimes X = \begin{pmatrix} 0 & 1 & 0 & 0 \\ 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \end{pmatrix}. \]It swaps \(|00\rangle\) with \(|01\rangle\), and swaps \(|10\rangle\) with \(|11\rangle\). Qubit 1 stays. Qubit 2 flips. That is the one-qubit \(X\) sitting on the second wire.
CNOT, controlled-\(X\). Qubit 1 is the control. Qubit 2 is the target. The control equal to 0 leaves the target. The control equal to 1 flips the target.
\[ \mathrm{CNOT} = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \end{pmatrix}. \]Read the columns of that matrix from left to right. \(|00\rangle\) stays \(|00\rangle\). \(|01\rangle\) stays \(|01\rangle\). \(|10\rangle\) becomes \(|11\rangle\). \(|11\rangle\) becomes \(|10\rangle\).
CZ, controlled-\(Z\). The matrix multiplies \(|11\rangle\) by \(-1\) and leaves the other three labels.
\[ \mathrm{CZ} = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & -1 \end{pmatrix}. \]\(H\) on the target turns one of these into the other. Apply \(H\) to qubit 2, then CNOT, then \(H\) to qubit 2 again. The product equals CZ. Apply \(H\) to qubit 2, then CZ, then \(H\) to qubit 2 again. The product equals CNOT. The one-qubit fact \(HZH = X\) is the same relation, acting only when the control is 1.
A controlled-\(U\) gate is the same pattern with a general one-qubit gate \(U\) in place of \(X\). Control 0 leaves the target. Control 1 applies \(U\) to the target. CNOT is controlled-\(X\). CZ is controlled-\(Z\). Controlled-\(S\) and controlled-\(T\) are the same pattern with the phase gates from §6.
SWAP exchanges the two digits. \(|01\rangle\) and \(|10\rangle\) trade places. \(|00\rangle\) and \(|11\rangle\) stay.
\[ \mathrm{SWAP} = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \end{pmatrix}. \]Three CNOT gates equal SWAP. Use CNOT with control on qubit 1, then CNOT with control on qubit 2, then CNOT with control on qubit 1 again. In the second of those, the target is qubit 1, so the matrix is the one that flips the first digit when the second digit is 1.
iSWAP swaps \(|01\rangle\) and \(|10\rangle\) and multiplies each of those two results by \(i\):
\[ \mathrm{iSWAP} = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & i & 0 \\ 0 & i & 0 & 0 \\ 0 & 0 & 0 & 1 \end{pmatrix}. \]On some superconducting chips, the two-qubit pulse has the matrix iSWAP, or a partial turn of that same swap. §14 names the machines. The matrix is the record of the pulse.
Paths and two photons. A beam splitter on one photon does not apply CNOT. Two photons barely change each other when they pass through ordinary glass. A two-qubit gate on photons is a larger arrangement: more than one beam splitter, sometimes an extra photon, and a detector that keeps some runs and drops the others. The photon article describes that limit. The matrices in this section stay the ones above. On a chip or an ion, a pulse can apply the same matrix without dropping runs.
11. One use: link the two qubits#
Start the two qubits at \(|0\rangle\), so the state column is \(|00\rangle\). Apply \(H\) to qubit 1. Qubit 2 waits. The state column is
\[ \frac{|00\rangle + |10\rangle}{\sqrt{2}}. \]The entries, in the order of §10, are \(1/\sqrt{2}\), \(0\), \(1/\sqrt{2}\), \(0\).
Apply CNOT. The \(|00\rangle\) piece stays. The \(|10\rangle\) piece becomes \(|11\rangle\). The state column is
\[ \frac{|00\rangle + |11\rangle}{\sqrt{2}}. \]The entries are \(1/\sqrt{2}\), \(0\), \(0\), \(1/\sqrt{2}\). The chance of 00 is \(1/2\). The chance of 11 is \(1/2\). The chance of 01 is 0. The chance of 10 is 0.
Read qubit 1. If the reading is 0, qubit 2 is 0. If the reading is 1, qubit 2 is 1. The two digits match. This state column is one Bell state. The four amplitudes are one joint list for the pair: the chance sits on 00 and on 11 together. That joint list is called entanglement. A pair of separate one-qubit mixes would also put chance on 01 and on 10. Bell’s Inequality: What It Actually Tests About Reality is a laboratory test of what that kind of link implies.
qubit 1: |0⟩ —— H —— ● ——
|
qubit 2: |0⟩ ———— ——— ⊕ ——
The filled circle is the control. The circle with a plus is the target, the \(X\) that fires when the control is 1. Time moves to the right. \(H\) is first. CNOT is second.
12. Three-qubit gates#
Three qubits have eight labels, from \(|000\rangle\) to \(|111\rangle\). The first digit is qubit 1, the second is qubit 2, and the third is qubit 3. The gate is an 8 by 8 matrix. Each label goes to one label, so each row has a single 1, and the other entries in that row are 0.
Toffoli, also called CCNOT. Qubit 1 and qubit 2 are the controls. Qubit 3 is the target. Both controls equal to 1 flips the target. The matrix swaps \(|110\rangle\) and \(|111\rangle\). The other six labels stay on the diagonal.
One use is AND, written onto a third qubit. A bit is a classical record that is already a definite 0 or a definite 1. Start the target at \(|0\rangle\). After Toffoli, the target reads 1 when each control is the definite label 1. The controls stay. The same 8 by 8 matrix also accepts mixes on the controls, because the gate multiplies the state column. It does not read the controls before it acts.
Fredkin, also called CSWAP. Qubit 1 is the control. When qubit 1 is 1, Fredkin swaps qubit 2 and qubit 3. The matrix swaps \(|101\rangle\) and \(|110\rangle\). The other six labels stay. In particular \(|111\rangle\) stays \(|111\rangle\), because swapping two 1s changes nothing. When the control is 0, every label stays.
Apply either gate twice and every label is back where it started. Two copies equal \(I\).
13. Measurement comes after the gates#
A detector records one label, 0 or 1, for each qubit it measures. The chance of the label is the squared length of that amplitude, taken from the state column the gates produced. One run records one label. The record is a bit. The state column is not written down. The measurement article is the laboratory side of that reading. The operators article keeps the piece of the state column that matches one reading and drops the rest. That matrix is a projector. The squared length of the piece is the chance.
For a polarization qubit, a polarizing beam splitter sends horizontal light to one detector and vertical light to the other. A click in the horizontal detector is the record 0. A click in the vertical detector is the record 1. That splitter is a measurement piece. It is not \(H\), and it is not the symmetric beam splitter of §4.
For a path qubit, one detector sits on the upper rail and one detector sits on the lower rail. A click on the upper rail is 0. A click on the lower rail is 1.
CNOT copies a definite label. Start the target at \(|0\rangle\). If the control is \(|0\rangle\), CNOT leaves \(|00\rangle\). If the control is \(|1\rangle\), CNOT produces \(|11\rangle\). A control that is definitely 0 or definitely 1 is now written on each of the two qubits.
The same matrix does not copy a mix. CNOT on \(|+\rangle\) with the target at \(|0\rangle\) produces the Bell column from §11, not two copies of \(|+\rangle\). There is no matrix that copies every unknown column onto a second qubit. The hardware article sets that limit next to the classical habit of splitting a wire.
14. Other machines use the same matrices#
A photon uses the glass in this article. A superconducting chip is a cold electrical circuit. There the same matrix is a pulse of short-wavelength radio waves. A trapped ion is one charged atom held in place. There the same matrix is a laser pulse. The programmer writes \(H\), \(X\), or CNOT in each case. Classical gate vs quantum gate makes that split: one matrix, several machines.
15. Which piece matches which gate#
| Gate | Piece |
|---|---|
| \(I\) | Straight path, or no plate |
| \(X\) | Mirrors that exchange the two paths, with the same phase on each reflection. Polarization: half-wave plate, fast axis at 45 degrees to horizontal |
| \(Y\) | Phase of \(\pi\) on the lower path, then the \(X\) mirrors. A global phase remains. See §5 |
| \(Z\) | Phase of \(\pi\) on the lower path only. Polarization: half-wave plate, fast axis horizontal |
| \(S\) | Phase of \(\pi/2\) on the lower path. Polarization: quarter-wave plate, axes along horizontal and vertical |
| \(T\) | Phase of \(\pi/4\) on the lower path |
| \(H\) | Half-wave plate, fast axis at 22.5 degrees to horizontal. Paths: plate \(P\), symmetric beam splitter, plate \(P\). See §7 |
| \(R_z(\theta)\) | A glass plate. The phase difference between the labels is \(\theta\), up to a global phase |
| \(R_y(\pi/2)\) | A 50/50 beam splitter whose reflection carries a minus, and no factor \(i\). The thin layer on the glass sets that phase |
| \(\sqrt{X}\) | \(R_x(\pi/2)\), up to the global phase \(e^{i\pi/4}\). Two copies equal \(X\) |
| CNOT, CZ, SWAP, iSWAP | The 4 by 4 matrices in §10. They use the larger two-photon arrangement in that section |
| Toffoli, Fredkin | The label swaps in §12 |
Related reading#
- Operators in Quantum Mechanics
- Building a 20-Qubit Quantum System Using Photons
- Before the Equations: A Mental Map of Quantum Mechanics Vocabulary
- How Many Numbers Does a Qubit Need?
- Seeing Three Dimensions: Colors, Planes, a Sphere and the Meaning of Rotation
- Quantum Measurement, Randomness, and Everyday Technology
- Quantum Hardware Is Not a Smaller or Stranger Classical Computer
Hashtags#
#QuantumGates #QuantumComputing #HadamardGate #BeamSplitter #PauliMatrices #CNOT #QuantumOptics #Qubit #LinearAlgebra #PhaseGate #ToffoliGate #MachZehnder

Comments: