Classical information
Classical states
Suppose we have a physical system that stores information. In the classical model, the system has a finite set of possible classical states. Call that set .
At any given moment, is in exactly one of those states. If the current state is written as , then .
Bit
The system is either 0 or 1, never both.
Dice
The upward face can be only one value at a time.
Probabilistic states
When we are uncertain about which state is in, we describe our knowledge using a probabilistic state. A probability is assigned to each , and all probabilities together sum to 1.
Probability vectors
The same distribution can be written as a probability vector - a column of numbers, one per state in , in a fixed order:
Dirac notation
The same probability vector can be written with Dirac notation. Suppose the elements of the state set are ordered as . For any state , is the column vector having a 1 in the entry corresponding to in that ordering, with 0 for all other entries.
Standard basis vectors:
Any vector is then a combination of standard basis vectors. In our example, is the probability of and is the probability of :
These notation versions all describe the same distribution. The probability statements, the column vector, and the Dirac notation are just different tools for writing the same information, each useful in a different setting.
Deterministic operations
A deterministic operation has no chance involved: each input state has exactly one output state. We can write it as a function from the state set to itself:
In Dirac notation, each state is represented by a basis vector . The operation becomes a matrix that acts on those basis vectors:
- feed in the basis vector for state
- get out the basis vector for state
The matrix entries are defined by:
This says:
- column describes what happens to input state
- the only in that column appears in the row for the output state
- all other entries are 0
For example, if and , then the operation always sends, with no uncertainty involved:
This function can be represented by the matrix . Its columns are the possible input states, and its rows are the possible output states. For each input , column contains a single in row , with every other entry equal to :
Matrix-vector updates
Instead of tracking individual state transitions, we can apply the matrix to the entire probability distribution at once. If is the current probability vector, the updated distribution is:
Consider a probability distribution where input 0 has probability , input 1 has probability , and input 2 has probability . The vector represents this distribution. When is applied, the probability associated with input 2 moves to output 0, the probabilities of inputs 0 and 1 are merged at output 1, and output 2 receives no probability mass:
We could update the probabilities by following each input separately and moving its probability mass to the corresponding output. The matrix packages all of these transfers into a single matrix-vector multiplication, producing the updated probability distribution in one step.
One-bit matrices
For a single bit , there are four possible deterministic operations:
Set to 0
Identity
NOT / bit flip
Set to 1
Bras and inner products
In Dirac notation, column vectors are called kets and are written as and . Their row-vector counterparts are called bras and are written with the bracket facing the opposite direction:
Multiplying a row vector by a column vector produces a single number. This operation is called the inner product, or dot product. It measures how much two vectors overlap:
For basis states, kets and bras contain a single 1 and zeros everywhere else. If we multiply matching states, the 1s line up. If we multiply different states, the 1s occur in different positions, so every term in the sum is zero:
So multiplying a bra by a ket, denoted as , acts like an equality test: it returns 1 when the states are the same and 0 when they are different:
Ket-bra products
If row-by-column multiplication gives a single number, then column-by-row multiplication gives a matrix. This operation is called an outer product:
For one-bit basis states, a ket-bra product creates a matrix with a single 1 and zeros everywhere else:
Suppose we are given a deterministic operation where, for each state , the function specifies an output state , representing this individual rule with the ket-bra operator , where the bra identifies the input state while the ket specifies the state that should be produced, so that adding one such term for every possible input state yields a matrix that implements the entire deterministic operation:
For the function , the deterministic rules are , and each rule contributes one ket-bra term: the rule becomes , the rule becomes , and the rule becomes — note that while we are used to reading input on the left and output on the right, in ket-bra notation the output comes first: means "produce when you see ."
Adding these terms gives:
Applying it to the basis state , the first two inner products vanish and only the matching term survives:
Each of the three ket-bra terms in is an ordinary matrix:
Adding them together gives exactly the deterministic-operation matrix constructed earlier:
The action of this matrix becomes clear when it is applied to a basis state . In each term, the inner product acts as an equality test: it equals 1 when and 0 otherwise. As a result, every term in the sum vanishes except the one corresponding to , leaving:
Thus the matrix sends each basis state to the state specified by the function, .
Probabilistic operations
A deterministic operation maps each input state to exactly one output state. A probabilistic operation is more general: each input state produces a probability distribution over output states. The operation is described by a matrix where entry gives the probability that input state produces output state .
For to represent a valid probabilistic operation, two conditions must hold. All entries must be nonnegative real numbers:
And the entries in each column must sum to 1 — each column is a probability vector describing the output distribution for one input state:
A matrix satisfying both conditions is called a stochastic matrix. Every deterministic-operation matrix is a special case: its columns each contain a single 1 and zeros elsewhere, which is a valid probability vector.
Composing operations
When two operations are applied in sequence — first , then — the result is . Because matrix multiplication is associative, this equals : the composition is itself a matrix, and the product of two stochastic matrices is stochastic.
Matrix multiplication is not commutative, however: and generally produce different results. The order in which operations are applied matters.
Using the one-bit matrices introduced earlier, we can see this directly. Applying (set to 0) and then (NOT) always produces 1 — equivalent to . Doing the same two operations in the opposite order always produces 0 — equivalent to itself:
Quantum information
Two levels of description
Quantum information can be described at two levels of generality. The simplified picture — kets and unitary matrices — is enough for pure states and reversible operations. The general picture adds density matrices and a broader class of measurements and operations, covering mixed states, noise, and measurement.
| Simplified | General | |
|---|---|---|
| Quantum states | Kets — state vectors | Density matrices |
| Operations | Unitary matrices | More general class of measurements and operations |
Quantum states
A quantum state of a system is represented by a column vector whose indices are placed in correspondence with the classical states of that system:
A valid quantum state vector must satisfy two conditions:
- Entries are complex numbers — amplitudes, not probabilities:
- The sum of squared absolute values of the entries equals 1:
The second condition uses the Euclidean norm — the generalisation of vector length to complex numbers:
Real vector
Complex vector
Quantum state vectors are unit vectors — . The amplitudes encode probability amplitudes: the probability of observing the system in classical state is .
Qubit states
A qubit is a quantum system whose classical state set is , so its state vector has two entries. The basis states and look like ordinary integer vectors, but their entries are complex numbers that happen to have zero imaginary part:
A general qubit state is any normalised complex combination of these two basis states:
Two particularly important named states are the plus and minus states. They assign equal probability to the basis states and — 50% and 50% — but differ in the relative sign between their amplitudes:
Most qubit states have no special name. Any normalised choice of and is valid — for example:
Conjugate transpose
Every ket has a corresponding bra obtained by the conjugate transpose — written with a (dagger):
Two steps: transpose the column vector into a row, then replace each entry with its complex conjugate — . For the qubit state :
The real amplitude is unchanged — conjugating a real number leaves it the same. Only the complex entry flips its imaginary part to give .
Why do we conjugate?
A complex number is not just a number—it can also be viewed as a point (or vector) in the complex plane.
Its length is simply the Euclidean distance from the origin:
The challenge is to compute this length using only complex arithmetic. Notice what happens if we multiply by its conjugate:
The imaginary terms cancel, leaving exactly the square of the Euclidean length:
This is why the complex conjugate appears. It isn't an arbitrary rule—it is the operation that recovers the ordinary Euclidean length of a complex number.
The inner product extends this same idea to vectors by applying the conjugate transpose to every amplitude:
Measurements
Measuring a quantum state extracts classical information from it. In a standard basis measurement, the possible outcomes are the classical states — the same states that label the entries of the state vector. For a state , the probability of obtaining outcome is the squared absolute value of the corresponding amplitude:
For example, measuring the state gives each outcome with equal probability:
For the state with complex amplitudes:
Measurement also changes the state. Once outcome is observed, the quantum state collapses to the corresponding basis state . A second measurement on the collapsed state will always return the same outcome — this is called the collapse of the quantum state.
The same logic applies to ordinary probability. Flip a coin and let it land face-up on the table. Before you look, each side has probability . The moment you look, the uncertainty is gone — the coin is showing heads, and re-checking it a second or third time still shows heads with certainty. What changes is not the coin but your state of knowledge about it. Quantum collapse works the same way from the outside: once you have a measurement result, subsequent measurements on that same state are no longer uncertain.
After the measurement, regardless of the pre-measurement state, the system is in a definite classical state or . This places a fundamental limit on how much classical information can be extracted from a quantum state in a single measurement.
Unitary operations
Quantum operations are represented by unitary matrices — a different constraint from the stochastic matrices of classical probabilistic operations. A square matrix is unitary if its conjugate transpose is also its inverse:
This has two equivalent restatements:
- The inverse is simply the conjugate transpose — — so inverting a unitary is cheap.
- Unitary matrices preserve the Euclidean norm: .
To see why the norm is preserved, first notice that for any column vector, multiplying it by its own conjugate transpose gives the squared norm — the conjugates pair with each entry to produce :
Or, in Dirac notation:
Since holds for any vector, we can apply it to . The rule says the conjugate transpose of a product reverses the order — so:
Substituting into and applying :
Taking square roots gives . As a numeric check, applying to the familiar state:
It simply swaps the two entries:
Geometrically, a unitary transformation is the complex-number analogue of a rotation: it changes the direction of the vector, but never its length. Since quantum state vectors are unit vectors, a unitary operation always maps valid quantum states to valid quantum states — it can never take a state outside the unit sphere.
To check if a matrix is unitary, multiply it by its conjugate transpose and see if the result is the identity.
For , which is real and symmetric so :
Qubit unitary operations
1. Pauli operations
The four Pauli matrices are the most common single-qubit unitary operations:
Identity
Bit flip
Phase + bit flip
Phase flip
The Pauli matrices also happen to be Hermitian — a matrix is Hermitian if it equals its own conjugate transpose, . For a real symmetric matrix this just means symmetry across the diagonal. For a complex matrix, entries are mirrored across the diagonal and conjugated.
2. Hadamard
The Hadamard gate H, named after the French mathematician Jacques Hadamard, is one of the most important quantum gates. It acts as a bridge between two ways of describing a qubit:
- The computational basis: and
- The superposition basis: and
From 0, 1 to +, -:
From +, - back to 0, 1:
Applying a Hadamard gate transforms a computational basis state into an equal superposition of and , meaning that a measurement would find each outcome with equal probability:
You can think of the Hadamard gate as a quantum "basis changer" that lets us move between definite states and equal-probability superpositions, making it a fundamental building block of many quantum algorithms.
3. Phase gates
Phase gates leave unchanged and rotate by a complex phase. They do not change measurement probabilities on their own, but they shift the relative phase between amplitudes, which affects how states interfere in a larger circuit.
The general phase rotation gate applies a phase to while leaving alone. is a real number, making always purely imaginary. This means always lies on the complex unit circle — — so it is a pure phase that rotates without scaling:
Two standard choices give the S gate and the T gate:
S applies a quarter-turn phase (90°) and satisfies , where Z is the Pauli phase-flip gate from section 1: . T applies an eighth-turn phase (45°) and satisfies and . Together with H, T generates a gate set that can approximate any single-qubit unitary to arbitrary precision.
Applied to the basis states:
Composing unitary operations
Gates compose by matrix multiplication. In the product the rightmost matrix acts first — the state travels right to left through the sequence:
For example, in the rightmost gate (purple H) acts first, then S, then the leftmost H (blue). Expanding step by step:
This matrix is called the square root of NOT (written ), because applying it twice gives the Pauli X (NOT) gate. To see why, insert in the middle and use :
In ordinary arithmetic, squaring something makes it "more of the same" — you would never expect a number squared to flip a sign. But unitary matrices can have complex eigenvalues such as , and introduces the sign change that turns a partial rotation into a full logical inversion. This is one of the ways quantum gates behave fundamentally differently from classical boolean operations.
As another example, consider HTH. T is a rotation around the Z axis by . Placing H on both sides redirects that same rotation onto the X axis:
So T and HTH are rotations around two non-parallel axes — Z and X — each by . Combining rotations around any two non-parallel axes generates all rotations of the sphere, so any single-qubit unitary can be reached by some finite sequence of T and HTH to any desired precision.
Multiple systems: classical
Classical states
Suppose we have two systems:
- with classical state set .
- with classical state set .
Together they form a compound system, written or simply . At any moment the compound system is in exactly one state - a pair where is the state of and is the state of .
The full set of possible states of is the Cartesian product:
For example, if both and are bits so , the compound system has four possible states:
General formula: if we combine classical systems with state sets , their compound state set is:
Convention notes
- When we list a Cartesian product, we usually use lexicographic order: compare the first coordinate, then the second, and so on.
- This assumes each state set already has an order. For bits, we use .
- Significance decreases from left to right: the leftmost coordinate is the most significant, and the rightmost coordinate changes fastest.
Example: for three bits, . In lexicographic order:
Probabilistic states
For a compound classical system, a probabilistic state assigns one probability to each state in the Cartesian product. If is the current state of and is the current state of , then:
For example, for the system of two bits, where and the possible compound states are , one of multiple possible probabilistic states can be:
The two-bit system is equally likely to be in state or state , and has probability zero of being in the other two states. In vector form (using lexicographic order):
For another two-bit system, the probability state might look like:
For a given probabilistic state of , we say and are independent if for all and .
Let's check and against this rule — by looking for a contradiction.
u — suppose the rule holds:
Contradiction — and are not independent under .
v — no contradiction arises:
and are independent under .
Correlation is, in a sense, a lack of independence: when two systems are not independent, the state of one carries information about the state of the other.
Dirac notation
The same rule for independence can be written in Dirac notation. Suppose that a probabilistic state of is expressed as a vector:
The systems and are independent if there exist probability vectors
such that for all and .
- — the probabilistic state of the compound system
- — the probability assigned to outcome
- — a basis vector labelling the outcome for these are the four standard basis vectors:
Returning to and from the earlier example. For , its column vector alongside its expansion:
For , its column vector alongside its expansion:
Since and are independent under , there exist probability vectors and such that each coefficient in is a product of one factor from each:
Tensor products of vectors
When working with multiple systems, we need a way to combine their vector spaces into a larger one. The mathematical operation that does this is the tensor product.
Given two vectors, and , their tensor product, written , represents the combined state of both systems. Every basis state of the first vector is paired with every basis state of the second, and the corresponding coefficients are multiplied.
- — probability vector for system , with coefficients
- — probability vector for system , with coefficients
- — coefficient of the compound basis state in
- — the Cartesian product of the two state sets; the sum runs over all possible pairs
Inner product form
Equivalently, the vector is defined by this condition:
Here, is a single number — the coefficient (amplitude) of basis state in ; and is also a single number — the coefficient of basis state in :
So the condition says: the coefficient of the combined basis state in is the product of the coefficients of and separately. means: take the vector and ask what its coefficient is along basis state .
For example, suppose
Then . It is just extracting one coefficient.
Now suppose
Then:
Therefore:
The amplitude of the combined outcome equals the product of the amplitudes of the individual outcomes and .
Column vector form
The tensor product can be viewed as a "multiply every entry by every entry" operation. Each coefficient of the first vector is paired with every coefficient of the second, producing a larger vector that represents all possible combinations of the two systems. As a result, dimensions multiply: if has entries and has entries, then has entries.
Tensor product of standard basis vectors
The tensor product of two standard basis vectors is often written by simply combining their labels into a single basis label. Thus, instead of writing , we commonly write , which can be viewed as shorthand for the basis vector indexed by the pair . More explicitly, one could write , but in practice the parentheses are usually omitted and the notation is preferred. This follows a common mathematical convention of removing symbols that do not add information or eliminate ambiguity. From a mathematician's perspective, once the structure is understood, the parentheses are carrying no real content and can be safely discarded. Of course, for anyone still getting comfortable with Dirac notation, the more explicit form can be a useful stepping stone — it makes the two-label structure impossible to miss, and once that structure feels natural, dropping the parentheses costs nothing.
For example, for two-bit systems where , each of the four standard basis vectors of the compound system arises as a tensor product:
To see this concretely, take and apply the column-vector rule — multiply every entry of the first vector by every entry of the second:
The result is exactly the standard basis vector — confirming that the label shorthand and the column-vector computation agree.
The same shorthand is used for basis bras: . For two-bit systems, , , , and .
Properties of tensor product
The tensor product is bilinear — it preserves the familiar rules of linearity in both of its arguments. You can distribute over addition and pull out scalar factors from either side independently.
First argument
For example, take , , :
For scalar multiplication, take , , :
Second argument
For example, take , , :
For scalar multiplication, take , , :
Multiple systems (multilinearity)
Tensor products generalize to three or more systems. If are vectors, their tensor product is defined by the equation .
The bra is shorthand for (tensor symbols are omitted for concise notation), so means applying that product bra to the tensor-product state. The equation says the larger inner product splits into matching ordinary overlaps:
For example, take with and let . To read off the amplitude of the specific outcome , apply the formula directly — no need to expand the full tensor product first:
The same value can be found by expanding the tensor product first, but that is a bit more work because we build the combined state and then apply the bra:
Any other outcome follows the same pattern. For instance, :
The direct formula is the cleanest way to get one amplitude, but the recursive view is useful when we want the whole combined vector. It peels off the last factor:
Using the same example, keep the two coefficients from visible while peeling off :
Measurement of probabilistic states
Consider the compound system in the probabilistic state:
Measuring all systems
Measuring the entire compound system at once is equivalent to measuring each subsystem independently — provided all systems are measured. The measurement produces a single combined outcome drawn from the joint probability distribution.
For this state the two possible combined outcomes are and , each with probability . Each individual measurement still happens according to those probabilities, but the whole state is measured together — producing exactly one combined result at a time: either or .
Measuring some systems
Suppose only a subset of systems is measured — for example, only from . Then, to find the probability that equals some value , add up probabilities of all outcomes where :
For the probabilistic state , the table below expands the Dirac notation into the four possible joint outcomes of and their probabilities.
| X | Y | Pr |
|---|---|---|
| 0 | 0 | |
| 0 | 1 | |
| 1 | 0 | |
| 1 | 1 |
But what happens to our knowledge of ?
After measuring and getting result , there can still be uncertainty about the state of . If we already measured and got , what is the probability that ?
Think of the division as rescaling the probabilities so they add up to again after we focus on only one situation. For example, once we learn that , we ignore all outcomes where . The probabilities of the remaining outcomes no longer add up to , because part of the original probability space was removed.
To turn the remaining outcomes into a valid probability distribution again, we divide each remaining probability by the total probability of . This process is called normalization. So the division means: out of the world where happened, how likely is each remaining outcome?
If we measured
If we measured
Measuring one system, in Dirac notation
Everything above can be expressed directly on the state vector:
Reading the chain left to right:
- — a general probabilistic state of : the sum over all possible joint outcomes , each weighted by its probability .
- — split every compound basis state into a tensor product, , separating the part from the part.
- — use bilinearity to pull the shared out of the inner sum. This groups the terms by the value of : one branch per value , with all of 's weight collected inside the parentheses.
For example, for the probabilistic state , we can split the compound state into , and into , and group by :
To get the probability of measuring , add the probabilities of all states that start with :
Where:
- — the probability of the joint outcome . The first index is the value of , the second index is the value of — so means .
- — keep fixed at and sweep over every possible ; that is, add up every outcome that starts with .
After measuring , all branches with other values of disappear. The remaining state of is the surviving branch, divided by its total weight so the coefficients add back up to :
The index in the normalizing sum is just a dummy variable: writing instead of avoids clashing with the in the numerator, but both range over all of . What it really collects is every outcome whose first coordinate is .
Example
Take the probabilistic state of :
We measure only (the first bit). Grouping by as above:
If we measured
The probabilistic state of becomes (normalize by ):
If we measured
The probabilistic state of becomes (normalize by ):
Measuring some: Y
Just like we grouped by , we can apply the same principle and group by — regroup the same sum by instead of :
To get the probability of measuring , add the probabilities of all states that end with :
After measuring , all branches with other values of disappear, and the remaining state of is that branch normalized by its total weight:
Example
Take the same state, but this time measure only (the second bit):
Grouping by this time:
If we measured
The probabilistic state of becomes (normalize by ):
If we measured
The probabilistic state of becomes (normalize by ):
Note: for classical, probabilistic systems these conditional probabilities are easier to handle with simple conditional-probability tables. But later, with quantum states, those simple tables stop working — so Dirac notation it is (I am starting to get used to it, but I understand the struggle, deeply!).
Operations on probabilistic states
Probabilistic operations on compound systems, just like for individual systems, are represented by stochastic matrices. But this time the matrices have rows and columns corresponding to the Cartesian product of the individual systems' classical state sets.
A deterministic example: controlled-NOT
Take a controlled-NOT operation on two bits :
- if ⇒ apply NOT to ;
- if ⇒ do nothing.
Here is the control bit and is the target bit. It is deterministic — each input state maps to exactly one output state:
Input → output
Matrix representation
For example, applying the matrix operation to flips the target, giving :
Nothing special is going on — the operation is just a matrix acting on the probability vector.
A probabilistic example
A probabilistic operation makes a random choice. For example:
- with probability ⇒ set ;
- with probability ⇒ set .
Each branch is itself a deterministic stochastic matrix. Take the input to see how both behave:
Set
Set
The overall probabilistic operation is the average of these two matrices, weighted by the probabilities :
The resulting matrix does not describe one concrete execution — it describes the distribution over outcomes after the random choice.
Simultaneous operations on a compound system
Suppose instead that two probabilistic operations act on separate systems — on and on , each its own stochastic matrix on its own probability vector. If we perform both at the same time, how do we describe their combined effect on the compound system?
Tensor product of matrices
Performing on and on simultaneously is described by a single matrix on the compound system — the tensor product . Writing each operation in Dirac notation,
the tensor product pairs every term of one with every term of the other, multiplying their coefficients:
- — the entry of in row , column
- — the entry of in row , column
- — the compound outer product, using the identity
Example: bit‑flip identity
First rewrite each in Dirac notation by reading off its entries: the entry in row , column is the coefficient of :
— bit‑flip on
Written out and simplified:
— identity on
Written out and simplified:
Method 1 — Kronecker blocks
Replace each entry of with the block :
Method 2 — Dirac expansion
Distribute (bilinearity), collapse each term with the identity, then keep the equality chain going by turning each outer product into its matrix:
Key idea of Dirac notation
A sandwich is just the single entry of at row , column . The bra is the unit row vector that picks out row , and the ket is the unit column vector that picks out column — multiplying them on either side of collapses the whole matrix down to one number. Indices count from , so is the top-left entry:
Equivalent entry rule
Equivalently, the tensor product is the matrix whose compound entry is found by multiplying the matching entry from with the matching entry from :
- Read from right to left: is the starting column, is the matrix you apply, and is the output row you read. For example, let's calculate . Start with the input column , apply , then read the value in the output row — the result is .columns in0010000110000100rows out
- The right side asks the same question one system at a time: asks how much sends to , and asks how much sends to . For the same example, look up each factor in its own matrix — is the entry of in row , column , and likewise for — then multiply them:01101001
- In this example, flips the first bit and leaves the second unchanged, so sends straight to . The resulting is the amplitude of that transition: it says all of the input lands on and none on any other basis state — the mapping is exact and deterministic (a coefficient of would mean never reaches ).
Why the entry rule holds
We want the entry of at row and column . The rule says: take the matching entry from , take the matching entry from , then multiply them.
Derivation
The compound entry we want.
Write and as sums of weighted outer products.
Linearity pulls the coefficients out front, and becomes .
Each compound overlap breaks into one bracket per system.
Those brackets vanish unless , , , .
Only that single term survives the double sum.
Exactly the per-system entry rule we set out to prove.
Selector picture
Focus on the part first. The two brackets are two tests on the same cell:
- asks: is this cell in row ?
- asks: is this cell in column ?
A cell must pass both tests. If it fails either one, it gets multiplied by .
The part does the same thing with and , so it leaves .
Example: ,
Pale cells pass one test but fail the other. The highlighted cell passes both, so it is the only one left.
Equivalent action on product states
Equivalently, is the unique matrix that satisfies the equation for all vectors and :
The tensor product is defined by one rule: apply to the first subsystem and to the second. Because every state can be built from basis states by adding them together, and linear maps preserve addition, this rule completely determines the full matrix.
Explicit formula
Collecting the entry rule into a single matrix gives the explicit form of the tensor product. Each entry is the product , so for with entries up to and with entries up to :
Three or more matrices
Nothing about the entry rule was special to two systems. For factors , a compound entry still splits into one bracket per system — each is asked the same question about its own bits in isolation, and the answers multiply:
The product also stays compatible with ordinary matrix multiplication. Running one stack of operators after another is the same as multiplying the matrices system by system (the mixed‑product property):
Multiple systems: quantum
Quantum states
A quantum state of several systems is represented by a column vector whose indices correspond to the Cartesian product of the individual systems' classical state sets — exactly the same index set as the compound classical system, now carrying complex amplitudes instead of probabilities.
For two systems with state set and with state set , the entries are indexed by . If both are bits, the four indices are:
So a quantum state of the two-bit system is a four-entry column vector. Written as a combination of the standard basis states :
As with a single system, the amplitudes are complex numbers and the vector is a unit vector: the squared absolute values sum to one, and is the probability of measuring the pair .
Definite (basis) state
is certainly and is certainly .
Equal superposition
All four outcomes are equally likely, each with probability .
Biased superposition
Still a unit vector: .
Entangled (Bell) state
Measuring gives or with equal probability and never or , so the two bits always come out the same. Unlike the states above, it cannot be factored into a separate state for each bit — no equals . That inseparability is what entanglement means.
In general, combining systems with state sets gives a state vector indexed by , so its dimension is the product of the individual sizes — for qubits, amplitudes.
Tensor products of states
The previous states described one compound system directly. We can also build a compound state by combining states of the parts: the tensor product of two quantum state vectors is again a quantum state vector.
Let be a state of system and a state of system . Their tensor product is a state of the joint system :
States of this form are called product states. They describe the two systems acting independently — each part has its own well-defined state, with no correlation between them. (Entangled states like cannot be written this way.)
More generally, if are states of systems , then their tensor product is a product state of the whole compound system :
Example: a state that is not a product state
It is a valid quantum state — a unit vector, since the squared amplitudes sum to one:
But it cannot be written as a tensor product . Any product expands to . Matching our state forces (no or terms) while and are both nonzero — which is impossible. So the two bits are entangled, not independent.
The Bell basis
The state from the previous example, , is one of four Bell states. Each differs only by which basis pairs are combined and by a sign, and together they form the Bell basis — an orthonormal basis of the two-qubit space made entirely of maximally entangled states.
None of the four can be written as a tensor product , so each is entangled. Because they are orthonormal, any two-qubit state can be expressed as a combination of these four.
Three-qubit states
Entanglement is not limited to pairs. Two famous three-qubit states show different ways three systems can be correlated — both are unit vectors and neither is a product state.
GHZ state
All three qubits are either or all . Measuring any one qubit instantly fixes the other two — the three-qubit analogue of the Bell state .
W state
Exactly one qubit is and its position is in superposition. Each squared amplitude is , and the three sum to one.
Measurements
Measuring a compound quantum system works exactly like measuring a single one — provided every system is measured. A standard basis measurement of the whole system returns one combined classical outcome, drawn from the squared amplitudes just as in the single-system case.
If is a quantum state of a system and all systems are measured, then each -tuple
(or string ) is obtained with probability equal to the squared absolute value of its amplitude:
The inner product simply picks out the amplitude sitting in front of the basis state — the entry of the state vector indexed by that outcome.
Example 1
Measuring both qubits of the Bell state gives or only — the two qubits always agree:
Example 2
Subsystems need not be qubits and amplitudes may be complex. For the pair in the state :
The two add to , and the drops out under — only amplitude magnitudes matter.
Measuring some systems
What if two systems share a quantum state but we measure only and leave alone? Write the joint state in the usual form:
If both were measured, outcome would appear with probability . Measuring only must give the same probability for as summing over every outcome:
Just as in the probabilistic setting, the state of changes as a result. The branch with survives and must be renormalized back to a unit vector — but because these are amplitudes, not probabilities, we divide by the square root of :
That square-root normalization is the one real difference from the classical case — otherwise partial measurement collapses a quantum compound system exactly the way it collapses a probabilistic one.
Example 3
Suppose is in the state below and we measure only :
We begin by writing it grouped by , factoring each term into :
The probability of each outcome is the squared norm of its branch. Recall the norm is a vector's length, so the squared norm is just the sum of the squared amplitude magnitudes:
Then keep the surviving branch and divide by so it is a unit vector again.
Outcome
Divide the branch by :
Outcome
Divide the branch by :
Each squared amplitude in the post-measurement state now sums back to : for , ; for , — measuring has left in a valid quantum state.
Measuring some: Y
The same works the other way round. Take the same state but measure only , grouping each term by instead:
Now each branch carries the amplitudes of . The same squared-norm rule gives the outcome probabilities, and the surviving branch is divided by :
Outcome
Divide the branch by :
Outcome
Divide the branch by :
As before the two probabilities add to , and each collapsed state is a unit vector again.
Example 4 — three qubits
Nothing changes with more systems. Take the W state of and measure only the first qubit , grouping the rest as :
Outcome
Divide the branch by — and is left in the Bell state :
Outcome
Divide the branch by — and is left in the definite state :
This shows the robustness of the W state mentioned earlier: with probability losing one qubit still leaves the other two entangled — whereas a GHZ state would collapse to a fully definite or on either outcome.
Key idea: no matter how many systems there are, we can always regroup the state into the part being measured and the part left unmeasured — one branch per outcome of the measured part. Each outcome's probability is the squared norm of its branch, and the unmeasured part is left in that branch, renormalized by . The split into “measured” vs. “unmeasured” is all that matters — the same recipe handles any subset of any number of systems.
Unitary operations
Just like for a single system, a quantum operation on a compound system is represented by a unitary matrix — but now its rows and columns are indexed by the Cartesian product of the individual classical state sets, the same index set as the compound state vector it acts on.
For instance, if has state set and has state set , the compound system has classical states, so an operation on is a unitary matrix:
Independent operations: tensor product
The general matrix above can entangle the systems it acts on. But often each system is acted on independently — a separate gate on each, with no interaction between them. Just as the tensor product combined separate states into one compound vector, it combines these separate operations into one compound unitary. If carry the operations , the combined action on is their tensor product:
Read it slot by slot: the matrix in each position is the operation that system experiences on its own. A tensor product of unitaries is again unitary, so independent operations always assemble into a single valid operation on the whole compound system.
The most common case is acting on just one part and leaving the rest alone — and doing nothing is itself a unitary, the identity matrix . For instance, applying the Hadamard gate to the first qubit while leaving the second untouched is , which passes the second qubit through unchanged:
Swapping the order applies to the second qubit instead — now appears as two identical blocks along the diagonal:
Operations that aren't tensor products: SWAP
A tensor product describes systems acted on independently, but not every unitary on a compound system factors that way. The standard example is the SWAP operation, which exchanges the contents of two systems and sharing the same classical state set :
To build that operation, consider one possible input basis state . The bra recognizes that input, while the ket supplies its swapped output. Their outer product therefore handles one input, and summing over every possible pair handles them all:
Each tensor-product term handles one specific pair: changes the first system from to , while changes the second from to . Together they map to . So every such tensor-product term swaps one specific pair.
For example, let's consider a simple system of two qubits. Each qubit has basis-state set , so both and can be either 0 or 1. Writing out all four possible pairs in the sum gives:
To apply SWAP, multiply its matrix by the compound state vector. For example, the basis state is the second standard basis vector, so the multiplication moves its 1 into the position for :
Controlled operations
Suppose that is a qubit and is an arbitrary quantum system. A controlled- operation uses as a switch for a unitary operation on . When the control is , the target system is left unchanged; when the control is , the operation is applied to it.
The projectors and select those two branches, giving the following operation on the pair :
The matrix is a block matrix, not an ordinary 2 × 2 matrix. If has basis states, then , , and each zero are all blocks. The complete controlled- matrix is therefore . In particular, if is a qubit, the blocks are and the full matrix is .
Example: controlled-NOT
Let the target also be a qubit and choose . On one qubit, flips the two basis states:
Now substitute and into the controlled- formula. The following equalities turn the general controlled operation into the controlled-NOT, or CNOT, gate:
In this example, the first digit is the control and the second is the target. Therefore means that the control is and the target is . A control value of 1 turns the operation on. The control stays at 1, while flips the target from 0 to 1:
In the standard basis order , the state is the third basis vector. The full matrix multiplication shows the same change from the third basis vector to the fourth:
The control can be any qubit
The first qubit is the control above only because we chose it that way. A controlled operation can use any qubit as its control. If the second qubit controls an operation on the first, the projectors move to the second tensor factor:
With that ordering, the second digit of is the control, and the first digit is the target.
Example: Fredkin operation
A controlled-SWAP on three qubits swaps the last two qubits only when the first qubit is 1. This is called the Fredkin operation, or Fredkin gate:
Example: Toffoli operation
A controlled-controlled-NOT on three qubits flips the third qubit only when both the first and second qubits are 1. This is called the Toffoli operation, or Toffoli gate:
Quantum circuits
Circuits as models of computation
A circuit is a graphical model of computation. It describes how information moves through a computation and which operations are applied along the way.
Wires represent the paths along which values travel from one part of the computation to another. Gates receive one or more input values, perform an operation on them, and pass the resulting values along their outgoing wires.
Interactive Boolean circuit editor
Click X or Y to toggle it. Drag nodes to move them, drag square wire handles to reroute, and drag circular output ports onto input ports to connect. Drag an occupied input port to reconnect its wire. Right-click anywhere on the board for context-specific actions.
The quantum circuit model
In the quantum circuit model, wires represent qubits and gates represent both unitary operations and measurements.
The terminology comes from physical electrical circuits, where wires carry current and components act on it. Here, wires and gates describe information flow, not electricity. The circuits considered here are acyclic: information flows in one direction, conventionally from left to right. A wire never loops back to an earlier gate, so the gates define an unambiguous order of computation.
A one-qubit circuit
From left to right, qubit passes through . Operators act on a ket from the left, so the rightmost matrix in a product acts first. The output is therefore : the combined operation is written , the reverse of the visual order. Hover over or focus a gate to see its full operation.
The three gate matrices are:
Multiply one step at a time, starting at the right:
A controlled-NOT circuit
The Hadamard gate first acts on the upper qubit . The filled dot then makes the CNOT control, while the circled plus marks as its target. If , the target is unchanged; if , the target is flipped.
For the matrix calculation, use the register order : . The Hadamard acts on , the second tensor factor, so its two-qubit matrix is :
With as the control, CNOT exchanges and while leaving the other two basis states unchanged:
CNOT acts after the Hadamard, so it appears on the left in the product:
Applying that matrix to gives the Bell state:
For all four computational-basis inputs, the circuit produces the four Bell states below. The final minus sign is a global phase and does not affect measurement probabilities.
Follow the state through the circuit
To find the output for one input, we do not need to multiply the full gate matrices. Instead, follow the state from left to right and update it at each gate; the slices below are labeled .
Classical states in a quantum circuit
A measurement connects quantum and classical information: it collapses a qubit to or and writes the corresponding bit onto a double classical wire. Here the measurements store Y in B and X in A. Because the qubits are in , the classical result is or , each with probability one half; those bits can then control later operations or be read as output.
Quantum-circuits symbols
Single-qubit gates
Controlled-NOT (CNOT)
SWAP
Toffoli (CCNOT)
Fredkin (controlled-SWAP)
Arbitrary unitary U
Controlled-U
Quantum states and measurements
Inner products
Suppose that we have two kets and with complex amplitudes:
To calculate the inner product of and , first turn into the bra — its conjugate transpose, whose entries are the complex conjugates — then multiply it by to get a single number:
For example, take the two qubit states:
Conjugating the amplitudes of flips the to :
Alternatively, suppose the same vectors are written as sums over a basis :
This gives the same formula as before, just in a different format. Expanding the product term by term, each is when and otherwise, so only the matching terms survive:
Our example states in this form, over the basis :
Substituting our values into the formula, we get (the and terms are , so they cancel):
Inner product as an angle
When the amplitudes are all real, the conjugation does nothing (), and the inner product has a clean geometric meaning: for two unit vectors it equals the cosine of the angle between them.
This geometric interpretation only works when all amplitudes are real. With complex amplitudes, the inner product becomes a complex number, so it no longer represents the cosine of an ordinary angle. The quantity that remains physically meaningful is its magnitude, , which determines measurement probabilities.
Inner product as an angle in multidimensional space
The idea of the inner product as an angle for real amplitudes generalizes to any number of dimensions: for real unit vectors the inner product is still the cosine of the angle between them — it just lives on a higher-dimensional sphere. Below is the three-dimensional case (a qutrit with real amplitudes, basis ):
Properties of the inner product
Relationship to the Euclidean norm
Take the inner product of a vector with itself. Each conjugate pair collapses to a squared magnitude, , so the result is the sum of squared amplitudes — exactly the squared Euclidean length of the vector:
When a state is normalized (that is, it represents a valid quantum state), its inner product with itself equals . Equivalently, its Euclidean norm equals . For example, for the vector :
More generally, the Euclidean norm of any vector is the square root of its inner product with itself:
Conjugate symmetry
Swapping the order of the two vectors conjugates a different set of amplitudes. For and , the two orderings are
which differ only in which factor carries the bar. In fact the two are complex conjugates of each other:
Why. Conjugate , pulling the bar inside the sum and onto each factor:
Because complex multiplication is commutative, , the final summand is exactly that of , which proves the identity.
Example. Take the two states
Computing both orderings yields a conjugate pair:
Linearity in the second argument
Suppose that , , and are vectors and and are complex numbers. If we define a new vector
then the inner product distributes over the combination, with each coefficient pulled out in front:
Conjugate linearity in the first argument
Suppose that , , and are vectors and and are complex numbers. If we define a new vector
then the inner product is again linear in each term — but forming the bra conjugates every coefficient as it comes out in front:
The Cauchy–Schwarz inequality
For every choice of vectors and , the magnitude of the inner product can never be larger than the product of the vectors' lengths:
In other words, the overlap between two vectors cannot exceed what their lengths allow.
Equality, , holds only when the two vectors are linearly dependent — that is, one is simply a scalar multiple of the other.
Orthogonality and orthonormality
Two vectors and are orthogonal if their inner product is zero:
An orthogonal set is one in which every pair is orthogonal:
An orthonormal set is an orthogonal set of unit vectors — each pair is orthogonal and each vector has length one:
An orthonormal basis is a set of orthonormal vectors that spans the entire vector space. This means every vector in the space can be written as a linear combination of the basis vectors.
Constructing basis sets
The key idea is that any orthonormal set can always be extended into an orthonormal basis. Suppose that is an orthonormal set of vectors in an -dimensional space. Because orthonormal sets are always linearly independent, these vectors span a subspace of dimension .
If , then there must exist additional vectors so that forms an orthonormal basis.
The Gram–Schmidt orthogonalization process can be used to construct these extra vectors. It repeatedly subtracts a vector's projections onto the existing basis vectors, leaving an orthogonal remainder that is then normalized to get the missing basis vectors.
Two dependent vectors — the span is only a line.
Independent vectors span the whole plane.
Orthonormal basis — vectors perpendicular and have unit length.
Orthonormal bases and unitary matrices
A unitary matrix is just a matrix whose columns are an orthonormal basis. More precisely, a square matrix is unitary if and only if its columns form an orthonormal basis — and equivalently, if and only if its rows do. These conditions are equivalent:
- ( is unitary).
- The columns of form an orthonormal basis.
- The rows of form an orthonormal basis.
To see why, write the columns of as vectors and take the conjugate transpose, which turns each column ket into the corresponding row bra. Multiplying then gives, in row and column , the inner product :
For example, suppose two columns of the unitary matrix are the vectors and below. Taking the conjugate transpose of the first turns it into its bra (row) form , and the inner product is exactly the dot product of the two columns, with complex conjugation applied to the first vector:
There are two important cases:
- If ,So the diagonal entries of are the squared lengths of the columns.
- If , then measures how closely the two vectors point in the same direction.
For real vectors, , where is the angle between the vectors. Thus, the inner product measures their overlap:
- large magnitude means they point in similar directions,
- zero means they are perpendicular (orthogonal).
Therefore is the matrix of all pairwise inner products between the columns of — each diagonal entry a squared length, each off-diagonal entry the overlap between two different columns:
If is unitary, then , and matching the entries of these two matrices gives
- every diagonal entry equals : , so every column has unit length;
- every off-diagonal entry equals : , so every pair of distinct columns is orthogonal.
So, for a unitary matrix, its columns form an orthonormal set, and since there are exactly columns in an -dimensional space, an orthonormal set of vectors is automatically an orthonormal basis.
Applying the same argument to shows that the rows are also an orthonormal basis.
Projections
A square matrix is called a projection if it satisfies two properties:
- (it is Hermitian);
- (it is idempotent).
Example: a single unit vector
For example, if is a unit vector, then its outer product with itself is a projection:
To confirm this, we check the two defining properties in turn.
- Hermitian — taking the conjugate transpose reverses the order of a product and daggers each factor, . Since and , the two factors swap back into their original places:
- Idempotent — applying twice leaves the inner product in the middle, and because is a unit vector that factor equals , so the product collapses back to a single copy:
Both properties hold, so is indeed a projection.
Visual demo: projecting onto the line
With a single unit vector , the projection operator takes any vector and projects it onto the line spanned by . The projection is , where is the scalar giving the component of along . Thus always lies on the line, while the remaining vector is perpendicular to it. Applying the projection a second time changes nothing, because is already on the line, so .
Generalization: an orthonormal set
This generalizes from a single vector to any orthonormal set. If is orthonormal, then the sum of their outer products is again a projection:
The same two checks go through, now using orthonormality (equal to when and otherwise).
- Hermitian — the dagger passes through the sum and daggers each term, and every term is Hermitian by the argument above:
- Idempotent — multiplying the two sums gives a double sum whose inner factor is . Orthonormality removes every cross term () and leaves on the diagonal (), collapsing the double sum back to a single one:
So any sum of outer products over an orthonormal set is a projection — geometrically, it projects onto the subspace those vectors span.
Projective measurements
A collection of projections that satisfies describes a projective measurement.
When such a measurement is performed on a system in the state , two things happen:
- The outcome of the measurement is chosen randomly:
The two forms and are mathematically identical. The first makes the geometry — the squared projection length — much more obvious, while the second connects naturally to the general framework of expectation values.
- The state of the system becomes
The outcomes need not be labelled . We are free to name them however is convenient — letters , or any index set , so that a family with describes a projective measurement with outcomes in . The rules are exactly the same.
Visual demo: measuring a qutrit in the standard basis
Take the three rank-one projections onto the basis axes . They add up to the identity, , so they form a projective measurement:
If outcome occurs, the state is projected onto the corresponding subspace, and the probability is the squared length of the projected vector — so the squared projection lengths (the probabilities) always sum to 1.
Measuring one subsystem
Suppose we have two systems, and , but we only measure in the standard basis. We don't need a new mathematical procedure for measuring composite systems — just use the projectors.
Each projector acts on the pair in two independent steps:
- checks whether — it keeps the part of the state carrying that outcome and discards the rest.
- does nothing to — the second system is left exactly as it was.
Since these projectors sum to the identity, they form a valid projective measurement:
The projective measurement rules apply as before:
and after observing outcome , the state of becomes
Example — subsystem measurement by projection
For example, suppose is a pair of qubits in the state below, written so that each term is grouped by :
Outcome
The projector for this outcome is
Apply it to the full state and expand. Each factor is handled separately, so the kets meet while the identity leaves the part unchanged:
The probability is the squared norm of what survived — the sum of its squared amplitude magnitudes:
The survivor is not a unit vector, so divide it by its norm :
Outcome
The other projector does the mirror image: now keeps the branch and discards the one:
Its squared norm is the remaining probability. The drops out under — only magnitudes matter:
Divide by the norm as before:
Implementing projective measurements
So far the projectors have been pure mathematics. Hardware offers only two things: unitary operations and standard basis measurements. That is already enough — any projective measurement can be assembled out of those two.
The trick is to bring in one extra system alongside the one being measured, with a classical state for each possible outcome. A single unitary then files each outcome into its own branch: the extra system carries the outcome's label, and travelling alongside it is the matching projected state of the measured system. Reading the extra system in the standard basis picks one branch — with exactly the probability the projection rule demands — and leaves the measured system in that branch's projected, renormalised state. No projector is ever built as hardware; the projections emerge from the branch structure.
Below, that idea runs on a pair of systems and . The bottom wire is the extra qubit — the only thing ever read.
The first Hadamard splits the extra qubit into two branches. The controlled-SWAP exchanges and on one branch only, so the two branches now hold the state seen from two different angles. The second Hadamard makes them interfere, which sorts the state into a part unchanged by the exchange and a part that the exchange reverses — and those two parts are precisely the projections. Measuring the extra qubit says which one you landed in, and turns it into a classical bit.
Three gates and a single qubit read out: an abstract pair of projections has become something a machine actually does.
Limitations of quantum measurements
Irrelevance of global phases
Quantum amplitudes are complex numbers, so each one carries both a magnitude and a phase. Phases show up in two different ways:
- A global phase multiplies every amplitude in a state by the same unit-modulus factor .
- A relative phase changes the phase difference between the amplitudes within a superposition.
The distinction is fundamental. A global phase rotates the entire state vector by the same amount, leaving the relationships between its amplitudes unchanged. A relative phase changes those relationships and therefore affects interference.
A scalar factor in a global phase must preserve the norm, so . That condition is met exactly by the complex numbers of the form for some real : every such number sits on the unit circle of the complex plane, and every unit-modulus number can be written this way. Two state vectors therefore differ by a global phase when — every amplitude is multiplied by the same unit-modulus factor .
For example, the two amplitudes of are drawn as arrows on the complex plane. Their lengths are the magnitudes, their angles the phases.
Drag global phase — every bar holds still, so the state is physically unchanged. Drag relative phase — the standard basis still won't move, but the ± measurement swings: the relative phase is observable. The amplitude split resizes the arrows and shifts the standard-basis odds.
Probability of each outcome if we measure in that basis:
Standard basis
Hadamard basis
Mathematically, two state vectors differ by a global phase if .
Standard-basis measurement. The probability of outcome is the squared magnitude of the amplitude . Substituting , the phase factors out and its magnitude disappears:
Projective measurement. The same cancellation holds for any projective measurement . Each outcome probability is the squared norm , and pulling the scalar out of the norm leaves the factor again:
Therefore all measurements produce exactly the same statistics for and . States that differ by a global phase are considered equivalent — they represent the same physical state. A relative phase, by contrast, changes the interference between amplitudes and is observable, as the demo above shows.
A note on representation. This global phase is a degeneracy of the state-vector picture: the same physical state maps to a whole circle of vectors that are all indistinguishable. It is an artifact of describing states at this simplified level of generality (it's called “simplified,” though personally I cried at the word “simple”).
The more general formalism uses density matrices: a state vector is replaced by the operator . Here the global phase cancels automatically, since , so equivalent states share exactly one density matrix and the redundancy disappears. Density matrices also describe mixed states (classical uncertainty over several vectors), which no single state vector can capture.
No-cloning theorem
Copying classical information is trivial — you read a bit and write it down twice. It is natural to ask whether a quantum computer can do the same for an unknown state , producing two identical copies of it. The no-cloning theorem says this is impossible: no single unitary can duplicate an arbitrary unknown quantum state, which is exactly why quantum information cannot simply be copied and why quantum key distribution is secure.
Formally, let and both have the classical state set with . A cloner would be a unitary on the pair that takes the state in with a blank in and writes a copy into . The theorem states no such exists:
Drawn as a circuit, this cloner would feed and a blank register into and read out two copies — the box below that cannot exist for every input:
Why no such U can exist
Suppose there existed a unitary operator that could perfectly clone any quantum state. For every state , it would satisfy , where is a blank qubit that receives the copy.
Applying to basis states results in:
But now consider a plus (superposition) state . Because every quantum gate is linear, the cloning operation must satisfy:
But if were truly a cloning machine, the output should instead be
This expands to
These two states are different:
The contradiction arises because linearity forces one output, while perfect cloning requires another. Therefore, no unitary operation can perfectly clone an arbitrary unknown quantum state.
Remarks
- Approximate forms of the cloning theorem are known.
- Copying a standard basis state is possible — the no-cloning theorem does not contradict this.
For example, a controlled by a basis value copies it into a blank , giving :
- Cloning a probabilistic state (classically) is also impossible.
- Perfect clones are possible if they are all encrypted. A 2026 protocol, encrypted cloning, deterministically produces any number of perfect copies of an unknown state — as long as the copies are simultaneously locked with a single-use quantum decryption key. Decrypting one clone consumes the key and renders every other clone indecipherable, so no two usable copies ever coexist and the theorem still holds. The real constraint is not the copying, but that the decryption mechanism must be single-use. The payoff is redundancy, like keeping backups: you hold many encrypted copies and recover the original from any one that survives. It has been demonstrated on IBM Heron-R2 hardware with up to 154 qubits (Yamaguchi et al., 2026).
Discriminating non-orthogonal states
It is not possible to perfectly discriminate two non-orthogonal quantum states. Equivalently, if we can discriminate two quantum states perfectly, then they must be orthogonal.
Two states and can be discriminated perfectly if there is a unitary operation that works like this:
Suppose a unitary operator perfectly distinguishes two states and . By definition,
where the final qubit stores the measurement result and the remaining qubits and represent arbitrary ancilla states.
The overlap of two states is their inner product — a number that measures how similar they are. It is for identical states and for orthogonal (perfectly distinguishable) ones.
Now take two states and and apply to each. To form the overlap of the outputs, the first ket becomes a bra by taking its conjugate transpose, which flips into :
where the middle collapses to the identity because is unitary. So passing both states through the same leaves their overlap unchanged — the input overlap equals the output overlap.
For the discriminating unitary, the two input vectors are and . Their overlap factorizes across the ancilla and state registers, and because the ancilla register is the same in both inputs :
The output overlap factorizes the same way. The measurement outcomes are different, so , and the whole overlap collapses to zero:
Equating the input and output overlaps, and recalling the output overlap is zero, gives
In other words, perfect discrimination is possible only for orthogonal quantum states.
The demo illustrates this result visually. Drag either state to change their overlap . As the overlap decreases, the states become easier to distinguish. When , they are orthogonal and can be distinguished perfectly.
Entanglement
Two qubits are entangled when their joint state cannot be written as . Measure both systems several times and compare the results: the separable state behaves like two independent coin flips, while the entangled Bell state always produces matching outcomes.
These correlations are stronger than anything independent classical systems can share, so entanglement is treated as a resource. One maximally entangled pair is one unit of it — an e-bit.
Quantum teleportation
Quantum teleportation is a protocol that allows a sender to send quantum information to a receiver using only entanglement and classical communication to accomplish that transmission.
Setup
- Alice holds a qubit in an unknown state that she wants to transfer to Bob.
- Alice and Bob share an entangled pair (an e-bit) in the state . Alice holds qubit , and Bob holds qubit . How or when they established this shared entanglement—for example, during an earlier meeting—is irrelevant to the protocol.
- Alice can communicate with Bob only by sending classical bits.
- An unknown quantum state cannot be completely described by classical bits, so classical communication alone is insufficient.
- Because of the no-cloning theorem, once the protocol is complete and Bob's qubit is in state , Alice no longer has a copy of that quantum state.
Protocol
- 1Alice performs a controlled-NOT operation, where is the control and is the target.
- 2Alice performs a Hadamard operation on .
- 3Alice measures and , obtaining binary outcomes and , respectively.
- 4Alice sends and to Bob.
- 5Bob performs these two steps on qubit :
- If , Bob applies an operation.
- If , Bob applies a operation.
Superdense coding
Superdense coding is a protocol that allows a sender to transmit two classical bits to a receiver by sending only a single qubit, using one shared e-bit of entanglement to accomplish that transmission.
Scenario
- Alice has two classical bits that she wishes to transmit to Bob.
- Alice is able to send only a to Bob.
- Alice and Bob already share an entangled pair (an e-bit) in the state .
- Without the e-bit the task would be impossible: by Holevo's theorem, two classical bits cannot be reliably transmitted by a single qubit alone.
Protocol
- 1Alice applies to her qubit — an when and a when .
- 2Alice sends her qubit to Bob.
- 3Bob applies a controlled-NOT, with the qubit received from Alice as the control and his own qubit as the target.
- 4Bob applies a Hadamard to the qubit received from Alice.
- 5Bob measures both qubits, reading off and .
CHSH game
A nonlocal game is a mathematical and physical framework modeling two or more cooperating players who try to win a game against a referee. The defining rule is that once the game begins, players cannot communicate.
Set-up
- The players Alice and Bob cooperate as a team against a referee.
- The referee runs the game: it sends each player a question and checks their answers against a fixed rule.
- Alice and Bob may prepare a strategy together beforehand — including sharing entanglement.
- But once the game starts they are forbidden from communicating: neither learns the other's question or answer.
One round
The referee asks. The referee picks two questions using randomness and sends one to each player — to Alice and to Bob. Each player sees only their own question.
The CHSH referee
The CHSH game is one example of a nonlocal game, in which the referee follows these rules. Questions and answers are all bits , the questions and are chosen uniformly at random, and the team wins exactly when .
| Winning condition | ||
|---|---|---|
| (0,0) | 0 | |
| (0,1) | 0 | |
| (1,0) | 0 | |
| (1,1) | 1 |
CHSH — Deterministic strategy
Program Alice and Bob before the game begins. For each possible question, choose the answer they will always give. Once the game starts, they cannot communicate or change their strategy. Can you find a strategy that wins all four rounds?
Strategy
Alice
Bob
CHSH game results
3 / 4 Wins
75%
🏆 This is the best possible deterministic strategy.
CHSH — Probabilistic strategy
Now let Alice and Bob answer at random. For each question, set how often they reply with a 1. The game is unchanged — only the strategy is now a coin flip. Can randomness push them past 75%?
Strategy
Alice
Bob
CHSH game results
Only a few thousand rounds, so the result is noisy — a lucky sample can drift above or below the true rate. Re-run it a few times to see it bounce around the expected value.
0.0%
win rate over 2,000 rounds
expected 50.0% · best possible 75%
CHSH — Quantum strategy
Now Alice and Bob share an entangled pair prepared before the game. Each question picks a measurement angle instead of a fixed answer. Same game, same rule — but can entanglement beat the classical 75% ceiling?
Measurements are angles
Measuring a qubit is not simply reading a fixed bit — the player first chooses a direction to measure along. That choice is an angle : outcome 0 corresponds to the direction , and outcome 1 to the perpendicular direction . The measurement asks: which of these two is the qubit closer to?
Measurement basis
| θ | deg | cos θ | sin θ |
|---|---|---|---|
| 0° | |||
| 22.5° | |||
| 45° | |||
| 67.5° | |||
| 90° |
So how does the angle determine the probability?
The qubit is also represented by a direction on the same circle. Suppose it points at angle , so its state is .
A measurement compares the qubit's direction with the measurement direction . The closer they are, the more likely the measurement returns outcome 0. If they point in exactly the same direction, the result is always 0. If they are perpendicular, outcome 0 is impossible.
Quantum mechanics quantifies this “closeness” using the inner product (also called the overlap). For a qubit pointing at angle and a measurement at angle , the overlap between the qubit state and the measurement direction is
The probability of obtaining a measurement outcome is the square of the overlap with the corresponding measurement direction. Since outcome 0 corresponds to ,
Likewise, outcome 1 corresponds to the perpendicular direction , so
The simplest choice is , where the measurement direction lines up with the horizontal axis. In this case,
So the two measurement outcomes are simply the familiar states and . This is called the standard (or computational, ) basis. Measuring in this basis is the familiar question: “Is the qubit 0 or 1?”
Of course, nothing requires us to measure in this basis. We can rotate the measurement direction to any angle, creating a different pair of measurement states. A few of these angles are used so often that they have their own names. Each basis is simply a different measurement angle — choose one below, or drag the arrows to rotate the measurement basis and watch the outcome probabilities change while the qubit itself stays fixed.
From one qubit to an entangled pair
So far we've measured a single qubit. Now imagine Alice and Bob each receive one qubit from a shared entangled pair prepared before the game.
Just as before, each player independently chooses a measurement angle — Alice uses , Bob uses . Each individual measurement still looks completely random: Alice sees 0 or 1 with equal probability, and so does Bob.
The surprise is that their outcomes are correlated. The probability that they obtain the same result depends only on the angle between their measurements:
Just like for a single qubit, only the difference between the two angles matters — not their absolute positions.
- If , Alice and Bob always obtain the same result.
- If the measurement directions are apart, they always obtain opposite results.
- Between these extremes, the probability changes smoothly as the angle changes.
The CHSH game circuit
Alice and Bob begin with the shared Bell state . Their CHSH questions don't determine the answers — they determine which measurement basis each player uses. In the circuit below, question selects Alice's rotation and question selects Bob's. After applying these rotations, both qubits are measured in the standard basis.
Strategy
Alice
angle Alice measures at for each question x
Bob
angle Bob measures at for each question y
CHSH game results
0.0%
win rate over 2,000 rounds
expected 85.4% · maximum 85.36% (Tsirelson bound)
⚛️ Optimal — this reaches the Tsirelson bound, the quantum maximum.
Query-model algorithms
Two models of computation
Quantum algorithms are often analyzed in the query model, which differs from the ordinary computational model only in how the input is accessed.
Standard model
The algorithm receives the entire input.
Query model
The algorithm can only interrogate a black box.
In the standard model, the complete input is available from the start. The algorithm may read any part of it whenever it likes, perform arbitrary computations, and eventually produce an output. Cost: the total number of elementary computational steps.
In the query model, the function is hidden inside a black box called an oracle. The algorithm never sees the function directly. Instead, it repeatedly asks questions of the form “what is ?”, receives the answer, performs arbitrary computation, and decides which query to ask next. Cost: the number of oracle queries.
The query model isolates the cost of obtaining information from the cost of computation itself. This makes it possible to compare classical and quantum algorithms in a clean and mathematically precise way.
Examples of query problems
In the query model, the input is not a string—it is an unknown function . The algorithm cannot inspect the function directly. It can only ask questions like “” for inputs of its choice.
Hidden function
Flip the values below to change the hidden function .
Each problem asks a different question about the same hidden function. The answer updates automatically as you change the function.
Query gates
In a circuit model, access to the hidden function is represented by a query gate (or oracle gate). It behaves like an ordinary component, but its behavior is fixed by the unknown : given on its input wires it outputs . The function is supplied by the problem instance, not the algorithm, and each use counts as one query.
Query gates can be combined with ordinary logic gates just like any other circuit component. The circuit below solves the Parity query problem for a function with two possible inputs, and . It queries and , then outputs exactly when one of the two values is and the other is (odd parity).
Why study hidden functions?
Admittedly this model looks a bit weird at first — why lock the input inside a box and count questions instead of simply reading it? But many computational tasks — from searching a database to testing a physical device — can only access information by asking questions. The query model captures exactly this situation by treating the input as an unknown function that can only be queried.
Quantum query gates
Classical query gates output the value directly. That is convenient for classical circuits, but it cannot be used in quantum circuits.
The reason is that quantum gates must be unitary (and therefore reversible). A gate that simply replaces its input with is generally not reversible, since many different inputs may produce the same output.
So for the quantum circuit model we choose a different definition that is always unitary. The query gate for any function is defined, for all and , by its action on basis states:
In circuit form, leaves the top register holding and writes into the bottom register by XOR. Notice that the function value is added into the second register rather than replacing it — this small change makes the operation reversible for every possible function :
Starting the bottom register at makes the gate output directly, since .
The extra register may seem unnecessary at first, but it is what makes the oracle useful:
- it keeps unitary and reversible for every ;
- it lets the oracle act on a superposition of many inputs at once;
- and it preserves the phases that quantum algorithms exploit through interference.
Deutsch’s problem
Deutsch’s problem asks whether a function is constant or balanced. The function takes one bit as input and returns one bit as output, so there are only four possible functions.
Build a function
Flip the two outputs to define a function . There are exactly four possible functions. Try to discover them all.
Found 0 of 4 possible functions of the form :
| ? | |
| ? |
| ? | |
| ? |
| ? | |
| ? |
| ? | |
| ? |
The classical approach
A classical algorithm must evaluate both possible inputs: after seeing only one value, you still cannot distinguish a constant function from a balanced one.
Deterministic classical cost: 2 queries
Deutsch’s algorithm
Deutsch’s algorithm solves the same problem using only one query. It prepares two qubits, performs a single query to the oracle , applies one more Hadamard gate, and measures the first qubit — the measurement directly reveals , which is:
- for constant functions
- for balanced functions
Step through the circuit
- 1Prepare the two qubits in .
- 2Apply a Hadamard to each qubit.
- 3Apply the query gate — the single query.
- 4Apply a Hadamard to the top qubit.
- 5Measure the top qubit to read .
The Deutsch–Jozsa circuit
Deutsch’s algorithm works only for the simplest case: a function , which maps a single input bit to a single output bit. The Deutsch–Jozsa algorithm generalizes this idea to functions of the form for any , allowing the input to consist of any number of bits.
The purpose of the circuit is not to compute , but to extract information about the function as a whole. After one query, measuring the query qubits produces a bit string . The meaning of this string depends on the query problem: once we specify what property of we want to determine, we can interpret according to an appropriate decision rule.
The Deutsch–Jozsa problem
The Deutsch–Jozsa problem generalizes Deutsch’s problem: for an input function , the task is to output if is constant and if is balanced.
For these are the only two possibilities, so this is exactly Deutsch’s problem. When , however, some functions are neither constant nor balanced.
Build a function
Flip the four outputs to define any function and see which family it falls into.
of the four inputs map to — neither all of them nor half of them — so this function is neither constant nor balanced.
Input functions that are neither constant nor balanced are “don’t care” inputs. The promise excludes them, so on such a function an algorithm may output anything without being considered wrong.
The Hadamard transform
The Hadamard gate acts on the computational basis states like this:
The only difference between these two equations is the sign of the term. The factor captures this perfectly: it equals when and when . So we can combine both cases into a single expression:
Notice that the only difference between the two terms is their phase. The term always has a positive sign, while the sign of the term depends on the input bit . We can capture both cases with the exponent , where labels the basis state in the sum:
- for , we have , so , giving the positive sign of ;
- for , we have , so , giving the correct sign of .
Therefore, both terms can be written as a single summation:
From one Hadamard to many
The one-qubit Hadamard identity extends naturally to a register of qubits. Take an -bit input string whose bits all lie in , and write the basis state it labels:
Applying a Hadamard gate to every qubit means applying independently to each bit:
Every qubit now becomes a superposition of and . In the one-qubit formula the summation index was called , but here we need one such index per qubit, so we rename it to for the -th qubit. So the one-qubit identity, with renamed to and renamed to , reads:
Now substitute the one-qubit identity for each factor in the tensor product, using a separate index for each qubit:
By the multilinearity of the tensor product, the tensor product distributes over the sums, producing one term for every -bit string . The phase factors multiply together, so their exponents add. Thus maps to an equal superposition of all basis states , differing only in their phases.
Walking through the circuit
Let’s follow the state as it passes through each stage of the Deutsch–Jozsa circuit.
Step through the circuit
- 1Prepare the query qubits in and the target qubit in .
- 2Apply a Hadamard to every qubit.
- 3Apply the query gate — the single query.
- 4Apply a Hadamard to each of the query qubits.
- 5Measure the query register to get .
The Bernstein–Vazirani problem
Imagine that someone secretly chooses an -bit string .
You cannot see directly. Instead, you may query a function . For any input , the function looks only at the positions where the secret string has a . It counts how many of those positions also contain a in , and returns:
- if the count is odd,
- if the count is even.
What does mean?
The binary dot product works in two steps.
- Compare the corresponding bits of and .
- Count only the positions where both bits are . If this count is odd, the answer is ; if it is even, the answer is .
For example, compare the two strings bit by bit. Only the columns where both bits are contribute to the dot product. Click any bit to change it.
Mathematically, this is written as follows, where multiplication is ordinary binary multiplication (, otherwise ), and denotes XOR:
The quantum algorithm
Unlike Deutsch’s and Deutsch–Jozsa’s problems, where the goal is to learn one property of the function, the Bernstein–Vazirani problem asks for the entire hidden string .
Surprisingly, the quantum algorithm requires no new circuit. It uses exactly the same circuit as Deutsch–Jozsa:
- query qubits initialized to ,
- one target qubit initialized to ,
- Hadamard gates before and after a single query to the oracle .
The only difference is the promise on the function. Because , the measurement no longer reveals whether the function is constant or balanced — it reveals the hidden string itself.