Table of Contents

Three qubits

Three-qubit system is a quantum system of three qubits. The Hilbert space is $\mathbb{C}^8$, meaning eight complex amplitudes to describe it, not three.

A single qubit needs two amplitudes; two qubits need four; three qubits need eight. The state space doubles with every qubit you add. That exponential growth is what makes quantum computers interesting.

A general three-qubit state is a superposition over the eight computational basis states, with the normalization condition saying the total probability must be 1:

$$\lvert\psi\rangle = \begin{pmatrix}c_{000}\\c_{001}\\c_{010}\\c_{011}\\c_{100}\\c_{101}\\c_{110}\\c_{111}\end{pmatrix}, \qquad \lvert\psi\rangle = \sum_{x \in \{0,1\}^3} c_x \lvert x\rangle, \qquad \sum_{x \in \{0,1\}^3} |c_x|^2 = 1$$

Product states

The simplest three-qubit states are product states: states where all three qubits are independent of each other. If qubit 2 is in state $\lvert\alpha\rangle$, qubit 1 in $\lvert\beta\rangle$, and qubit 0 in $\lvert\gamma\rangle$, the combined state is just their tensor product:

$$\lvert\alpha\rangle\otimes\lvert\beta\rangle\otimes\lvert\gamma\rangle = \lvert\alpha\beta\gamma\rangle$$

The shorthand $\lvert\alpha\beta\gamma\rangle$ means $\lvert\alpha\rangle\otimes\lvert\beta\rangle\otimes\lvert\gamma\rangle$, with qubit 2 on the left (MSB) and qubit 0 on the right (LSB). There are infinitely many product states. The ones worth naming come from picking a standard single-qubit basis and using it for all three qubits.

Z-basis (Computational basis)

Pick $\lvert 0\rangle$ and $\lvert 1\rangle$ for each qubit and you get eight product states that look exactly like a classical 3-bit register. Each qubit is definitively 0 or 1 with no superposition. These eight states span all of $\mathbb{C}^8$, so every three-qubit state can be written in terms of them.

$$\lvert 000\rangle = \begin{pmatrix}1\\0\\0\\0\\0\\0\\0\\0\end{pmatrix} \quad \lvert 001\rangle = \begin{pmatrix}0\\1\\0\\0\\0\\0\\0\\0\end{pmatrix} \quad \cdots \quad \lvert 111\rangle = \begin{pmatrix}0\\0\\0\\0\\0\\0\\0\\1\end{pmatrix}$$

State Description
$\lvert 000\rangle$ All qubits in $\lvert 0\rangle$. Default initial state of every qubit register.
$\lvert 001\rangle$ Qubits 2 and 1 are $\lvert 0\rangle$, qubit 0 is $\lvert 1\rangle$.
$\lvert 010\rangle$ Qubits 2 and 0 are $\lvert 0\rangle$, qubit 1 is $\lvert 1\rangle$.
$\lvert 011\rangle$ Qubit 2 is $\lvert 0\rangle$, qubits 1 and 0 are $\lvert 1\rangle$.
$\lvert 100\rangle$ Qubit 2 is $\lvert 1\rangle$, qubits 1 and 0 are $\lvert 0\rangle$.
$\lvert 101\rangle$ Qubits 2 and 0 are $\lvert 1\rangle$, qubit 1 is $\lvert 0\rangle$.
$\lvert 110\rangle$ Qubits 2 and 1 are $\lvert 1\rangle$, qubit 0 is $\lvert 0\rangle$.
$\lvert 111\rangle$ All qubits in $\lvert 1\rangle$.

X-basis (Hadamard basis)

Pick $\lvert +\rangle$ and $\lvert -\rangle$ for each qubit instead. These states look “spread out” in the computational basis, because $\lvert +\rangle = (\lvert 0\rangle + \lvert 1\rangle)/\sqrt{2}$ mixes both. In the X basis they are perfectly sharp. You get from the computational basis to this one by applying a Hadamard to every qubit.

