Site Tools


two-qubits

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
two-qubits [June 13, 2026 at 02:30] Ivan Janevskitwo-qubits [June 13, 2026 at 03:23] (current) Ivan Janevski
Line 1: Line 1:
 # Two qubits # Two qubits
-**Two-qubit system** is a quantum system of two qubits. The state space is $\mathbb{C}^2\otimes\mathbb{C}^2 \cong \mathbb{C}^4$: you need four complex amplitudes to describe it, not two.+**Two-qubit system** is a quantum system of two qubits. The Hilbert space is $\mathbb{C}^4$, meaning four complex amplitudes to describe it, not two.
  
 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 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.
Line 6: Line 6:
 A general two-qubit state is a superposition over the four computational basis states, with the normalization condition saying the total probability must be 1: A general two-qubit state is a superposition over the four computational basis states, with the normalization condition saying the total probability must be 1:
  
-$$\lvert\psi\rangle = c_{00}\lvert 00\rangle + c_{01}\lvert 01\rangle + c_{10}\lvert 10\rangle + c_{11}\lvert 11\rangle, \qquad |c_{00}|^2 + |c_{01}|^2 + |c_{10}|^2 + |c_{11}|^2 = 1$$+$$\lvert\psi\rangle = \begin{pmatrix}c_{00}\\c_{01}\\c_{10}\\c_{11}\end{pmatrix}, \qquad \lvert\psi\rangle = c_{00}\underbrace{\begin{pmatrix}1\\0\\0\\0\end{pmatrix}}_{\lvert 00\rangle+ c_{01}\underbrace{\begin{pmatrix}0\\1\\0\\0\end{pmatrix}}_{\lvert 01\rangle+ c_{10}\underbrace{\begin{pmatrix}0\\0\\1\\0\end{pmatrix}}_{\lvert 10\rangle+ c_{11}\underbrace{\begin{pmatrix}0\\0\\0\\1\end{pmatrix}}_{\lvert 11\rangle}, \qquad |c_{00}|^2 + |c_{01}|^2 + |c_{10}|^2 + |c_{11}|^2 = 1$$
  
 ## Product states ## Product states
  
-The simplest two-qubit states are **product states**: states where the two qubits are independent of each other. If qubit is in $a\lvert 0\rangle + b\lvert 1\rangle$ and qubit is in $c\lvert 0\rangle + d\lvert 1\rangle$, the combined state is just their tensor product:+The simplest two-qubit states are **product states**: states where the two qubits are independent of each other. If qubit is in $a\lvert 0\rangle + b\lvert 1\rangle$ and qubit is in $c\lvert 0\rangle + d\lvert 1\rangle$, the combined state is just their tensor product:
  
-$$\lvert\psi_0\rangle\otimes\lvert\psi_1\rangle = ac\lvert 00\rangle + ad\lvert 01\rangle + bc\lvert 10\rangle + bd\lvert 11\rangle$$+$$\lvert\psi_1\rangle\otimes\lvert\psi_0\rangle = ac\lvert 00\rangle + ad\lvert 01\rangle + bc\lvert 10\rangle + bd\lvert 11\rangle$$
  
-The shorthand $\lvert\psi_0\psi_1\rangle$ means $\lvert\psi_0\rangle\otimes\lvert\psi_1\rangle$. There are infinitely many product states — any pair of single-qubit states gives you one. The ones worth naming come from picking a standard single-qubit basis and using it for both qubits.+The shorthand $\lvert\psi_1\psi_0\rangle$ means $\lvert\psi_1\rangle\otimes\lvert\psi_0\rangle$. There are infinitely many product states. Any pair of single-qubit states gives you one. The ones worth naming come from picking a standard single-qubit basis and using it for both qubits.
  
 ### Z-basis (Computational basis) ### Z-basis (Computational basis)
  
-Pick $\lvert 0\rangle$ and $\lvert 1\rangle$ for each qubit and you get four product states that look exactly like a classical 2-bit register. Each qubit is definitively 0 or 1 with no superposition. These four states span all of $\mathbb{C}^4$, so every two-qubit state can be written in terms of them.+Pick [[ket-0|$\lvert 0\rangle$]] and [[ket-1|$\lvert 1\rangle$]] for each qubit and you get four product states that look exactly like a classical 2-bit register. Each qubit is definitively 0 or 1 with no superposition. These four states span all of $\mathbb{C}^4$, so every two-qubit state can be written in terms of them.
  
 $$\lvert 00\rangle = \begin{pmatrix} 1\\0\\0\\0 \end{pmatrix} $$\lvert 00\rangle = \begin{pmatrix} 1\\0\\0\\0 \end{pmatrix}
Line 26: Line 26:
 $$ $$
  
-^ State ^ Preparation from $\lvert 00\rangle$ ^ Description ^ +^ State ^ Description ^ 
-| [[ket-00|$\lvert 00\rangle$]] | default | Both qubits are $\lvert 0\rangle$. The default initial state of every qubit register; $H\otimes I$ then CNOT produces $\lvert\Phi^+\rangle$ directly. | +| [[ket-00|$\lvert 00\rangle$]] | Both qubits are $\lvert 0\rangle$. Default initial state of every qubit register. | 
-| [[ket-01|$\lvert 01\rangle$]] | $X$ on qubit | Qubit 0 is $\lvert 0\rangle$, qubit is $\lvert 1\rangle$. $H\otimes I$ then CNOT produces $\lvert\Psi^+\rangle$. | +| [[ket-01|$\lvert 01\rangle$]] | Qubit 1 is $\lvert 0\rangle$, qubit is $\lvert 1\rangle$. | 
-| [[ket-10|$\lvert 10\rangle$]] | $X$ on qubit 0 | Qubit is $\lvert 1\rangle$, qubit is $\lvert 0\rangle$. $H\otimes I$ then CNOT produces $\lvert\Phi^-\rangle$. | +| [[ket-10|$\lvert 10\rangle$]] | Qubit is $\lvert 1\rangle$, qubit is $\lvert 0\rangle$. | 
-| [[ket-11|$\lvert 11\rangle$]] | $X$ on both qubits | Both qubits are $\lvert 1\rangle$. $H\otimes I$ then CNOT produces $\lvert\Psi^-\rangle$. |+| [[ket-11|$\lvert 11\rangle$]] | Both qubits are $\lvert 1\rangle$. |
  
-Notice the pattern: applying $H\otimes I$ then CNOT to each computational basis state gives a different Bell state. The same circuit run in reverse (CNOT then $H\otimes I$) is the Bell measurement, which maps every Bell state back to its corresponding computational basis state. This makes the two bases inverses of each other.+### X-basis (Hadamard basis)
  
-### X-basis +Pick [[ket-plus|$\lvert +\rangle$]] and [[ket-minus|$\lvert -\rangle$]] for each qubit instead. These states look "spread out" in the computational basis, because [[ket-plus|$\lvert +\rangle$]] $= (\lvert 0\rangle + \lvert 1\rangle)/\sqrt{2}$ mixes both. But in the X basis they are perfectly sharp, just like $\lvert 00\rangle$ is sharp in the Z basis. You get from the computational basis to this one by applying a Hadamard to every qubit.
- +
-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. But in the X basis they are perfectly sharp, just like $\lvert 00\rangle$ is sharp in the Z basis. You get from the computational basis to this one by applying a Hadamard to every qubit.+
  
 $$\lvert ++\rangle = \frac{1}{2}\begin{pmatrix}1\\1\\1\\1\end{pmatrix} $$\lvert ++\rangle = \frac{1}{2}\begin{pmatrix}1\\1\\1\\1\end{pmatrix}
Line 45: Line 43:
  
 ^ State ^ Expansion in computational basis ^ Description ^ ^ State ^ Expansion in computational basis ^ Description ^
-| $\lvert ++\rangle$ | $\tfrac{1}{2}(\lvert 00\rangle + \lvert 01\rangle + \lvert 10\rangle + \lvert 11\rangle)$ | Both qubits in $\lvert +\rangle$. Uniform superposition over all four computational basis states; $H\otimes H\lvert 00\rangle = \lvert ++\rangle$. | +| $\lvert ++\rangle$ | $\tfrac{1}{2}(\lvert 00\rangle + \lvert 01\rangle + \lvert 10\rangle + \lvert 11\rangle)$ | Both qubits in [[ket-plus|$\lvert +\rangle$]]. Uniform superposition over all four computational basis states; $H\otimes H\lvert 00\rangle = \lvert ++\rangle$. | 
-| $\lvert +-\rangle$ | $\tfrac{1}{2}(\lvert 00\rangle - \lvert 01\rangle + \lvert 10\rangle - \lvert 11\rangle)$ | Qubit in $\lvert +\rangle$, qubit in $\lvert -\rangle$. | +| $\lvert +-\rangle$ | $\tfrac{1}{2}(\lvert 00\rangle - \lvert 01\rangle + \lvert 10\rangle - \lvert 11\rangle)$ | Qubit in [[ket-plus|$\lvert +\rangle$]], qubit in [[ket-minus|$\lvert -\rangle$]]. | 
-| $\lvert -+\rangle$ | $\tfrac{1}{2}(\lvert 00\rangle + \lvert 01\rangle - \lvert 10\rangle - \lvert 11\rangle)$ | Qubit in $\lvert -\rangle$, qubit in $\lvert +\rangle$. | +| $\lvert -+\rangle$ | $\tfrac{1}{2}(\lvert 00\rangle + \lvert 01\rangle - \lvert 10\rangle - \lvert 11\rangle)$ | Qubit in [[ket-minus|$\lvert -\rangle$]], qubit in [[ket-plus|$\lvert +\rangle$]]. | 
-| $\lvert --\rangle$ | $\tfrac{1}{2}(\lvert 00\rangle - \lvert 01\rangle - \lvert 10\rangle + \lvert 11\rangle)$ | Both qubits in $\lvert -\rangle$. |+| $\lvert --\rangle$ | $\tfrac{1}{2}(\lvert 00\rangle - \lvert 01\rangle - \lvert 10\rangle + \lvert 11\rangle)$ | Both qubits in [[ket-minus|$\lvert -\rangle$]]. |
  
-### Y-basis+### Y-basis (Phase basis)
  
 Pick [[ket-plus-i|$\lvert +i\rangle$]] and [[ket-minus-i|$\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$). Pick [[ket-plus-i|$\lvert +i\rangle$]] and [[ket-minus-i|$\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$).
Line 61: Line 59:
  
 ^ State ^ Expansion in computational basis ^ Description ^ ^ State ^ Expansion in computational basis ^ Description ^
-| $\lvert +i,+i\rangle$ | $\tfrac{1}{2}(\lvert 00\rangle + i\lvert 01\rangle + i\lvert 10\rangle - \lvert 11\rangle)$ | Both qubits in $\lvert +i\rangle$. | +| $\lvert +i,+i\rangle$ | $\tfrac{1}{2}(\lvert 00\rangle + i\lvert 01\rangle + i\lvert 10\rangle - \lvert 11\rangle)$ | Both qubits in [[ket-plus-i|$\lvert +i\rangle$]]. | 
-| $\lvert +i,-i\rangle$ | $\tfrac{1}{2}(\lvert 00\rangle - i\lvert 01\rangle + i\lvert 10\rangle + \lvert 11\rangle)$ | Qubit in $\lvert +i\rangle$, qubit in $\lvert -i\rangle$. | +| $\lvert +i,-i\rangle$ | $\tfrac{1}{2}(\lvert 00\rangle - i\lvert 01\rangle + i\lvert 10\rangle + \lvert 11\rangle)$ | Qubit in [[ket-plus-i|$\lvert +i\rangle$]], qubit in [[ket-minus-i|$\lvert -i\rangle$]]. | 
-| $\lvert -i,+i\rangle$ | $\tfrac{1}{2}(\lvert 00\rangle + i\lvert 01\rangle - i\lvert 10\rangle + \lvert 11\rangle)$ | Qubit in $\lvert -i\rangle$, qubit in $\lvert +i\rangle$. | +| $\lvert -i,+i\rangle$ | $\tfrac{1}{2}(\lvert 00\rangle + i\lvert 01\rangle - i\lvert 10\rangle + \lvert 11\rangle)$ | Qubit in [[ket-minus-i|$\lvert -i\rangle$]], qubit in [[ket-plus-i|$\lvert +i\rangle$]]. | 
-| $\lvert -i,-i\rangle$ | $\tfrac{1}{2}(\lvert 00\rangle - i\lvert 01\rangle - i\lvert 10\rangle - \lvert 11\rangle)$ | Both qubits in $\lvert -i\rangle$. |+| $\lvert -i,-i\rangle$ | $\tfrac{1}{2}(\lvert 00\rangle - i\lvert 01\rangle - i\lvert 10\rangle - \lvert 11\rangle)$ | Both qubits in [[ket-minus-i|$\lvert -i\rangle$]]. |
  
 ## Entangled states ## Entangled states
  
-Some two-qubit states cannot be written as $\lvert\psi_0\rangle\otimes\lvert\psi_1\rangle$ for any choice of single-qubit states. These are **entangled states**. The give-away is that the four amplitudes $c_{00}, c_{01}, c_{10}, c_{11}$ cannot be factored into two pairs: entanglement means $c_{00}c_{11} \neq c_{01}c_{10}$.+Some two-qubit states cannot be written as $\lvert\psi_1\rangle\otimes\lvert\psi_0\rangle$ for any choice of single-qubit states. These are **entangled states**. The give-away is that the four amplitudes $c_{00}, c_{01}, c_{10}, c_{11}$ cannot be factored into two pairs: entanglement means $c_{00}c_{11} \neq c_{01}c_{10}$.
  
 What does that mean physically? Measuring one qubit of an entangled state instantly determines the outcome of measuring the other, even though neither qubit has a definite value before measurement. The correlations are stronger than anything a classical system can produce. What does that mean physically? Measuring one qubit of an entangled state instantly determines the outcome of measuring the other, even though neither qubit has a definite value before measurement. The correlations are stronger than anything a classical system can produce.
Line 83: Line 81:
  
 ^ State ^ Definition ^ Correlations ^ ^ State ^ Definition ^ Correlations ^
-| [[ket-phi-plus|$\lvert\Phi^+\rangle$]] | $\tfrac{1}{\sqrt{2}}(\lvert 00\rangle + \lvert 11\rangle)$ | Same-value in Z and X; anti-correlated in Y. Prepared from $\lvert 00\rangle$ by $H\otimes I$ then CNOT. |+| [[ket-phi-plus|$\lvert\Phi^+\rangle$]] | $\tfrac{1}{\sqrt{2}}(\lvert 00\rangle + \lvert 11\rangle)$ | Same-value in Z and X; anti-correlated in Y. Prepared from $\lvert 00\rangle$ by $H\otimes I$ then CX. |
 | [[ket-phi-minus|$\lvert\Phi^-\rangle$]] | $\tfrac{1}{\sqrt{2}}(\lvert 00\rangle - \lvert 11\rangle)$ | Same-value in Z; anti-correlated in X. The minus sign is invisible in Z-basis measurements. | | [[ket-phi-minus|$\lvert\Phi^-\rangle$]] | $\tfrac{1}{\sqrt{2}}(\lvert 00\rangle - \lvert 11\rangle)$ | Same-value in Z; anti-correlated in X. The minus sign is invisible in Z-basis measurements. |
-| [[ket-psi-plus|$\lvert\Psi^+\rangle$]] | $\tfrac{1}{\sqrt{2}}(\lvert 01\rangle + \lvert 10\rangle)$ | Anti-correlated in Z; same-value in X. Prepared from $\lvert 01\rangle$ by $H\otimes I$ then CNOT. |+| [[ket-psi-plus|$\lvert\Psi^+\rangle$]] | $\tfrac{1}{\sqrt{2}}(\lvert 01\rangle + \lvert 10\rangle)$ | Anti-correlated in Z; same-value in X. Prepared from $\lvert 01\rangle$ by $H\otimes I$ then CX. |
 | [[ket-psi-minus|$\lvert\Psi^-\rangle$]] | $\tfrac{1}{\sqrt{2}}(\lvert 01\rangle - \lvert 10\rangle)$ | Anti-correlated in every basis. The only antisymmetric Bell state; also called the singlet. | | [[ket-psi-minus|$\lvert\Psi^-\rangle$]] | $\tfrac{1}{\sqrt{2}}(\lvert 01\rangle - \lvert 10\rangle)$ | Anti-correlated in every basis. The only antisymmetric Bell state; also called the singlet. |
  
-Any single-qubit Pauli gate on one qubit of a Bell state maps it to another Bell state: $X$ switches $\Phi\leftrightarrow\Psi$, $Z$ toggles the sign, $Y$ does both. This is why the four Bell states map one-to-one to the four Pauli corrections in quantum teleportation.+Any single-qubit Pauli gate on one qubit of a Bell state maps it to another Bell state: $X$ switches $\Phi\leftrightarrow\Psi$, $Z$ toggles the sign, $Y$ does both. 
 + 
 +### Partial measurement 
 + 
 +Measuring one qubit of an entangled state collapses the joint state. Take $\lvert\Phi^+\rangle = \tfrac{1}{\sqrt{2}}(\lvert 00\rangle + \lvert 11\rangle)$ and measure qubit 0 in the Z basis: 
 + 
 + result 0 with probability $\tfrac{1}{2}$: the state collapses to $\lvert 00\rangle$. Qubit 1 is now certain to be $\lvert 0\rangle$. 
 + result 1 with probability $\tfrac{1}{2}$: the state collapses to $\lvert 11\rangle$. Qubit 1 is now certain to be $\lvert 1\rangle$. 
 + 
 +Before the measurement neither qubit has a definite value. After a measurement on qubit 0, qubit 1's outcome is fixed without touching it. The same pattern holds for any maximally entangled state and any measurement basis. 
 + 
 +## Gates 
 + 
 +Two-qubit gates are $4\times 4$ unitary matrices acting on $\mathbb{C}^4$. The three most common ones are CX (CX), CZ, and SWAP. Row and column ordering follows the computational basis: $\lvert 00\rangle, \lvert 01\rangle, \lvert 10\rangle, \lvert 11\rangle$. 
 + 
 +$$CX = \begin{pmatrix}1&0&0&0\\0&1&0&0\\0&0&0&1\\0&0&1&0\end{pmatrix} 
 +\qquad CZ = \begin{pmatrix}1&0&0&0\\0&1&0&0\\0&0&1&0\\0&0&0&-1\end{pmatrix} 
 +\qquad SWAP = \begin{pmatrix}1&0&0&0\\0&0&1&0\\0&1&0&0\\0&0&0&1\end{pmatrix}$$ 
 + 
 +CX flips qubit 0 when qubit 1 is $\lvert 1\rangle$ (qubit 1 is the control; Qiskit: `cx(1, 0)`). CZ applies a $-1$ phase when both qubits are $\lvert 1\rangle$; it is symmetric so either qubit can serve as the control. SWAP exchanges the two qubits entirely. For a full list see [[two-qubit-gates]]. 
 + 
 +## Qiskit 
 + 
 +```python 
 +# Requires: pip install qiskit qiskit-aer 
 +# Run: python bell.py 
 +# Prepares |Φ+⟩ and samples 1000 shots; expect roughly equal counts of '00' and '11'
 +from qiskit import QuantumCircuit 
 +from qiskit_aer import AerSimulator 
 + 
 +qc = QuantumCircuit(2, 2) 
 +qc.h(0)       # Hadamard on qubit 0 → superposition 
 +qc.cx(0, 1)   # CX: control=qubit 0, target=qubit 1 → entanglement 
 +qc.measure([0, 1], [0, 1]) 
 + 
 +counts = AerSimulator().run(qc, shots=1000).result().get_counts() 
 +print(counts)  # {'00': ~500, '11': ~500} 
 +```
  
two-qubits.1781317816.txt.gz · Last modified: by Ivan Janevski