Back to Resources
Quantum Primer

Quantum Primer

A practical introduction to quantum computing concepts, focused on what you need to know to solve challenges. No prior quantum experience required.

Linear Algebra Basics

Optional — but recommended for deeper understanding

Do I need to know this to solve challenges?

No. You can solve every challenge on Qubit Forge without understanding the maths behind it. The platform tells you exactly which gates to use and what output to target. You do not need to do any calculations by hand.

However, if you want to understand why your circuits work, what a gate is actually doing to a qubit, and the real significance of the quantum algorithms you are building, this section will give you that foundation. Think of it as the difference between following a recipe and understanding why each ingredient matters.

Numbers: The Building Blocks

Before we talk about vectors or matrices, let's make sure we are on the same page about numbers. In everyday life you use whole numbers (1, 2, 3) and decimals (3.14, 0.5). In maths, a single number is often called a scalar — it just means "one number on its own."

In quantum computing, these scalars are usually decimal numbers (like 0.707) and sometimes involve the square root symbol. For example, 120.707\frac{1}{\sqrt{2}} \approx 0.707. Do not worry about computing these by hand — the computer does it for you. You just need to recognise what the notation means when you see it.

Quick notation guide

2\sqrt{2}

The square root of 2 (about 1.414). The number which, multiplied by itself, gives 2.

12\frac{1}{\sqrt{2}}

1 divided by √2 (about 0.707). You will see this number constantly in quantum computing.

π\pi

Pi (about 3.14159). The ratio of a circle's circumference to its diameter. Used for rotation angles.

π2\frac{\pi}{2}

Half of pi (about 1.571). Represents a quarter turn (90°).

Vectors: Lists of Numbers

A vector is simply an ordered list of numbers. You can think of it like a column in a spreadsheet. In quantum computing, we write vectors as a vertical stack of numbers inside square brackets:

A 2-element vector

[1 0]\begin{bmatrix} 1 \\\ 0 \end{bmatrix}

This vector has two entries: the first is 1, the second is 0.

Another 2-element vector

[0 1]\begin{bmatrix} 0 \\\ 1 \end{bmatrix}

First entry is 0, second entry is 1.

Why vectors matter for quantum computing

In quantum computing, the state of a qubit is a vector. The qubit in state 0|0\rangle is actually the vector [1 0]\begin{bmatrix} 1 \\\ 0 \end{bmatrix}, and the qubit in state 1|1\rangle is the vector [0 1]\begin{bmatrix} 0 \\\ 1 \end{bmatrix}. The two entries in the vector represent the "amount" of 0|0\rangle and 1|1\rangle in the qubit's state.

A qubit in superposition — part 0 and part 1 at the same time — is a vector where both entries are non-zero:

+=12[1 1][0.707 0.707]|+\rangle = \frac{1}{\sqrt{2}}\begin{bmatrix} 1 \\\ 1 \end{bmatrix} \approx \begin{bmatrix} 0.707 \\\ 0.707 \end{bmatrix}

This is the "plus" state — an equal mix of 0 and 1. Both entries are equal (about 0.707 each), meaning there is a 50% chance of measuring either outcome. The 12\frac{1}{\sqrt{2}} is just a scaling factor that makes the probabilities add up to 1.

Complex Numbers: Not as Scary as They Sound

In school, you were probably told "you can't take the square root of a negative number." In maths, we invented a workaround: define a special number called ii where i2=1i^2 = -1 (in other words, i=1i = \sqrt{-1}). A complex number is any number that combines a regular part and an ii part:

a+bia + bi

aa is the real part — a normal number you are already familiar with.

bb is the imaginary part — the coefficient multiplied by ii.

3+0i=33 + 0i = 3

A normal number (zero imaginary part)

0+2i=2i0 + 2i = 2i

A purely imaginary number

1+i1 + i

A complex number with both parts

Why complex numbers matter

The entries in a qubit's state vector can be complex numbers (not just regular decimals). This is what gives quantum computing its extra power — the imaginary part creates a property called phase, which is how quantum algorithms manipulate probabilities through interference.