$$\lvert +++\rangle = \frac{1}{2\sqrt{2}}\begin{pmatrix}1\\1\\1\\1\\1\\1\\1\\1\end{pmatrix} \quad \lvert ++-\rangle = \frac{1}{2\sqrt{2}}\begin{pmatrix}1\\{-1}\\1\\{-1}\\1\\{-1}\\1\\{-1}\end{pmatrix} \quad \lvert +-+\rangle = \frac{1}{2\sqrt{2}}\begin{pmatrix}1\\1\\{-1}\\{-1}\\1\\1\\{-1}\\{-1}\end{pmatrix} \quad \lvert +--\rangle = \frac{1}{2\sqrt{2}}\begin{pmatrix}1\\{-1}\\{-1}\\1\\1\\{-1}\\{-1}\\1\end{pmatrix}$$

$$\lvert -++\rangle = \frac{1}{2\sqrt{2}}\begin{pmatrix}1\\1\\1\\1\\{-1}\\{-1}\\{-1}\\{-1}\end{pmatrix} \quad \lvert -+-\rangle = \frac{1}{2\sqrt{2}}\begin{pmatrix}1\\{-1}\\1\\{-1}\\{-1}\\1\\{-1}\\1\end{pmatrix} \quad \lvert --+\rangle = \frac{1}{2\sqrt{2}}\begin{pmatrix}1\\1\\{-1}\\{-1}\\{-1}\\{-1}\\1\\1\end{pmatrix} \quad \lvert ---\rangle = \frac{1}{2\sqrt{2}}\begin{pmatrix}1\\{-1}\\{-1}\\1\\{-1}\\1\\1\\{-1}\end{pmatrix}$$

State Expansion in computational basis Description
$\lvert +++\rangle$ $\tfrac{1}{2\sqrt{2}}(\lvert 000\rangle + \lvert 001\rangle + \lvert 010\rangle + \lvert 011\rangle + \lvert 100\rangle + \lvert 101\rangle + \lvert 110\rangle + \lvert 111\rangle)$ All qubits in $\lvert +\rangle$. Uniform superposition over all eight computational basis states; $H^{\otimes 3}\lvert 000\rangle = \lvert +++\rangle$.
$\lvert ++-\rangle$ $\tfrac{1}{2\sqrt{2}}(\lvert 000\rangle - \lvert 001\rangle + \lvert 010\rangle - \lvert 011\rangle + \lvert 100\rangle - \lvert 101\rangle + \lvert 110\rangle - \lvert 111\rangle)$ Qubits 2 and 1 in $\lvert +\rangle$, qubit 0 in $\lvert -\rangle$.
$\lvert +-+\rangle$ $\tfrac{1}{2\sqrt{2}}(\lvert 000\rangle + \lvert 001\rangle - \lvert 010\rangle - \lvert 011\rangle + \lvert 100\rangle + \lvert 101\rangle - \lvert 110\rangle - \lvert 111\rangle)$ Qubits 2 and 0 in $\lvert +\rangle$, qubit 1 in $\lvert -\rangle$.
$\lvert +--\rangle$ $\tfrac{1}{2\sqrt{2}}(\lvert 000\rangle - \lvert 001\rangle - \lvert 010\rangle + \lvert 011\rangle + \lvert 100\rangle - \lvert 101\rangle - \lvert 110\rangle + \lvert 111\rangle)$ Qubit 2 in $\lvert +\rangle$, qubits 1 and 0 in $\lvert -\rangle$.
$\lvert -++\rangle$ $\tfrac{1}{2\sqrt{2}}(\lvert 000\rangle + \lvert 001\rangle + \lvert 010\rangle + \lvert 011\rangle - \lvert 100\rangle - \lvert 101\rangle - \lvert 110\rangle - \lvert 111\rangle)$ Qubit 2 in $\lvert -\rangle$, qubits 1 and 0 in $\lvert +\rangle$.
$\lvert -+-\rangle$ $\tfrac{1}{2\sqrt{2}}(\lvert 000\rangle - \lvert 001\rangle + \lvert 010\rangle - \lvert 011\rangle - \lvert 100\rangle + \lvert 101\rangle - \lvert 110\rangle + \lvert 111\rangle)$ Qubits 2 and 0 in $\lvert -\rangle$, qubit 1 in $\lvert +\rangle$.
$\lvert --+\rangle$ $\tfrac{1}{2\sqrt{2}}(\lvert 000\rangle + \lvert 001\rangle - \lvert 010\rangle - \lvert 011\rangle - \lvert 100\rangle - \lvert 101\rangle + \lvert 110\rangle + \lvert 111\rangle)$ Qubits 2 and 1 in $\lvert -\rangle$, qubit 0 in $\lvert +\rangle$.
$\lvert ---\rangle$ $\tfrac{1}{2\sqrt{2}}(\lvert 000\rangle - \lvert 001\rangle - \lvert 010\rangle + \lvert 011\rangle - \lvert 100\rangle + \lvert 101\rangle + \lvert 110\rangle - \lvert 111\rangle)$ All qubits in $\lvert -\rangle$.

