Site Tools


qubit

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
qubit [May 08, 2026 at 22:33] yanevskivqubit [June 13, 2026 at 03:46] (current) Ivan Janevski
Line 1: Line 1:
 +# Qubit
 +**Qubit** (or **quantum bit**) is the basic unit of quantum information. The Hilbert space of a single qubit is $\mathbb{C}^2$, meaning two complex amplitudes to describe it, not one.
 +
 +A classical bit can only be 0 or 1. A qubit can be in a **superposition**: a combination of $\lvert 0\rangle$ and $\lvert 1\rangle$ with complex coefficients called [[probability-amplitude|probability amplitudes]]. The state evolves according to the [[schrodinger-equation|Schrödinger equation]] and collapses to a definite 0 or 1 only when measured.
 +
 +A general qubit state is a superposition over the two computational basis states, with the normalization condition saying the total probability must be 1:
 +
 +$$\lvert\psi\rangle = \begin{pmatrix}a\\b\end{pmatrix} = a\underbrace{\begin{pmatrix}1\\ 0\end{pmatrix}}_{\lvert 0\rangle} + b\underbrace{\begin{pmatrix}0\\1\end{pmatrix}}_{\lvert 1\rangle} = a\lvert 0\rangle + b\lvert 1\rangle, \qquad |a|^2 + |b|^2 = 1$$
 +
 +## Basis states
 +
 +There are infinitely many single-qubit states but three orthonormal bases are standard, corresponding to the three axes of the [[bloch-sphere|Bloch sphere]]. In each basis the two states are perfectly sharp for that observable and spread out for the others.
 +
 +### Z-basis (Computational basis)
 +
 +The Z-basis states $\lvert 0\rangle$ and $\lvert 1\rangle$ are the eigenstates of the Pauli Z gate. They behave exactly like a classical bit: each has a definite value with no superposition. Every qubit state can be written as a linear combination of them.
 +
 +$$\lvert 0\rangle = \begin{pmatrix}1\\0\end{pmatrix} \qquad \lvert 1\rangle = \begin{pmatrix}0\\1\end{pmatrix}$$
 +
 +^ State ^ Description ^
 +| [[ket-0|$\lvert 0\rangle$]] | Eigenstate of Z with eigenvalue $+1$. Default initial state of every qubit. |
 +| [[ket-1|$\lvert 1\rangle$]] | Eigenstate of Z with eigenvalue $-1$. |
 +
 +### X-basis (Hadamard basis)
 +
 +The X-basis states $\lvert +\rangle$ and $\lvert -\rangle$ are the eigenstates of the Pauli X gate. They look "spread out" in the computational basis, because each is an equal superposition of $\lvert 0\rangle$ and $\lvert 1\rangle$. In the X basis they are perfectly sharp. You get from the computational basis to the X basis by applying a Hadamard.
 +
 +$$\lvert +\rangle = \frac{1}{\sqrt{2}}\begin{pmatrix}1\\1\end{pmatrix} \qquad \lvert -\rangle = \frac{1}{\sqrt{2}}\begin{pmatrix}1\\{-1}\end{pmatrix}$$
 +
 +^ State ^ Expansion in computational basis ^ Description ^
 +| [[ket-plus|$\lvert +\rangle$]] | $\tfrac{1}{\sqrt{2}}(\lvert 0\rangle + \lvert 1\rangle)$ | Eigenstate of X with eigenvalue $+1$. Prepared from $\lvert 0\rangle$ by $H$. |
 +| [[ket-minus|$\lvert -\rangle$]] | $\tfrac{1}{\sqrt{2}}(\lvert 0\rangle - \lvert 1\rangle)$ | Eigenstate of X with eigenvalue $-1$. Prepared from $\lvert 1\rangle$ by $H$. |
 +
 +### Y-basis (Phase basis)
 +
 +The Y-basis states $\lvert +i\rangle$ and $\lvert -i\rangle$ are the eigenstates of the Pauli Y gate. Their coefficients are complex, so they are the first states on this page with imaginary entries. You get from the computational basis to the Y basis by applying $SH$ ($H$ first, then $S$).
 +
 +$$\lvert +i\rangle = \frac{1}{\sqrt{2}}\begin{pmatrix}1\\i\end{pmatrix} \qquad \lvert -i\rangle = \frac{1}{\sqrt{2}}\begin{pmatrix}1\\{-i}\end{pmatrix}$$
 +
 +^ State ^ Expansion in computational basis ^ Description ^
 +| [[ket-plus-i|$\lvert +i\rangle$]] | $\tfrac{1}{\sqrt{2}}(\lvert 0\rangle + i\lvert 1\rangle)$ | Eigenstate of Y with eigenvalue $+1$. |
 +| [[ket-minus-i|$\lvert -i\rangle$]] | $\tfrac{1}{\sqrt{2}}(\lvert 0\rangle - i\lvert 1\rangle)$ | Eigenstate of Y with eigenvalue $-1$. |
 +
 +## Measurement
 +
 +Measuring a qubit in the Z basis gives outcome 0 or 1 and collapses the state. For $\lvert\psi\rangle = a\lvert 0\rangle + b\lvert 1\rangle$, the [[born-rule|Born rule]] gives the probabilities:
 +
 +$$P(0) = |a|^2 \qquad P(1) = |b|^2$$
 +
 +Result 0 collapses the state to $\lvert 0\rangle$; result 1 collapses it to $\lvert 1\rangle$. The probability amplitudes are destroyed by measurement and cannot be recovered. Measuring in the X or Y basis works the same way with different outcome states: to measure in the X basis, apply $H$ before measuring in Z; to measure in the Y basis, apply $S^\dagger H$ before measuring in Z.
 +
 +## Bloch sphere
 +
 +Every pure qubit state corresponds to a unique point on the surface of the [[bloch-sphere|Bloch sphere]], a unit sphere in $\mathbb{R}^3$. The parametrisation uses two angles $\theta \in [0, \pi]$ and $\phi \in [0, 2\pi)$:
 +
 +$$\lvert\psi\rangle = \cos\tfrac{\theta}{2}\lvert 0\rangle + e^{i\phi}\sin\tfrac{\theta}{2}\lvert 1\rangle$$
 +
 +The north pole ($\theta = 0$) is $\lvert 0\rangle$; the south pole ($\theta = \pi$) is $\lvert 1\rangle$. The equator ($\theta = \pi/2$) holds all equal-amplitude superpositions: $\lvert +\rangle$ at $\phi = 0$, $\lvert -\rangle$ at $\phi = \pi$, $\lvert +i\rangle$ at $\phi = \pi/2$, $\lvert -i\rangle$ at $\phi = 3\pi/2$. Single-qubit gates act as rotations of the Bloch sphere.
 +
 +## Gates
 +
 +Single-qubit gates are $2\times 2$ unitary matrices acting on $\mathbb{C}^2$. The three Pauli gates and the Hadamard are the most common.
 +
 +$$X = \begin{pmatrix}0&1\\1&0\end{pmatrix}
 +\qquad Y = \begin{pmatrix}0&{-i}\\i&0\end{pmatrix}
 +\qquad Z = \begin{pmatrix}1&0\\0&{-1}\end{pmatrix}
 +\qquad H = \frac{1}{\sqrt{2}}\begin{pmatrix}1&1\\1&{-1}\end{pmatrix}
 +\qquad S = \begin{pmatrix}1&0\\0&i\end{pmatrix}
 +\qquad T = \begin{pmatrix}1&0\\0&e^{i\pi/4}\end{pmatrix}$$
 +
 +X flips $\lvert 0\rangle \leftrightarrow \lvert 1\rangle$ (the quantum NOT gate). Z applies a $-1$ phase to $\lvert 1\rangle$ and leaves $\lvert 0\rangle$ unchanged. Y is equivalent to $iXZ$. H maps $\lvert 0\rangle \to \lvert +\rangle$ and $\lvert 1\rangle \to \lvert -\rangle$, converting between the Z and X bases. S is the square root of Z ($S^2 = Z$); T is the square root of S ($T^2 = S$). For a full list see [[single-qubit-gates]].
 +
 +## Qiskit
 +
 +```python
 +# Requires: pip install qiskit qiskit-aer
 +# Run: python qubit.py
 +# Prepares |+⟩ and samples 1000 shots; expect roughly equal counts of '0' and '1'.
 +from qiskit import QuantumCircuit
 +from qiskit_aer import AerSimulator
 +
 +qc = QuantumCircuit(1, 1)
 +qc.h(0)        # Hadamard: |0⟩ → |+⟩ = equal superposition
 +qc.measure(0, 0)
 +
 +counts = AerSimulator().run(qc, shots=1000).result().get_counts()
 +print(counts)  # {'0': ~500, '1': ~500}
 +```