You do not need to do complex number arithmetic to solve challenges. You just need to know they exist and roughly what they mean when you see them.

Magnitude (Absolute Value) of Complex Numbers

When you see α2|\alpha|^2 in quantum computing, that is asking: "what is the magnitude squared of this complex number?" The magnitude tells you how "big" the number is, ignoring its direction/phase:

a+bi2=a2+b2|a + bi|^2 = a^2 + b^2

Example: a regular number

0.7072=0.707×0.707=0.5|0.707|^2 = 0.707 \times 0.707 = 0.5

So there is a 50% probability — exactly what we expect from a superposition state.

Example: a complex number

1+i22=14+14=12|\frac{1+i}{2}|^2 = \frac{1}{4} + \frac{1}{4} = \frac{1}{2}

Even though this has an imaginary part, the probability is still 50%.

Key takeaway: in quantum computing, the probability of measuring a particular outcome equals the magnitude squared of its amplitude. α2|\alpha|^2 means "square the real part, square the imaginary part, and add them together."

Matrices: Grids of Numbers That Do Things

A matrix is a rectangular grid of numbers. If a vector is a single column in a spreadsheet, a matrix is the whole table. In quantum computing, matrices are important because every quantum gate is a matrix.

Colour key:Matrix entriesVector entries

The X gate (quantum NOT)