Y-basis (Phase basis)

Pick $\lvert +i\rangle$ and $\lvert -i\rangle$ for each qubit. These are the eigenstates of the Y gate. The coefficients are complex, so the Y-basis states are the first ones on this page with imaginary entries. You get from the computational basis to the Y basis by applying $SH$ to every qubit ($H$ first, then $S$).

$$\lvert{+i,+i,+i}\rangle = \frac{1}{2\sqrt{2}}\begin{pmatrix}1\\i\\i\\{-1}\\i\\{-1}\\{-1}\\{-i}\end{pmatrix} \quad \lvert{+i,+i,-i}\rangle = \frac{1}{2\sqrt{2}}\begin{pmatrix}1\\{-i}\\i\\1\\i\\1\\{-1}\\i\end{pmatrix} \quad \lvert{+i,-i,+i}\rangle = \frac{1}{2\sqrt{2}}\begin{pmatrix}1\\i\\{-i}\\1\\i\\{-1}\\1\\i\end{pmatrix} \quad \lvert{+i,-i,-i}\rangle = \frac{1}{2\sqrt{2}}\begin{pmatrix}1\\{-i}\\{-i}\\{-1}\\i\\1\\1\\{-i}\end{pmatrix}$$

$$\lvert{-i,+i,+i}\rangle = \frac{1}{2\sqrt{2}}\begin{pmatrix}1\\i\\i\\{-1}\\{-i}\\1\\1\\i\end{pmatrix} \quad \lvert{-i,+i,-i}\rangle = \frac{1}{2\sqrt{2}}\begin{pmatrix}1\\{-i}\\i\\1\\{-i}\\{-1}\\1\\{-i}\end{pmatrix} \quad \lvert{-i,-i,+i}\rangle = \frac{1}{2\sqrt{2}}\begin{pmatrix}1\\i\\{-i}\\1\\{-i}\\1\\{-1}\\{-i}\end{pmatrix} \quad \lvert{-i,-i,-i}\rangle = \frac{1}{2\sqrt{2}}\begin{pmatrix}1\\{-i}\\{-i}\\{-1}\\{-i}\\{-1}\\{-1}\\i\end{pmatrix}$$

