qubit
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| qubit [June 11, 2026 at 01:31] – Ivan Janevski | qubit [June 13, 2026 at 03:46] (current) – Ivan Janevski | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| # Qubit | # Qubit | ||
| - | **Qubit** (or **quantum bit**) is the quantum | + | **Qubit** (or **quantum bit**) is the basic unit of quantum |
| - | A classical bit can be `0` or `1`. There are no probabilities involved at all, but we can assign them anyway. If a bit is `1`, then it's `1` with 100% probability | + | A classical bit can only be 0 or 1. A qubit can be in a **superposition**: |
| - | A qubit works in a similar way. It also has two basis states: $\lvert 0\rangle$ and $\lvert 1\rangle$, except | + | A general |
| - | $$\lvert\psi\rangle = a\lvert 0\rangle + b\lvert 1\rangle$$ | + | $$\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$$ |
| - | The coefficients $a$ and $b$ are not percentages — they are complex numbers called [[probability-amplitude|probability amplitudes]]. For example, a qubit might have amplitude $a = \frac{\sqrt{2}}{2} + i\frac{\sqrt{2}}{2}$ for state $\lvert 0\rangle$ and amplitude $b = \frac{\sqrt{2}}{2} - i\frac{\sqrt{2}}{2}$ for state $\lvert 1\rangle$, all at the same time. The probability amplitudes evolve over time according to the [[schrodinger-equation|Schrödinger equation]]; for example, $a$ and $b$ can rotate or exchange magnitudes over time. | + | ## Basis states |
| - | A qubit state continues | + | There are infinitely many single-qubit states but three orthonormal bases are standard, corresponding |
| - | But how do we know whether a qubit is going to collapse to `0` or `1` if $a$ and $b$ are complex numbers rather than percentages? | + | ### Z-basis (Computational basis) |
| - | $$P_0 = |a|^2 \qquad P_1 = |b|^2$$ | + | The Z-basis states |
| - | We do, however, require the qubit always exists as *at least something* with 100% probability when we measure it — a qubit can't half-exist or exist with 150% probability. Therefore the squared moduli must add up to 1. This is also called the second axiom of probability: | + | $$\lvert 0\rangle = \begin{pmatrix}1\\0\end{pmatrix} \qquad \lvert 1\rangle = \begin{pmatrix}0\\1\end{pmatrix}$$ |
| - | $$|a|^2 + |b|^2 = 1$$ | + | ^ 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$. | | ||
| - | The state of a qubit can be visualised geometrically as a point on the surface of the [[bloch-sphere|Bloch sphere]], | + | ### X-basis (Hadamard basis) |
| + | |||
| + | The X-basis states $\lvert +\rangle$ and $\lvert -\rangle$ are the eigenstates | ||
| + | |||
| + | $$\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 | ||
| + | |||
| + | $$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 | ||
| + | |||
| + | ## Bloch sphere | ||
| + | |||
| + | Every pure qubit state corresponds to a unique | ||
| + | |||
| + | $$\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: | ||
| + | |||
| + | ## 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& | ||
| + | \qquad Y = \begin{pmatrix}0& | ||
| + | \qquad Z = \begin{pmatrix}1& | ||
| + | \qquad H = \frac{1}{\sqrt{2}}\begin{pmatrix}1& | ||
| + | \qquad S = \begin{pmatrix}1& | ||
| + | \qquad T = \begin{pmatrix}1& | ||
| + | |||
| + | 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 ' | ||
| + | from qiskit import QuantumCircuit | ||
| + | from qiskit_aer import AerSimulator | ||
| + | |||
| + | qc = QuantumCircuit(1, | ||
| + | qc.h(0) | ||
| + | qc.measure(0, 0) | ||
| + | |||
| + | counts = AerSimulator().run(qc, | ||
| + | print(counts) | ||
| + | ``` | ||
qubit.1781141488.txt.gz · Last modified: by Ivan Janevski