X=[01 10]X = \textcolor{#38bdf8}{\begin{bmatrix} 0 & 1 \\\ 1 & 0 \end{bmatrix}}

A 2×2 grid: 2 rows, 2 columns.

The Hadamard gate

H=12[11 11]H = \frac{1}{\sqrt{2}}\textcolor{#38bdf8}{\begin{bmatrix} 1 & 1 \\\ 1 & -1 \end{bmatrix}}

Also 2×2. The 12\frac{1}{\sqrt{2}} keeps probabilities valid.

Matrix × Vector = Gate Applied to Qubit

When you "apply a gate to a qubit," the computer is multiplying the gate's matrix by the qubit's state vector. Here is how that works, step by step:

Colour key:Matrix entriesVector entries

Example: Apply the X gate (NOT) to 0|0\rangle

[01 10][1 0]=[(0×1)+(1×0) (1×1)+(0×0)]=[0 1]\textcolor{#38bdf8}{\begin{bmatrix} 0 & 1 \\\ 1 & 0 \end{bmatrix}}\textcolor{#4ade80}{\begin{bmatrix} 1 \\\ 0 \end{bmatrix}} = \begin{bmatrix}(\textcolor{#38bdf8}{0} \times \textcolor{#4ade80}{1}) + (\textcolor{#38bdf8}{1} \times \textcolor{#4ade80}{0}) \\\ (\textcolor{#38bdf8}{1} \times \textcolor{#4ade80}{1}) + (\textcolor{#38bdf8}{0} \times \textcolor{#4ade80}{0})\end{bmatrix} = \begin{bmatrix}0 \\\ 1\end{bmatrix}

Step 1: For the first entry of the result, take the first row of the matrix and do a dot product with the vector: (0×1)+(1×0)=0(\textcolor{#38bdf8}{0} \times \textcolor{#4ade80}{1}) + (\textcolor{#38bdf8}{1} \times \textcolor{#4ade80}{0}) = 0.

Step 2: For the second entry, take the second row of the matrix and dot it with the same vector: (1×1)+(0×0)=1(\textcolor{#38bdf8}{1} \times \textcolor{#4ade80}{1}) + (\textcolor{#38bdf8}{0} \times \textcolor{#4ade80}{0}) = 1.

Result: The output vector is [0 1]\begin{bmatrix} 0 \\\ 1 \end{bmatrix} which is 1|1\rangle. Applying the NOT gate to 0|0\rangle gives 1|1\rangle — exactly as expected!

Example: Apply the Hadamard gate to 0|0\rangle

12[11 11][1 0]=12[(1×1)+(1×0) (1×1)+(1×0)]\frac{1}{\sqrt{2}}\textcolor{#38bdf8}{\begin{bmatrix}1 & 1 \\\ 1 & -1\end{bmatrix}}\textcolor{#4ade80}{\begin{bmatrix}1 \\\ 0\end{bmatrix}} = \frac{1}{\sqrt{2}}\begin{bmatrix}(\textcolor{#38bdf8}{1}\times\textcolor{#4ade80}{1}) + (\textcolor{#38bdf8}{1}\times\textcolor{#4ade80}{0}) \\\ (\textcolor{#38bdf8}{1}\times\textcolor{#4ade80}{1}) + (\textcolor{#38bdf8}{-1}\times\textcolor{#4ade80}{0})\end{bmatrix}
=12[1 1]=[0.707 0.707]= \frac{1}{\sqrt{2}}\begin{bmatrix} 1 \\\ 1 \end{bmatrix} = \begin{bmatrix} 0.707 \\\ 0.707 \end{bmatrix}

The result is the +|+\rangle state — equal superposition. Both entries are 0.707, so the probability of measuring 0 is 0.7072=0.50.707^2 = 0.5 (50%), and the probability of measuring 1 is also 50%. This is why the Hadamard gate creates superposition — it spreads the amplitude equally across both states.

Do I need to do matrix multiplication by hand?

Absolutely not. The computer and the simulator handle all of this automatically. The reason we show it here is so that when you read "the Hadamard gate creates a superposition," you can understand how it does that (by multiplying a matrix by a vector) and why the result is a 50% / 50% split.

Tensor Products: Combining Multiple Qubits

When you have more than one qubit, you need to describe the combined state of the whole system. This is where the tensor product (written as \otimes) comes in. The tensor product combines two smaller vectors into one larger vector.

Colour key:Left vectorRight vector

Example: Two qubits, both in state 0|0\rangle

00=[1 0][1 0]\textcolor{#38bdf8}{|0\rangle} \otimes \textcolor{#4ade80}{|0\rangle} = \textcolor{#38bdf8}{\begin{bmatrix} 1 \\\ 0 \end{bmatrix}} \otimes \textcolor{#4ade80}{\begin{bmatrix} 1 \\\ 0 \end{bmatrix}}
=[1×11×00×10×0]=[1 0 0 0]= \begin{bmatrix} \textcolor{#38bdf8}{1} \times \textcolor{#4ade80}{1} \\ \textcolor{#38bdf8}{1} \times \textcolor{#4ade80}{0} \\ \textcolor{#38bdf8}{0} \times \textcolor{#4ade80}{1} \\ \textcolor{#38bdf8}{0} \times \textcolor{#4ade80}{0} \end{bmatrix} = \begin{bmatrix} 1 \\\ 0 \\\ 0 \\\ 0 \end{bmatrix}

The tensor product takes two 2-element vectors and produces a 4-element vector. The rule is straightforward: multiply the first entry of the left vector by every entry of the right vector, then do the same for the second entry:

1×[1 0]=[1 0]\textcolor{#38bdf8}{1} \times \textcolor{#4ade80}{\begin{bmatrix} 1 \\\ 0 \end{bmatrix}} = \begin{bmatrix} 1 \\\ 0 \end{bmatrix} (first entry of left vector × right vector)

0×[1 0]=[0 0]\textcolor{#38bdf8}{0} \times \textcolor{#4ade80}{\begin{bmatrix} 1 \\\ 0 \end{bmatrix}} = \begin{bmatrix} 0 \\\ 0 \end{bmatrix} (second entry of left vector × right vector)

Stack them: [1 0 0 0]\begin{bmatrix} 1 \\\ 0 \\\ 0 \\\ 0 \end{bmatrix}

This is written in shorthand as 00|00\rangle. The 4-element vector represents all four possible states of two qubits:

00|00\rangle

[1 0 0 0]\begin{bmatrix} 1 \\\ 0 \\\ 0 \\\ 0 \end{bmatrix}

Both qubits are 0

01|01\rangle

[0 1 0 0]\begin{bmatrix} 0 \\\ 1 \\\ 0 \\\ 0 \end{bmatrix}

First qubit 0, second qubit 1

10|10\rangle

[0 0 1 0]\begin{bmatrix} 0 \\\ 0 \\\ 1 \\\ 0 \end{bmatrix}

First qubit 1, second qubit 0

11|11\rangle

[0 0 0 1]\begin{bmatrix} 0 \\\ 0 \\\ 0 \\\ 1 \end{bmatrix}

Both qubits are 1

Why this matters

This is the mathematical explanation for why quantum computers are potentially powerful: nn qubits need a vector with 2n2^n entries. Just 10 qubits require a vector of 1,024 entries. 30 qubits need over a billion entries. A quantum computer handles this naturally — a classical computer has to store and manipulate all of those numbers explicitly.

For challenges: you will not need to calculate tensor products. But when a challenge says "create the state 00+11|00\rangle + |11\rangle," you now know this describes a 4-element vector where the 1st and 4th entries are non-zero (those two states both have amplitude).

Connecting the Dots: Dirac Notation

Now you know what vectors are, you can understand the notation used throughout this primer and on the platform. Quantum physicists invented a shorthand called Dirac notation (or "bra-ket notation") so they do not have to write column vectors every time:

0|0\rangle
=
[1 0]\begin{bmatrix} 1 \\\ 0 \end{bmatrix}
The qubit is definitely 0. Called a "ket zero."
1|1\rangle
=
[0 1]\begin{bmatrix} 0 \\\ 1 \end{bmatrix}
The qubit is definitely 1. Called a "ket one."
ψ|\psi\rangle
=
[αβ]\begin{bmatrix} \alpha \\ \beta \end{bmatrix}
Some arbitrary qubit state (psi is a common label). α is the amplitude for 0, β for 1.

The | and \rangle symbols are just visual wrappers — they tell you "this is a quantum state vector." It is like how quotation marks tell you something is a word: "cat" is a label for the animal, and 0|0\rangle is a label for the vector [1 0]\begin{bmatrix} 1 \\\ 0 \end{bmatrix}.

Putting it all together

ψ=α0+β1=α[1 0]+β[0 1]=[αβ]|\psi\rangle = \alpha|0\rangle + \beta|1\rangle = \alpha\begin{bmatrix} 1 \\\ 0 \end{bmatrix} + \beta\begin{bmatrix} 0 \\\ 1 \end{bmatrix} = \begin{bmatrix} \alpha \\ \beta \end{bmatrix}

This equation, which appears at the start of Chapter 1, now makes complete sense: a qubit's state is a 2-element vector. The first entry (α\alpha) is how much 0|0\rangle is in the mix, and the second entry (β\beta) is how much 1|1\rangle. The probability of measuring 0 is α2|\alpha|^2 (magnitude squared, as we learnt above), and the probability of measuring 1 is β2|\beta|^2.

Section Summary

What you need for challenges

  • Recognise Dirac notation (0|0\rangle, 1|1\rangle, ψ|\psi\rangle)
  • Know that qubit states are described by amplitudes
  • Understand that α2|\alpha|^2 gives a probability
  • Know that gates change the state of qubits
  • Accept that more qubits = exponentially larger state space

Helpful but not required

  • Understanding what vectors and matrices are
  • Complex numbers and the role of phase
  • How matrix multiplication transforms states
  • How tensor products build multi-qubit spaces
  • Why unitary matrices keep probabilities valid
1

Qubits and States

Classical Bits vs Qubits

A classical bit is either 0 or 1. A qubit (quantum bit) can also be 0 or 1, but unlike a classical bit, it can exist in a superposition of both states simultaneously. This is the foundational concept behind quantum computing.

Superposition

When a qubit is in superposition, it has some probability of being measured as 0 and some probability of being measured as 1. These probabilities are described by complex numbers called amplitudes.

New to this notation? Read the Linear Algebra Basics section first — it explains everything from scratch.

A qubit's state can be written as:

ψ=α0+β1|\psi\rangle = \alpha|0\rangle + \beta|1\rangle

Where α\alpha and β\beta are complex amplitudes. The probability of measuring 0 is α2|\alpha|^2 and the probability of measuring 1 is β2|\beta|^2. These probabilities always sum to 1.

Need a maths refresher?

The Linear Algebra Basics section above covers vectors, complex numbers, matrices, and tensor products from scratch — no prior maths background required.

Dirac Notation

Quantum states are written using Dirac notation (also called bra-ket notation). This is the standard notation used in quantum computing and you will see it throughout challenge descriptions.

0|0\rangle

The "zero" state. A qubit that will always measure as 0. This is the default initial state of qubits.

1|1\rangle

The "one" state. A qubit that will always measure as 1.

+|+\rangle

Equal superposition: 0+12\frac{|0\rangle + |1\rangle}{\sqrt{2}}. Created by applying a Hadamard gate to 0|0\rangle. 50% chance of measuring 0 or 1.

|-\rangle

Minus superposition: 012\frac{|0\rangle - |1\rangle}{\sqrt{2}}. Created by applying a Hadamard gate to 1|1\rangle. Also 50%, but with a different phase.

Multi-Qubit States

When you have multiple qubits, the state space grows exponentially. Two qubits have four possible states: 00|00\rangle, 01|01\rangle, 10|10\rangle, and 11|11\rangle. Three qubits have eight possible states, and so on. A system of nn qubits has 2n2^n basis states.

This exponential growth is the source of quantum computing's potential power. A classical computer needs 2n2^n numbers to describe nn qubits, but the qubits themselves exist in this full space naturally.

2

Quantum Gates

Quantum gates are operations that transform qubit states. They are the quantum equivalent of classical logic gates (AND, OR, NOT), but they work on superpositions and must be reversible (unitary).

Single-Qubit Gates

X Gate (Pauli-X)

qc.x(qubit)

The quantum NOT gate. Flips 0|0\rangle to 1|1\rangle and vice versa. Often called a "bit flip."

Z Gate (Pauli-Z)

qc.z(qubit)

Leaves 0|0\rangle unchanged but maps 1|1\rangle to 1-|1\rangle. Introduces a "phase flip" that affects interference. Has no effect on measurement probabilities alone.

Y Gate (Pauli-Y)

qc.y(qubit)

Combines the effects of X and Z (with a factor of ii). Flips the state and adds a phase.

Hadamard Gate (H)

qc.h(qubit)

The most important single-qubit gate. Maps 0|0\rangle to +|+\rangle (equal superposition) and 1|1\rangle to |-\rangle. Applying H twice returns to the original state.

S Gate (Phase Gate)

qc.s(qubit)

Adds a π2\frac{\pi}{2} phase to 1|1\rangle. A "quarter turn" around the Z-axis of the Bloch sphere. S2=ZS^2 = Z.

T Gate

qc.t(qubit)

Adds a π4\frac{\pi}{4} phase to 1|1\rangle. A finer rotation than S. T2=ST^2 = S. Important for fault-tolerant quantum computing.

Rotation Gates

Rotation gates allow precise, continuous control over qubit states. They take an angle parameter θ\theta and rotate the qubit around a specific axis of the Bloch sphere.

Rx(θ)R_x(\theta)

qc.rx(θ, qubit)

X-axis rotation

Ry(θ)R_y(\theta)

qc.ry(θ, qubit)

Y-axis rotation

Rz(θ)R_z(\theta)

qc.rz(θ, qubit)

Z-axis rotation

Rx(π)=XR_x(\pi) = X, Rz(π)=ZR_z(\pi) = Z (up to global phase). Rotation gates generalise the Pauli gates and are essential for variational quantum circuits.

Phase and the Bloch Sphere

You have seen that a qubit's state has amplitudes. But amplitudes are complex numbers, and complex numbers carry a property called phase. Phase is the angle of the complex number in the complex plane — it does not change the probability of measuring 0 or 1, but it has a dramatic effect on how amplitudes combine during interference.

Global phase vs relative phase

Global phase

Multiplying the entire state by a number like eiθe^{i\theta} changes nothing measurable. The states 0|0\rangle and eiπ0e^{i\pi}|0\rangle are physically identical. You can ignore global phase.

Relative phase

A phase difference between the amplitudes of 0|0\rangle and 1|1\rangle does matter. The states +=0+12|+\rangle = \frac{|0\rangle + |1\rangle}{\sqrt{2}} and =012|-\rangle = \frac{|0\rangle - |1\rangle}{\sqrt{2}} both have 50% measurement probabilities, but they behave very differently in circuits because the minus sign (a phase of π\pi) changes how they interfere.

Why does phase matter?

Quantum algorithms work by making correct answers interfere constructively (amplitudes add up) and wrong answers interfere destructively (amplitudes cancel out). Phase controls whether amplitudes add or cancel.

The Z, S, and T gates all work purely by adjusting phase. They do not change measurement probabilities directly — their effect only shows up when combined with other gates like the Hadamard.

The Bloch Sphere

The Bloch sphere is a visual way to represent a single qubit's state as a point on the surface of a sphere. Every single-qubit pure state corresponds to exactly one point on this sphere.

|0⟩|1⟩|+⟩|−⟩|+i⟩|−i⟩ZXY

The Bloch sphere. The arrow (state vector) points to the current state of the qubit. Every point on the surface is a valid single-qubit state.

North pole

0|0\rangle

Qubit is definitely 0

South pole

1|1\rangle

Qubit is definitely 1

Equator (+X)

+|+\rangle

Equal superposition (positive phase)

Equator (−X)

|-\rangle

Equal superposition (negative phase)

How gates move the state on the sphere

X gate: 180° rotation around the X-axis. Flips the qubit from north pole to south pole (or vice versa).

Z gate: 180° rotation around the Z-axis. Flips the phase. +|+\rangle becomes |-\rangle and vice versa, but 0|0\rangle and 1|1\rangle stay unchanged.

Hadamard (H): Swaps the Z-axis and X-axis. Takes 0|0\rangle (north pole) to +|+\rangle (equator) and 1|1\rangle (south pole) to |-\rangle.

Rotation gates (Rx,Ry,RzR_x, R_y, R_z): Rotate by any angle around their respective axis. This includes every single-qubit gate as a special case.

Do I need to memorise the Bloch sphere?

No. The Bloch sphere is a visualisation tool. It is helpful for building intuition about what gates do — especially phase gates that do not change measurement probabilities. If it helps you, use it. If not, you can solve every challenge without it.

Multi-Qubit Gates

CNOT (CX)

qc.cx(control, target)

The controlled-NOT gate. Flips the target qubit if and only if the control qubit is 1|1\rangle. The most common two-qubit gate. Essential for creating entanglement.

CZ

qc.cz(control, target)

Controlled-Z. Applies a Z gate to the target if the control is 1|1\rangle. Symmetric: it does not matter which qubit you call control or target.

SWAP

qc.swap(qubit1, qubit2)

Exchanges the states of two qubits. Equivalent to three CNOT gates. Useful when you need to rearrange qubit positions.

Toffoli (CCX)

qc.ccx(ctrl1, ctrl2, target)

Double-controlled NOT. Flips the target only when both control qubits are 1|1\rangle. The quantum equivalent of a classical AND gate.

Gate matrices

Every quantum gate is represented by a unitary matrix. For single-qubit gates, this is a 2×2 matrix. For two-qubit gates, it is 4×4. You do not need to know the matrices to solve challenges, but understanding them helps conceptualise what gates do to quantum states.

3

Circuits and Measurement

Building Circuits

A quantum circuit is a sequence of gates applied to qubits. Gates are applied left-to-right (in the order you write them in code). All qubits start in the 0|0\rangle state unless otherwise specified.

A circuit that creates the Bell state Φ+|\Phi^+\rangle:

qc = QuantumCircuit(2)
qc.h(0)       # Hadamard on qubit 0 → creates superposition
qc.cx(0, 1)   # CNOT: entangles qubit 0 and qubit 1
# Result: (|00⟩ + |11⟩)/√2

Circuit Depth

Circuit depth is the number of time steps needed to execute the circuit, assuming gates on different qubits can run in parallel. It measures the critical path length, not the total gate count.

Example: Depth 2

H on qubit 0, then CNOT(0,1). Two layers of operations. The H must finish before the CNOT can use qubit 0.

Example: Depth 1

H on qubit 0 and X on qubit 1 simultaneously. These operate on different qubits, so they run in the same time step.

Measurement

Measurement collapses a qubit's superposition into a definite classical value: 0 or 1. The probability of each outcome is determined by the amplitudes of the quantum state.

Measurement is probabilistic

A qubit in the +|+\rangle state has a 50% chance of measuring 0 and 50% chance of measuring 1. You cannot predict which outcome will occur for a single measurement.

Measurement is destructive

After measurement, the superposition is destroyed. The qubit collapses to whichever state was observed. You cannot "un-measure" a qubit.

Statistical results

By running a circuit many times (shots), you build up a probability distribution. With enough shots, the distribution converges to the true probabilities.

Measurement Notation

For a qubit in state ψ=α0+β1|\psi\rangle = \alpha|0\rangle + \beta|1\rangle, the Born rule gives the probability of each outcome:

P(0)=α2P(0) = |\alpha|^2— probability of measuring 0
P(1)=β2P(1) = |\beta|^2— probability of measuring 1
α2+β2=1|\alpha|^2 + |\beta|^2 = 1— probabilities must sum to 1 (normalisation)

After a 0 outcome the qubit collapses to 0|0\rangle; after a 1 outcome it collapses to 1|1\rangle. In Qiskit, explicit measurement syntax looks like:

qc = QuantumCircuit(2, 2)   # 2 qubits, 2 classical bits
qc.h(0)
qc.cx(0, 1)

# Measure individual qubits into classical bits
qc.measure(0, 0)   # qubit 0 → classical bit 0
qc.measure(1, 1)   # qubit 1 → classical bit 1

# Or measure all qubits at once
qc.measure_all()

Platform note

On Qubit Forge, your circuits are evaluated using a statevector simulator, which computes exact probabilities without needing to run thousands of shots. You do not need to add measurement gates -- the platform handles this automatically.

4

Entanglement

What Entanglement Is (and Isn't)

Entanglement is a correlation between qubits that has no classical equivalent. When two qubits are entangled, measuring one instantly determines the state of the other, regardless of the distance between them.

Entanglement IS

  • A quantum correlation between particles
  • A resource for quantum algorithms
  • Created by multi-qubit gates (CNOT, CZ)
  • Measurable through correlated outcomes

Entanglement IS NOT

  • Faster-than-light communication
  • Cloning or copying quantum states
  • A way to send information instantly
  • The same as classical correlation

Bell States

The Bell states are the four maximally entangled two-qubit states. They are the simplest examples of entanglement and appear frequently in challenges.

Φ+|\Phi^+\rangle

00+112\frac{|00\rangle + |11\rangle}{\sqrt{2}}

Created by: H(0), CNOT(0,1)

Φ|\Phi^-\rangle

00112\frac{|00\rangle - |11\rangle}{\sqrt{2}}

Created by: H(0), Z(0), CNOT(0,1)

Ψ+|\Psi^+\rangle

01+102\frac{|01\rangle + |10\rangle}{\sqrt{2}}

Created by: X(1), H(0), CNOT(0,1)

Ψ|\Psi^-\rangle

01102\frac{|01\rangle - |10\rangle}{\sqrt{2}}

Created by: X(1), H(0), Z(0), CNOT(0,1)

Entanglement as a Resource

Entanglement is not just a curiosity -- it is a computational resource. Quantum algorithms exploit entanglement to achieve speedups over classical algorithms. Key applications include:

  • Quantum teleportation: transferring quantum states using entanglement and classical communication
  • Superdense coding: sending two classical bits using one qubit and shared entanglement
  • Quantum error correction: protecting information by encoding it across entangled qubits
  • Algorithm speedups: Grover's search and Shor's factoring both rely on entanglement
5

Algorithms Overview

Quantum Parallelism

A quantum computer can evaluate a function on all possible inputs simultaneously by preparing a superposition of inputs. This is not the same as classical parallelism -- you cannot directly read out all results. The art of quantum algorithms is designing circuits that extract useful information from the superposition through measurement.

Interference and Amplitude Manipulation

Quantum algorithms work by manipulating amplitudes so that correct answers have higher probability and wrong answers have lower probability. This is achieved through interference:

Constructive Interference

Amplitudes add together, increasing the probability of a particular outcome. Correct answers are amplified.

Destructive Interference

Amplitudes cancel each other out, reducing the probability of a particular outcome. Wrong answers are suppressed.

Key Algorithm Families

These algorithm families appear in Master-level challenges. Understanding the high-level idea is more important than memorising implementations.

Deutsch-Jozsa

Determines whether a function is constant or balanced using a single query. The simplest demonstration of quantum speedup. Tests your understanding of oracles and interference.

Grover's Search

Searches an unsorted database in O(N)O(\sqrt{N}) time versus O(N)O(N) classically. Uses amplitude amplification: mark the target state, then amplify its amplitude through repeated Grover iterations.

Quantum Phase Estimation (QPE)

Estimates the eigenvalue (phase) of a unitary operator. A fundamental subroutine used in many other algorithms, including Shor's algorithm for factoring.

Variational Quantum Eigensolver (VQE)

A hybrid classical-quantum algorithm for finding ground state energies. Uses parameterised circuits with rotation gates. The classical optimiser adjusts gate angles based on measurement results.

Quantum Fourier Transform (QFT)

The quantum analogue of the discrete Fourier transform. Operates exponentially faster than its classical counterpart. Core component of phase estimation and factoring algorithms.

6

Practical Considerations

On Qubit Forge, you are not just solving for correctness -- you are solving for efficiency. These practical techniques help you design better circuits.

Circuit Depth Management

Parallelise independent operations

If two gates act on different qubits, they can execute in the same time step. Apply them back-to-back in your code and Qiskit will optimise the depth.

Avoid unnecessary serialisation

Only create dependencies between gates when the algorithm requires it. A Hadamard on qubit 0 and an X on qubit 1 have no dependency.

Use native multi-qubit gates

A single CNOT is depth 1. Decomposing it into multiple single-qubit operations increases depth unnecessarily.

Gate Count Optimisation

Combine rotations

Two consecutive RzR_z gates on the same qubit can be combined into a single RzR_z with the summed angle. Three H gates = one H gate (since H2=IH^2 = I).

Choose the right gate

Use the most direct gate for the job. If you need a phase flip, use Z directly rather than Rz(π)R_z(\pi).

Eliminate identity operations

Applying a gate and then its inverse accomplishes nothing. XX=IXX = I, HH=IHH = I, CNOTCNOT=I\text{CNOT} \cdot \text{CNOT} = I. Remove these redundancies.

Why Constraints Matter

Qubit Forge challenges impose constraints for a reason: on real quantum hardware, every gate introduces noise (errors) and every qubit is expensive. Efficient circuits are not just an academic exercise -- they are essential for practical quantum computing.

  • Fewer gates = less accumulated noise on real hardware
  • Shallower circuits = less decoherence (qubits lose their quantum properties over time)
  • Fewer qubits = more practical deployability on current hardware
  • Constraint awareness is a core quantum engineering skill that employers value

What's Next

This primer covers the core concepts used in Qubit Forge challenges. For deeper learning, explore the external resources on the main Resources page, or start solving challenges to apply what you have learned.