State Expansion in computational basis Description
$\lvert +i,+i,+i\rangle$ $\tfrac{1}{2\sqrt{2}}(\lvert 000\rangle + i\lvert 001\rangle + i\lvert 010\rangle - \lvert 011\rangle + i\lvert 100\rangle - \lvert 101\rangle - \lvert 110\rangle - i\lvert 111\rangle)$ All qubits in $\lvert +i\rangle$.
$\lvert +i,+i,-i\rangle$ $\tfrac{1}{2\sqrt{2}}(\lvert 000\rangle - i\lvert 001\rangle + i\lvert 010\rangle + \lvert 011\rangle + i\lvert 100\rangle + \lvert 101\rangle - \lvert 110\rangle + i\lvert 111\rangle)$ Qubits 2 and 1 in $\lvert +i\rangle$, qubit 0 in $\lvert -i\rangle$.
$\lvert +i,-i,+i\rangle$ $\tfrac{1}{2\sqrt{2}}(\lvert 000\rangle + i\lvert 001\rangle - i\lvert 010\rangle + \lvert 011\rangle + i\lvert 100\rangle - \lvert 101\rangle + \lvert 110\rangle + i\lvert 111\rangle)$ Qubits 2 and 0 in $\lvert +i\rangle$, qubit 1 in $\lvert -i\rangle$.
$\lvert +i,-i,-i\rangle$ $\tfrac{1}{2\sqrt{2}}(\lvert 000\rangle - i\lvert 001\rangle - i\lvert 010\rangle - \lvert 011\rangle + i\lvert 100\rangle + \lvert 101\rangle + \lvert 110\rangle - i\lvert 111\rangle)$ Qubit 2 in $\lvert +i\rangle$, qubits 1 and 0 in $\lvert -i\rangle$.
$\lvert -i,+i,+i\rangle$ $\tfrac{1}{2\sqrt{2}}(\lvert 000\rangle + i\lvert 001\rangle + i\lvert 010\rangle - \lvert 011\rangle - i\lvert 100\rangle + \lvert 101\rangle + \lvert 110\rangle + i\lvert 111\rangle)$ Qubit 2 in $\lvert -i\rangle$, qubits 1 and 0 in $\lvert +i\rangle$.
$\lvert -i,+i,-i\rangle$ $\tfrac{1}{2\sqrt{2}}(\lvert 000\rangle - i\lvert 001\rangle + i\lvert 010\rangle + \lvert 011\rangle - i\lvert 100\rangle - \lvert 101\rangle + \lvert 110\rangle - i\lvert 111\rangle)$ Qubits 2 and 0 in $\lvert -i\rangle$, qubit 1 in $\lvert +i\rangle$.
$\lvert -i,-i,+i\rangle$ $\tfrac{1}{2\sqrt{2}}(\lvert 000\rangle + i\lvert 001\rangle - i\lvert 010\rangle + \lvert 011\rangle - i\lvert 100\rangle + \lvert 101\rangle - \lvert 110\rangle - i\lvert 111\rangle)$ Qubits 2 and 1 in $\lvert -i\rangle$, qubit 0 in $\lvert +i\rangle$.
$\lvert -i,-i,-i\rangle$ $\tfrac{1}{2\sqrt{2}}(\lvert 000\rangle - i\lvert 001\rangle - i\lvert 010\rangle - \lvert 011\rangle - i\lvert 100\rangle - \lvert 101\rangle - \lvert 110\rangle + i\lvert 111\rangle)$ All qubits in $\lvert -i\rangle$.

Entangled states

Some three-qubit states cannot be written as $\lvert\alpha\rangle\otimes\lvert\beta\rangle\otimes\lvert\gamma\rangle$ for any choice of single-qubit states. These are entangled states. Three-qubit entanglement is richer than two-qubit entanglement: there are two genuinely distinct classes of tripartite entanglement, and no local operations can convert a state from one class to the other.

GHZ states

The GHZ states (Greenberger-Horne-Zeilinger) are the canonical maximally entangled three-qubit states. The two principal ones are equal superpositions of $\lvert 000\rangle$ and $\lvert 111\rangle$ with a relative phase:

$$\lvert\mathrm{GHZ}^+\rangle = \frac{1}{\sqrt{2}}\begin{pmatrix}1\\0\\0\\0\\0\\0\\0\\1\end{pmatrix} \qquad \lvert\mathrm{GHZ}^-\rangle = \frac{1}{\sqrt{2}}\begin{pmatrix}1\\0\\0\\0\\0\\0\\0\\{-1}\end{pmatrix}$$

State Definition Notes
$\lvert\mathrm{GHZ}^+\rangle$ $\tfrac{1}{\sqrt{2}}(\lvert 000\rangle + \lvert 111\rangle)$ Prepared from $\lvert 000\rangle$ by $H$ on qubit 0, then CX(0,1), then CX(0,2).
$\lvert\mathrm{GHZ}^-\rangle$ $\tfrac{1}{\sqrt{2}}(\lvert 000\rangle - \lvert 111\rangle)$ Apply $Z$ to any qubit of $\lvert\mathrm{GHZ}^+\rangle$. The minus sign is invisible in Z-basis measurements.

Measuring any one qubit of $\lvert\mathrm{GHZ}^+\rangle$ in the Z basis gives 0 or 1 with equal probability and instantly fixes the outcomes of the other two: result 0 collapses the state to $\lvert 000\rangle$, result 1 to $\lvert 111\rangle$. All three qubits are always found in the same state. This all-or-nothing correlation disappears entirely if any single qubit is lost: tracing out one qubit of a GHZ state leaves the remaining two in a completely mixed state with no entanglement.

