Classical computers operate on a binary logic system where a bit must exist in one of two distinct states: 0 or 1. If you measure a voltage on a classical circuit board, you will find it is either high (representing 1) or low (representing 0). There is no middle ground.In quantum computing, we expand this logic significantly. A qubit is not restricted to being just a 0 or a 1. Instead, it can occupy a state that is a linear combination of both. This phenomenon is called superposition. It allows quantum algorithms to process information in ways that classical systems cannot replicate. For an AI engineer, you can think of this as moving from a deterministic boolean value to a probabilistic vector.The Linear Combination of StatesTo understand superposition mathematically, we rely on the vector notation introduced in previous chapters. We defined the standard basis states as:$$ |0\rangle = \begin{bmatrix} 1 \ 0 \end{bmatrix}, \quad |1\rangle = \begin{bmatrix} 0 \ 1 \end{bmatrix} $$A qubit in superposition is represented by a state vector $|\psi\rangle$ that adds these two vectors together, scaled by specific coefficients. We express this relationship with the following equation:$$ |\psi\rangle = \alpha|0\rangle + \beta|1\rangle $$In this equation, $\alpha$ (alpha) and $\beta$ (beta) are complex numbers known as probability amplitudes. These amplitudes determine how much "0-ness" and how much "1-ness" the qubit possesses.The following diagram illustrates the structural difference between a classical bit and a qubit in superposition.digraph G { rankdir=TB; node [shape=box, style=filled, fontname="Helvetica", color="#dee2e6"]; edge [color="#868e96"]; subgraph cluster_classical { label = "Classical Bit Logic"; fontname="Helvetica"; bgcolor="#f8f9fa"; color="#dee2e6"; c_state [label="Bit State", fillcolor="#a5d8ff"]; c_0 [label="0", fillcolor="#e9ecef"]; c_1 [label="1", fillcolor="#e9ecef"]; c_state -> c_0 [label="OR"]; c_state -> c_1 [label="OR"]; } subgraph cluster_quantum { label = "Quantum Qubit Logic"; fontname="Helvetica"; bgcolor="#f8f9fa"; color="#dee2e6"; q_state [label="Qubit State |ψ⟩", fillcolor="#b2f2bb"]; q_combo [label="α|0⟩ + β|1⟩", shape=ellipse, fillcolor="#d8f5a2"]; q_state -> q_combo [label="Linear Combination"]; } }Comparison of classical deterministic states versus the linear combination found in quantum superposition.Probability Amplitudes and NormalizationThe numbers $\alpha$ and $\beta$ are not direct probabilities. They are amplitudes. To find the probability of measuring the qubit in a specific state, you must calculate the magnitude squared of the amplitude.The probability of measuring $|0\rangle$ is $|\alpha|^2$.The probability of measuring $|1\rangle$ is $|\beta|^2$.Because a measurement must result in some outcome (either 0 or 1), the total probability of the system must equal 100%. This leads to the normalization constraint, a fundamental rule for all valid quantum states:$$ |\alpha|^2 + |\beta|^2 = 1 $$If you encounter a state vector where the sum of the squared magnitudes does not equal 1, it does not represent a valid physical state for a qubit.A Concrete ExampleLet us look at a specific, evenly distributed superposition. If a qubit is in a state where it is equally likely to be measured as 0 or 1, the amplitudes are often set to $1/\sqrt{2}$.$$ |+\rangle = \frac{1}{\sqrt{2}}|0\rangle + \frac{1}{\sqrt{2}}|1\rangle $$When we apply the probability rule to this state:Calculate probability of 0: $| \frac{1}{\sqrt{2}} |^2 = \frac{1}{2} = 0.5$Calculate probability of 1: $| \frac{1}{\sqrt{2}} |^2 = \frac{1}{2} = 0.5$Check total probability: $0.5 + 0.5 = 1.0$This specific state is often denoted as $|+\rangle$. In this state, the qubit is not toggling rapidly between 0 and 1. It is in a stable, definite quantum state composed of both basis vectors simultaneously.We can visualize these probabilities using a simple distribution chart.{ "layout": { "title": "Measurement Probabilities for Equal Superposition", "xaxis": { "title": "Basis State", "showgrid": false }, "yaxis": { "title": "Probability", "range": [0, 1], "showgrid": true, "gridcolor": "#e9ecef" }, "plot_bgcolor": "white", "font": { "family": "Helvetica" }, "margin": {"t": 40, "b": 40, "l": 40, "r": 40}, "height": 400, "width": 600 }, "data": [ { "type": "bar", "x": ["|0⟩", "|1⟩"], "y": [0.5, 0.5], "marker": { "color": ["#4dabf7", "#69db7c"] }, "width": 0.4 } ] }Probability distribution when measuring a qubit in the state $|+\rangle$. The outcomes are equally likely.Distinguishing Superposition from UncertaintyIt is important for engineers to distinguish superposition from classical uncertainty. In classical probability, if you toss a coin and cover it with your hand, the coin is definitely heads or definitely tails; you simply do not know which one yet. This is a lack of information.In quantum mechanics, before measurement, the system is the vector addition of the states. The qubit has definite information, defined by $\alpha$ and $\beta$, but that information describes a superposition, not a hidden binary value. The "choice" of 0 or 1 is only made at the moment of measurement.Vector Representation in PythonWhen we implement this in code later in the chapter, we will represent these states using NumPy arrays. Since $|\psi\rangle = \alpha|0\rangle + \beta|1\rangle$, the vector form is:$$ \begin{bmatrix} \alpha \ \beta \end{bmatrix} $$For the equal superposition example discussed above, the vector would be:$$ \begin{bmatrix} \frac{1}{\sqrt{2}} \ \frac{1}{\sqrt{2}} \end{bmatrix} \approx \begin{bmatrix} 0.707 \ 0.707 \end{bmatrix} $$Understanding this vector structure is essential because quantum gates, the operators we will use to manipulate qubits, are matrices that multiply these vectors. A gate operation essentially changes the values of $\alpha$ and $\beta$, thereby changing the probability of the measurement outcomes.