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 [June 11, 2026 at 01:31] Ivan Janevskiqubit [June 13, 2026 at 03:46] (current) Ivan Janevski
Line 1: Line 1:
 # Qubit # Qubit
-**Qubit** (or **quantum bit**) is the quantum equivalent of a bit.+**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 be `0or `1`There are no probabilities involved at all, but we can assign them anyway. If bit is `1`, then it's `1` with 100% probability and `0` with 0% probability. Conversely, if bit is `0`, then it's `1` with 0% probability and `0` with 100% probability.+A classical bit can only be 0 or 1. A qubit can be in **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 definite or only when measured.
  
-A qubit works in similar way. It also has two basis states: $\lvert 0\rangle$ and $\lvert 1\rangle$except the total probability is distributed between them. A qubit $\lvert\psi\rangle$ is written in the following form, using [[dirac-notation|Dirac notation]]:+general qubit state is superposition over the two computational basis states, with the normalization condition saying the total probability must be 1:
  
-$$\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
  
-qubit state continues to evolve as this object of two complex probability amplitudes — until it is measured. When a qubit is measured, it collapses to either $\lvert 0\rangle$ or $\lvert 1\rangle$ with 100% probability. At that point, there are no longer any probability amplitudes involved. The qubit behaves exactly like a classical bit and we might as well refer to $\lvert 0\rangle$ as `0` and $\lvert 1\rangle$ as `1`.+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.
  
-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? The answer is given by the [[born-rule|Born rule]]. The Born rule states that the real probability of a measurement yielding a certain result equals the modulus squared of the probability amplitude associated with that result.+### Z-basis (Computational basis)
  
-$$P_0 = |a|^2 \qquad P_1 = |b|^2$$+The Z-basis states $\lvert 0\rangleand $\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.
  
-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]], where the north pole is $\lvert 0\rangle$the south pole is $\lvert 1\rangle$, and all other points correspond to superposition states.+### 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 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} 
 +```
  
qubit.1781141471.txt.gz · Last modified: by Ivan Janevski