W states

The W states are the other canonical class of tripartite entanglement. Unlike GHZ states, W states are robust to qubit loss: tracing out any one qubit leaves the remaining two in a partially entangled state rather than a product state.

$$\lvert W\rangle = \frac{1}{\sqrt{3}}\begin{pmatrix}0\\1\\1\\0\\1\\0\\0\\0\end{pmatrix} \qquad \lvert\bar{W}\rangle = \frac{1}{\sqrt{3}}\begin{pmatrix}0\\0\\0\\1\\0\\1\\1\\0\end{pmatrix}$$

State Definition Notes
$\lvert W\rangle$ $\tfrac{1}{\sqrt{3}}(\lvert 001\rangle + \lvert 010\rangle + \lvert 100\rangle)$ Exactly one qubit is $\lvert 1\rangle$, all three positions equally weighted.
$\lvert\bar{W}\rangle$ $\tfrac{1}{\sqrt{3}}(\lvert 011\rangle + \lvert 101\rangle + \lvert 110\rangle)$ Exactly two qubits are $\lvert 1\rangle$; the bitwise complement of $\lvert W\rangle$.

Measuring qubit 0 of $\lvert W\rangle$ in the Z basis: result 1 with probability $\tfrac{1}{3}$, leaving qubits 2 and 1 in $\lvert 00\rangle$. Result 0 with probability $\tfrac{2}{3}$, leaving qubits 2 and 1 in $\tfrac{1}{\sqrt{2}}(\lvert 01\rangle + \lvert 10\rangle) = \lvert\Psi^+\rangle$, a Bell state. That residual entanglement after partial measurement is the signature of W-class entanglement and has no GHZ-class analogue.

Gates

Three-qubit gates are $8\times 8$ unitary matrices acting on $\mathbb{C}^8$. The two most common ones are CCX (Toffoli) and CSWAP (Fredkin). Row and column ordering follows the computational basis: $\lvert 000\rangle, \lvert 001\rangle, \ldots, \lvert 111\rangle$.

$$CCX = \begin{pmatrix} 1&0&0&0&0&0&0&0\\ 0&1&0&0&0&0&0&0\\ 0&0&1&0&0&0&0&0\\ 0&0&0&1&0&0&0&0\\ 0&0&0&0&1&0&0&0\\ 0&0&0&0&0&1&0&0\\ 0&0&0&0&0&0&0&1\\ 0&0&0&0&0&0&1&0 \end{pmatrix} \qquad CSWAP = \begin{pmatrix} 1&0&0&0&0&0&0&0\\ 0&1&0&0&0&0&0&0\\ 0&0&1&0&0&0&0&0\\ 0&0&0&1&0&0&0&0\\ 0&0&0&0&1&0&0&0\\ 0&0&0&0&0&0&1&0\\ 0&0&0&0&0&1&0&0\\ 0&0&0&0&0&0&0&1 \end{pmatrix}$$

CCX flips qubit 0 when both qubits 2 and 1 are $\lvert 1\rangle$ (controls on qubits 2 and 1; Qiskit: ccx(2, 1, 0)). It is the three-qubit generalization of CX and is classically universal: any classical Boolean circuit can be simulated by a circuit of Toffoli gates alone. CSWAP swaps qubits 1 and 0 when qubit 2 is $\lvert 1\rangle$ (control on qubit 2; Qiskit: cswap(2, 1, 0)). For a full list see Three-qubit gates.

Qiskit

# Requires: pip install qiskit qiskit-aer
# Run: python ghz.py
# Prepares |GHZ+⟩ and samples 1000 shots; expect roughly equal counts of '000' and '111'.
from qiskit import QuantumCircuit
from qiskit_aer import AerSimulator
 
qc = QuantumCircuit(3, 3)
qc.h(0)       # Hadamard on qubit 0 → superposition
qc.cx(0, 1)   # CX: control=qubit 0, target=qubit 1 → entangle
qc.cx(0, 2)   # CX: control=qubit 0, target=qubit 2 → entangle
qc.measure([0, 1, 2], [0, 1, 2])
 
counts = AerSimulator().run(qc, shots=1000).result().get_counts()
print(counts)  # {'000': ~500, '111': ~500}