Quantum Sandbox logo

Quantum Sandbox

An Interactive Quantum Circuit Playground

All Lessons Sandbox
Part 1: Foundations 10 min read

Superposition

A qubit is not just a coin that can be heads or tails. Before you look at it, it is genuinely both - and the math behind that "both" is surprisingly precise and useful.

The classical bit vs. the qubit

In classical computing, every piece of information comes down to bits - switches that are either off (0) or on (1). Nothing in between. The entire history of digital computing is built on that binary foundation.

A qubit follows different rules. Instead of being stuck in one state, a qubit can exist in a superposition - a blend of |0⟩ and |1⟩ at the same time. We write the two possible states as |0⟩ and |1⟩ (the brackets and vertical bar are just notation physicists use, called "ket" notation). A qubit in superposition is written as a weighted combination of both: some amount of |0⟩ plus some amount of |1⟩.

The amounts are not just percentages. They are called amplitudes, and they are complex numbers - numbers that have both a real part and an imaginary part. The probability of measuring |0⟩ is the square of the amplitude's magnitude, and similarly for |1⟩. The two probabilities always add up to exactly 100%. Think of it like a recipe: the amplitudes are the precise quantities of two ingredients blended together, and squaring them just converts "how much of each" into "how likely each one is to show up when you taste the result."

The Hadamard gate: the superposition switch

If a qubit starts in |0⟩ (a definite zero, with 100% chance of measuring 0), how do you put it into superposition? You use a gate. Gates are the quantum equivalent of logic gates in classical computing - they transform the qubit state.

The most important gate for creating superposition is the Hadamard gate, written H. Applying H to |0⟩ creates a perfect 50/50 superposition: the qubit has exactly a 50% chance of measuring as 0 and a 50% chance of measuring as 1. The same gate applied to |1⟩ also creates superposition, but with a phase difference - the amplitudes point in opposite directions. Picture two waves that look identical in height but are offset, one peaking where the other dips - measuring either wave alone tells you nothing about that offset, but the offset still changes what happens when the waves later combine. That phase difference turns out to be crucial for interference, which you will explore in Lesson 4.

Here is the key insight: superposition is not the same as randomness or uncertainty. When a qubit is in superposition, it is in a precise, well-defined mathematical state. The "both at once" is not a gap in our knowledge - it is the actual physical situation. This is what makes quantum mechanics genuinely strange compared to anything in everyday experience.

The Bloch sphere

There is a beautiful way to visualize a single qubit's state called the Bloch sphere. Imagine a globe. The north pole represents |0⟩. The south pole represents |1⟩. Any point on the surface represents a valid qubit state - any superposition you can construct.

When you apply H to |0⟩ (north pole), the state moves to the equator, exactly halfway between north and south - perfect superposition. The Bloch sphere makes it visual: applying gates rotates the arrow (called the Bloch vector) around the sphere.

Phase - the imaginary part of the amplitude - is encoded in the direction around the equator. Two states can both have 50% probability of each outcome but point in different directions on the equator. They are different states with different behavior in later operations, even though a single measurement cannot distinguish them.

Superposition Explorer. Drag to adjust
|0⟩ (alpha)
50%
|1⟩ (beta)
50%
Perfect 50/50 superposition - the outcome is genuinely random until measured.
Try it in the Sandbox
Create superposition with the Hadamard gate
  1. Start: qubit is |0⟩. Bloch sphere at north pole, 100% |0⟩ probability.
  2. Click H. The arrow shifts to the equator, both bars hit 50%.
  3. Click H again. Qubit snaps back to |0⟩. H applied twice undoes itself.
  4. Switch preset to |1⟩, then apply H, shifts to the equator again, but on the opposite side.
  5. Hit Measure: the result is random but should average 50/50 over multiple tries.

What superposition is not

It is tempting to think of superposition as the qubit being "secretly" 0 or secretly 1, and we just don't know which one until we measure. This would make it like a coin that is already heads or tails inside a closed box - we just haven't looked yet.

Quantum mechanics has been tested exhaustively, and this classical interpretation is wrong. Superposition is not a lack of knowledge. Experiments show that a qubit in superposition behaves as if it genuinely is in both states simultaneously - the two possibilities interfere with each other in ways that no "hidden coin" model can explain. The most famous such test is called Bell's theorem, which you will revisit when we get to entanglement.

This is the hardest conceptual leap in quantum computing, and even physicists who have worked with quantum mechanics for decades find it philosophically strange. The right approach is to accept the math: the state is a precise description of a real physical system, and it predicts experiments perfectly.

Why superposition matters for computing

With one qubit in superposition, you are working with a blend of two states. With two qubits in superposition simultaneously, you are working with a blend of four states. With three qubits, eight states. With n qubits, you are processing 2ⁿ states at once.

With 300 qubits all in superposition, 2³⁰⁰ is more than the number of atoms in the visible universe. This exponential growth is the source of the quantum computing advantage - but only if you can use interference and entanglement to extract useful answers from it. Just having qubits in superposition is not enough on its own. The real power comes from engineering what happens when you measure.

Key takeaway

Superposition is not uncertainty or randomness - it is a precise physical state where a qubit genuinely exists as a weighted combination of |0⟩ and |1⟩. The Hadamard gate creates (and destroys) superposition, and the Bloch sphere gives you a geometric picture of every possible qubit state.

Knowledge check · Question 1 of 4

How is the probability of measuring |0⟩ related to its amplitude?

Amplitudes are complex numbers that describe the qubit's state precisely. Squaring an amplitude's magnitude converts it into the probability of observing that outcome, and the two probabilities always add up to 100%.
Knowledge check · Question 2 of 4

What happens if you apply the Hadamard gate twice in a row to a qubit?

H is its own inverse: applying it twice undoes the first application, snapping the qubit back to where it started. You can see this directly in the Sandbox demo above.
Knowledge check · Question 3 of 4

Two qubit states both have a 50% chance of measuring 0 and 50% chance of measuring 1, but they sit at different points on the Bloch sphere's equator. What does this tell you?

Position around the equator encodes phase. A single measurement only reveals the |0⟩/|1⟩ probabilities, so two states with the same probabilities but different phase look identical at that point - but they behave differently once you apply further gates, especially in interference.
Knowledge check · Question 4 of 4

Why does putting many qubits into superposition together matter for computing power?

Each additional qubit doubles the number of states represented simultaneously - 2ⁿ for n qubits. That exponential scaling is the raw resource behind quantum advantage, though interference and entanglement are still needed to turn it into a useful answer.