The qubit in quantum computing
Representing a qubit#
While a bit can have a value of either 0 or 1, a qubit can have a value that is either 0, 1, or a quantum superposition of 0 and 1.
The state of a single qubit is described by a two-dimensional column vector of unit norm — the magnitude squared of its entries must sum to 1. This vector, called the quantum state vector, holds all the information needed to describe the one-qubit quantum system, just as a single bit holds all the information needed to describe a binary variable.
Any two-dimensional column vector of real or complex numbers with norm 1 represents a possible quantum state held by a qubit: the vector [α, β] represents a qubit state if α and β are complex numbers satisfying |α|² + |β|² = 1. Two example valid quantum state vectors are [1, 0] and [0, 1] — these form a basis for the vector space that describes the qubit's state, called the computational basis. By convention, [1, 0] corresponds to classical state 0, and [0, 1] corresponds to classical state 1.
Out of the infinite number of possible single-qubit quantum state vectors, only these two correspond to states of classical bits — all other quantum states don't.
Measuring a qubit#
A measurement corresponds to the informal idea of "looking" at a qubit, which immediately collapses the quantum state to one of the two classical states [1, 0] or [0, 1]. When a qubit given by the state vector [α, β] is measured, the outcome 0 is obtained with probability |α|², and the outcome 1 with probability |β|². These probabilities sum to 1 because of the normalization condition.
A qubit already in the state [1, 0] (corresponding to classical state 0) always yields the outcome 0 when measured, and its state is unchanged — in this sense, measurement doesn't damage a qubit that only holds classical data. The ability to store information in both states at once is what elevates quantum computing beyond what's possible classically, and it's also why quantum data can't be indiscriminately copied (see the no-cloning theorem).
Visualizing qubits: the Bloch sphere#
Qubits can be pictured in 3D using the Bloch sphere representation, which describes a single-qubit quantum state (a two-dimensional complex vector) as a three-dimensional real-valued vector. This is useful for building intuition about single-qubit states — though the representation breaks down for multi-qubit states.
Single-qubit operations#
Quantum computers process data by applying a universal set of quantum gates that can emulate any rotation of the quantum state vector — the same notion of universality found in classical computing, where a gate set is universal if every transformation of the input bits can be performed using a finite-length circuit.
Single-qubit gates fall into two categories: Clifford gates and non-Clifford gates. The standard set of single-qubit Clifford gates included by default in Q# are the Hadamard (H), phase (S), and Pauli operators X, Y, and Z — named after their creator Wolfgang Pauli. The non-Clifford gate is the T gate (also known as the π/8 gate). Together, these gates can be composed to approximate any unitary transformation on a single qubit.
At the algorithmic level, it's often convenient to use higher-level unitaries rather than decomposing everything down to Clifford and T gates. The simplest of these are the single-qubit rotations Rx, Ry, and Rz. Q# provides methods for implementing these higher-level operations directly, so you don't need to hand-code Clifford/T decompositions.