Level 0 · Math Foundations
Linear Algebra for Quantum Computing
About 4,611 words · roughly 21 minute read · sources checked December 2, 2026
Almost every statement in quantum computing is a statement about vectors and matrices. A qubit is a vector. A gate is a matrix. A measurement is a question about how much of one vector lies along another. If you are comfortable with a small amount of linear algebra, quantum circuits stop looking like magic and start looking like arithmetic you can do on paper.
This lesson builds that toolkit from nothing. It assumes you know school algebra and what a vector is as an arrow or a list of numbers. It does not assume any physics. Every idea comes with a worked example, and the key ideas are drawn. By the end you will be able to read expressions such as ⟨+|ψ⟩, H|0⟩ and U†U = I, and compute with them.
One honest note about scope: this is the finite-dimensional linear algebra that quantum computing uses. Real quantum mechanics also works with infinite-dimensional spaces, which we do not need here.
What you will learn
- How to add, multiply and rotate complex numbers, and why phases are the heart of interference.
- What a ket, a bra and an inner product are, and how to read Dirac notation.
- How the measurement rule turns amplitudes into probabilities.
- Why quantum gates are unitary matrices, and how to check that a matrix is unitary.
- What eigenvectors and Hermitian matrices have to do with measurements.
- The most common slips beginners make, and a quick self-test.
Why quantum computing is written in linear algebra
A classical bit is either 0 or 1. To describe a quantum bit, you need more than a choice between two options. You need a list of two numbers, one attached to each option, and those numbers are allowed to be complex. That list is a vector. Everything that can happen to the qubit, such as a gate, a rotation or a measurement, is then described by operations on that vector.
The reason this works is that quantum theory is linear. If you know what a gate does to the state 0 and to the state 1, you automatically know what it does to every mixture of them. Linearity is what lets a short list of matrices describe a whole machine, and it is also what makes interference possible, because amplitudes add before they are turned into probabilities.
| Quantum idea | Linear algebra object | Example |
|---|---|---|
| State of one qubit | Unit vector with 2 complex entries | (1/√2, 1/√2) |
| Gate | Unitary matrix | Hadamard H |
| Measurement outcome probability | Squared magnitude of an inner product | |⟨0|ψ⟩|² |
| Measured quantity (observable) | Hermitian matrix | Pauli Z |
| Several qubits together | Tensor product (next lessons) | |0⟩ ⊗ |1⟩ |
A dictionary between quantum language and linear algebra. Each row is explained below.
How to use this lesson
Work every example with a pencil. Quantum computing is a skill of calculation as much as of understanding, and the calculations here are short.
Complex numbers: amplitudes need them
A complex number has the form z = a + bi, where a and b are ordinary real numbers and i is defined by i² = −1. We call a the real part and b the imaginary part. You can picture z as a point, or an arrow from the origin, in a plane whose horizontal axis is the real part and vertical axis is the imaginary part.
Arithmetic you will use constantly
- Addition is componentwise: (a + bi) + (c + di) = (a + c) + (b + d)i.
- Multiplication uses i² = −1: (a + bi)(c + di) = (ac − bd) + (ad + bc)i.
- The complex conjugate flips the sign of the imaginary part: z* = a − bi.
- The modulus (length) is |z| = √(a² + b²), and the useful identity is z·z* = |z|².
- Division uses the conjugate: 1/z = z*/|z|².
Worked example
Multiply and take the modulus
- Let z = 1 + 2i and w = 3 − i.
- Product: (1)(3) − (2)(−1) = 3 + 2 = 5 for the real part; (1)(−1) + (2)(3) = −1 + 6 = 5 for the imaginary part. So zw = 5 + 5i.
- Check with moduli: |z|² = 1 + 4 = 5 and |w|² = 9 + 1 = 10, so |zw|² should be 50. Indeed |5 + 5i|² = 25 + 25 = 50. Moduli multiply: |zw| = |z||w|.
Polar form and Euler's formula
Any complex number can be written by its length r and its angle φ: z = r(cos φ + i sin φ). Euler's formula packages this as e^(iφ) = cos φ + i sin φ, so z = r·e^(iφ). The angle φ is called the phase. This form makes multiplication geometric: multiplying two numbers multiplies their lengths and adds their angles.
Numbers of length exactly 1, written e^(iφ), are called phase factors. Multiplying by one rotates a number by φ without changing its length. Two special cases appear everywhere in quantum computing: e^(iπ) = −1, and e^(iπ/2) = i. The Z gate multiplies the |1⟩ amplitude by −1, which is a half turn. The S gate multiplies it by i, which is a quarter turn.
Why phases matter
A probability is the squared length of an amplitude, so a phase factor alone does not change any single probability. But when two amplitudes are added, their phases decide whether they reinforce or cancel. That is interference, and it is the engine of quantum algorithms.
Worked example
Phases make or break addition
- Add two amplitudes of length 1/√2 each. If both have phase 0, the sum is 2/√2 = √2 and the squared length is 2.
- If the second has phase π, it equals −1/√2 and the sum is 0, so the squared length is 0.
- Same lengths, completely different outcomes. Only the relative phase changed.
Vectors, kets and bras
A vector in two complex dimensions is a column of two complex numbers. In quantum computing the two standard basis vectors are written with a special bracket called a ket:
|0⟩ = (1, 0)ᵀ |1⟩ = (0, 1)ᵀ
Any qubit state is a combination of these two: |ψ⟩ = α|0⟩ + β|1⟩, written as the column (α, β)ᵀ. The numbers α and β are the amplitudes. The ket notation |ψ⟩ is just a label that says this is a vector in our state space; it is not different mathematics from a column vector.
Normalisation
A valid state has total squared length 1: |α|² + |β|² = 1. This is called normalisation. It is the requirement that the probabilities of all outcomes add to 100%. If you build a vector that is not normalised, divide it by its length to repair it.
Worked example
Normalise a vector
- Start with (1, 1)ᵀ. Its squared length is 1 + 1 = 2.
- Divide each entry by √2 to get (1/√2, 1/√2)ᵀ, which is the state |+⟩ = (|0⟩ + |1⟩)/√2. Now the squared length is ½ + ½ = 1.
Bras and the dagger
For every ket there is a bra, written ⟨ψ|. The bra is the conjugate transpose of the ket: turn the column into a row and replace each entry by its complex conjugate. This operation is called taking the dagger and is written †. So if |ψ⟩ = (α, β)ᵀ then ⟨ψ| = (α*, β*).
|ψ⟩ = (α, β)ᵀ ⟨ψ| = (|ψ⟩)† = (α*, β*)
The conjugate is not decoration. It is what makes the squared length come out real and non-negative: ⟨ψ|ψ⟩ = α*α + β*β = |α|² + |β|².
The inner product
The bra-ket ⟨φ|ψ⟩ is the inner product of two states: multiply the row ⟨φ| by the column |ψ⟩. The result is a single complex number that measures how much of |ψ⟩ points along |φ⟩. It generalises the dot product to complex vectors.
- ⟨0|ψ⟩ = α and ⟨1|ψ⟩ = β. The bras of the basis states pick out the amplitudes.
- ⟨ψ|ψ⟩ = 1 for a normalised state.
- ⟨φ|ψ⟩ = (⟨ψ|φ⟩)*. Swapping the order conjugates the answer.
- If ⟨φ|ψ⟩ = 0 the states are orthogonal, which means perfectly distinguishable by a single measurement.
Worked example
An inner product with complex numbers
- Let |ψ⟩ = (1/√2)(|0⟩ + i|1⟩) and |+⟩ = (1/√2)(|0⟩ + |1⟩).
- ⟨+| = (1/√2)(1, 1). Multiply by the column (1/√2)(1, i)ᵀ: (1/2)(1·1 + 1·i) = (1 + i)/2.
- Its squared length is (1² + 1²)/4 = ½. So measuring |ψ⟩ against |+⟩ would succeed with probability 50%.
A set of vectors is orthonormal if every vector has length 1 and every pair is orthogonal. {|0⟩, |1⟩} is orthonormal. So is {|+⟩, |−⟩}, where |−⟩ = (|0⟩ − |1⟩)/√2. Any orthonormal basis of the space can be used to describe a state, and changing basis is just a different way of looking at the same vector.
The measurement rule
Here is the single most important rule connecting the mathematics to the lab. If a qubit is in state |ψ⟩ and you measure it in a basis {|a⟩, |b⟩}, the probability of getting outcome a is the squared length of the inner product:
P(a) = |⟨a|ψ⟩|²
Worked example
Measure (3|0⟩ + 4i|1⟩)/5
- First check normalisation: |3/5|² + |4i/5|² = 9/25 + 16/25 = 1. Good.
- P(0) = |⟨0|ψ⟩|² = |3/5|² = 36%. P(1) = |⟨1|ψ⟩|² = |4i/5|² = 64%.
- Notice the factor i did not affect either probability. It would matter only if we measured in a different basis or combined this state with another.
Worked example
The same state, measured in a different basis
- Measure the state |+⟩ in the {|0⟩, |1⟩} basis: ⟨0|+⟩ = 1/√2, so P(0) = ½ and P(1) = ½.
- Now measure |+⟩ in the {|+⟩, |−⟩} basis: ⟨+|+⟩ = 1 so P(+) = 1 and P(−) = 0.
- A state can be uncertain in one basis and perfectly certain in another. This is the origin of much of what seems strange about quantum mechanics.
After a measurement the state is no longer the original superposition. It becomes the basis state that was observed. This update is sometimes called collapse. The probabilities in the rule describe what happens over many identical preparations; a single run produces one outcome.
Global phase versus relative phase
The states |ψ⟩ and e^(iγ)|ψ⟩ give identical probabilities in every basis, so a global phase has no physical effect and is ignored. But |+⟩ = (|0⟩ + |1⟩)/√2 and |−⟩ = (|0⟩ − |1⟩)/√2 differ by a relative phase and are completely distinguishable. The difference between a global and a relative phase is one of the most important distinctions in the subject.
Matrices as operations
A matrix turns one vector into another. For a 2×2 matrix acting on a column, the rule is row-times-column:
[ a b ] [ x ] [ a·x + b·y ] [ c d ] [ y ] = [ c·x + d·y ]
Linearity means M(αu + βv) = αMu + βMv. So to know a matrix you only need to know what it does to the basis vectors. The columns of M are exactly the images M|0⟩ and M|1⟩. This one fact lets you build a matrix from a description of what a gate should do.
The standard single-qubit gates
| Gate | Matrix | What it does |
|---|---|---|
| X (NOT) | [[0, 1], [1, 0]] | Swaps |0⟩ and |1⟩ |
| Z | [[1, 0], [0, −1]] | Flips the sign of |1⟩; leaves |0⟩ |
| Y | [[0, −i], [i, 0]] | |0⟩ → i|1⟩, |1⟩ → −i|0⟩ |
| H (Hadamard) | (1/√2)[[1, 1], [1, −1]] | |0⟩ → |+⟩, |1⟩ → |−⟩ |
| S | [[1, 0], [0, i]] | Quarter-turn phase on |1⟩ |
| T | [[1, 0], [0, e^(iπ/4)]] | Eighth-turn phase on |1⟩ |
The common one-qubit gates. X, Y and Z are the Pauli matrices.
Worked example
Apply H to |0⟩, then H again
- H|0⟩ = (1/√2)[[1, 1], [1, −1]](1, 0)ᵀ = (1/√2)(1, 1)ᵀ = |+⟩.
- H|+⟩ = (1/√2)[[1, 1], [1, −1]] · (1/√2)(1, 1)ᵀ = (1/2)(1 + 1, 1 − 1)ᵀ = (1, 0)ᵀ = |0⟩.
- So H applied twice returns the original state: H² = I. Gates that undo themselves are common.
Matrices compose by multiplication, and order matters. Doing gate A first and then gate B is the product BA, with the first gate on the right, because the matrix nearest the state acts first. In general AB ≠ BA. For example XZ = −ZX, which means these two gates anticommute.
Worked example
Order matters: XZ versus ZX
- XZ = [[0, 1], [1, 0]]·[[1, 0], [0, −1]] = [[0, −1], [1, 0]].
- ZX = [[1, 0], [0, −1]]·[[0, 1], [1, 0]] = [[0, 1], [−1, 0]].
- The two results differ by an overall sign, XZ = −ZX. Because that sign is a global phase, the two orders are physically the same up to phase, which is why X and Z are said to anticommute.
Unitary matrices: the only allowed gates
Not every matrix is a legal quantum gate. A gate must keep the total probability at 100%, which means it must keep the length of every state vector equal to 1. A matrix with that property is called unitary, and the test is compact:
U†U = U U† = I where U† is the conjugate transpose of U
Worked example
Verify that the Hadamard is unitary
- H = (1/√2)[[1, 1], [1, −1]]. It is real and symmetric, so H† = H.
- H·H = (1/2)[[1 + 1, 1 − 1], [1 − 1, 1 + 1]] = (1/2)[[2, 0], [0, 2]] = I. So H†H = I and H is unitary.
Worked example
Show a matrix that is not unitary
- Take M = [[1, 1], [0, 1]]. Apply it to |1⟩ = (0, 1)ᵀ to get (1, 1)ᵀ.
- The new vector has squared length 2, so M does not preserve length and cannot be a gate.
What unitarity buys you
- Probabilities stay normalised after every gate.
- Every gate is reversible. This is why quantum circuits contain no information-destroying operation except measurement.
- The columns of a unitary matrix are orthonormal, which gives a quick check by inspection.
- Unitary matrices preserve inner products: ⟨Uφ|Uψ⟩ = ⟨φ|ψ⟩. Distinguishability is kept under evolution.
A single-qubit unitary can always be understood as a rotation of the Bloch sphere, which the next lesson develops. A real unitary matrix is also called an orthogonal matrix, and in two dimensions it is a rotation or a reflection of the plane, which matches the pictures above.
Eigenvectors, eigenvalues and Hermitian matrices
An eigenvector of a matrix A is a non-zero vector that the matrix only rescales: A|v⟩ = λ|v⟩. The scale factor λ is the eigenvalue. Eigenvectors are the directions a matrix leaves alone.
Worked example
Eigenvectors of the Pauli Z matrix
- Z|0⟩ = |0⟩, so |0⟩ is an eigenvector with eigenvalue +1.
- Z|1⟩ = −|1⟩, so |1⟩ is an eigenvector with eigenvalue −1.
- For Pauli X: X|+⟩ = |+⟩ (eigenvalue +1) and X|−⟩ = −|−⟩ (eigenvalue −1).
| Matrix | Eigenvalue +1 state | Eigenvalue −1 state |
|---|---|---|
| Z | |0⟩ | |1⟩ |
| X | |+⟩ = (|0⟩ + |1⟩)/√2 | |−⟩ = (|0⟩ − |1⟩)/√2 |
| Y | |+i⟩ = (|0⟩ + i|1⟩)/√2 | |−i⟩ = (|0⟩ − i|1⟩)/√2 |
Each Pauli matrix has two eigenvectors, and they form an orthonormal basis.
A matrix is Hermitian if it equals its own dagger: A† = A. Hermitian matrices have real eigenvalues and orthogonal eigenvectors. In quantum mechanics, a measurable quantity (an observable) is represented by a Hermitian matrix. Measuring it gives one of its eigenvalues, and the state afterwards is the matching eigenvector. The Pauli matrices are both Hermitian and unitary, which is a rare and convenient combination.
Unitary versus Hermitian
Unitary matrices describe how a state changes. Hermitian matrices describe what we can measure. Their eigenvalues also differ: a unitary matrix has eigenvalues of length 1 (phase factors), while a Hermitian matrix has real eigenvalues.
Because the eigenvectors of a Hermitian matrix form an orthonormal basis, you can compute the probability of each measurement result by expanding the state in that basis. Choosing to measure in the X basis is the same as measuring the observable X.
Outer products, projectors and the completeness relation
So far an inner product ⟨φ|ψ⟩ (row times column) gave a number. Turn it around and you get an outer product |φ⟩⟨ψ| (column times row), which is a matrix. For example |0⟩⟨0| = [[1, 0], [0, 0]]. This particular matrix keeps the |0⟩ part of a state and deletes the rest, so it is called a projector.
|0⟩⟨0| = [[1, 0], [0, 0]] |1⟩⟨1| = [[0, 0], [0, 1]] |0⟩⟨0| + |1⟩⟨1| = I
Completeness is a very handy trick. Insert I between any two objects without changing them, then expand it. For instance, any state can be written as |ψ⟩ = I|ψ⟩ = |0⟩⟨0|ψ⟩ + |1⟩⟨1|ψ⟩, which says exactly that the amplitudes are the inner products with the basis states.
Outer products also let you write whole matrices compactly. The Pauli Z gate is Z = |0⟩⟨0| − |1⟩⟨1|, and X is X = |0⟩⟨1| + |1⟩⟨0|. In general a Hermitian matrix equals the sum of its eigenvalues times the projectors onto its eigenvectors, a result known as the spectral decomposition.
Worked example
Build X from outer products
- |0⟩⟨1| = [[0, 1], [0, 0]] and |1⟩⟨0| = [[0, 0], [1, 0]].
- Their sum is [[0, 1], [1, 0]], which is exactly X. Reading it aloud: take |1⟩ to |0⟩ and |0⟩ to |1⟩.
Reading Dirac notation fluently
The bra-ket notation compresses a lot of matrix algebra into short expressions. This table collects the pieces so you can decode any formula you meet.
| You see | It means | Type of object |
|---|---|---|
| |ψ⟩ | State vector (column) | Vector |
| ⟨ψ| | Conjugate transpose of |ψ⟩ (row) | Covector |
| ⟨φ|ψ⟩ | Inner product | Complex number |
| |φ⟩⟨ψ| | Outer product | Matrix |
| A|ψ⟩ | Matrix acting on a vector | Vector |
| ⟨φ|A|ψ⟩ | Sandwich: apply A, then take overlap with φ | Complex number |
| U† | Conjugate transpose, the undo of a unitary | Matrix |
A quick guide to reading expressions.
A good habit is to ask of every expression: is it a number, a vector or a matrix? Mixing them up produces nonsense, such as adding a number to a vector. Reading types is the fastest way to catch an algebra error.
Worked example
Evaluate ⟨1|H|0⟩
- H|0⟩ = (1/√2)(|0⟩ + |1⟩).
- Take the inner product with ⟨1|: ⟨1|H|0⟩ = 1/√2.
- Its squared length is ½, so after H the state of a qubit that started in |0⟩ would be found in |1⟩ half the time.
Changing basis
A basis is a choice of reference directions. The same state vector can be written in many bases, and the numbers you write down change while the state itself does not. Quantum computing switches basis constantly, because measuring in a different basis is the same as asking a different question.
Suppose a state is |ψ⟩ = α|0⟩ + β|1⟩. The plus and minus states are |+⟩ = (|0⟩ + |1⟩)/√2 and |−⟩ = (|0⟩ − |1⟩)/√2. To rewrite |ψ⟩ in that basis, you need the inner products with each new basis vector:
⟨+|ψ⟩ = (α + β)/√2 ⟨−|ψ⟩ = (α − β)/√2 |ψ⟩ = ((α + β)/√2)|+⟩ + ((α − β)/√2)|−⟩
Worked example
Rewrite |0⟩ and |1⟩ in the ± basis
- For |0⟩: α = 1, β = 0, so the coefficients are 1/√2 and 1/√2. Hence |0⟩ = (|+⟩ + |−⟩)/√2.
- For |1⟩: α = 0, β = 1, so the coefficients are 1/√2 and −1/√2. Hence |1⟩ = (|+⟩ − |−⟩)/√2.
- A state that is certain in the first basis is a 50-50 superposition in the second, and the reverse holds too.
Look at the arithmetic above. The coefficient list (α + β, α − β)/√2 is exactly the Hadamard matrix applied to (α, β). A change from one orthonormal basis to another is always done by a unitary matrix, and here that matrix is H. This is why the Hadamard gate is so central: applying it to a qubit is the same as relabelling that qubit's description from the standard basis to the ± basis.
Matrices change when the basis changes too. If you describe the Z gate in the ± basis, it swaps |+⟩ and |−⟩, so it looks exactly like X looked in the standard basis. In symbols, HZH = X and HXH = Z. Conjugating a gate by H exchanges the roles of the two bases, and that identity is used again and again when simplifying circuits.
Worked example
Verify HZH = X
- ZH = [[1, 0], [0, −1]] · (1/√2)[[1, 1], [1, −1]] = (1/√2)[[1, 1], [−1, 1]].
- H(ZH) = (1/2)[[1, 1], [1, −1]] · [[1, 1], [−1, 1]] = (1/2)[[0, 2], [2, 0]] = [[0, 1], [1, 0]] = X. ✓
The Pauli algebra: a small set of rules that does a lot
The three matrices X, Y and Z, together with the identity I, appear in nearly every quantum calculation. They satisfy a handful of simple rules, and knowing them lets you simplify long expressions without multiplying out matrices.
- Each squares to the identity: X² = Y² = Z² = I.
- Products of two different ones give the third, times a phase: XY = iZ, YZ = iX, ZX = iY.
- Reversing the order flips the sign: YX = −iZ, ZY = −iX, XZ = −iY.
- Any two different Pauli matrices anticommute: XY = −YX, and similarly for the other pairs.
- Each is Hermitian (equal to its dagger) and unitary (its dagger is its inverse).
| Product | Result | Product | Result |
|---|---|---|---|
| XX | I | XY | iZ |
| YY | I | YZ | iX |
| ZZ | I | ZX | iY |
| YX | −iZ | ZY | −iX |
Multiplication table of the Pauli matrices.
The pair of operations that measure how far two matrices are from commuting are the commutator [A, B] = AB − BA and the anticommutator {A, B} = AB + BA. For two different Pauli matrices the anticommutator is zero and the commutator is twice their product, so [X, Y] = 2iZ. The fact that these matrices do not commute is the algebraic form of the statement that you cannot know X and Z with certainty at the same time.
Worked example
Simplify XYX
- Use XY = −YX to move the second X to the left: XYX = −YXX.
- Since XX = I, this gives XYX = −Y.
- Check on the Bloch sphere: conjugating by X flips the y and z axes (a half turn about x), so Y becomes −Y.
Why bother
Many quantum error-correction and measurement ideas are statements about which Pauli products commute with which. The stabiliser formalism, used for error-correcting codes, is built almost entirely on this table and on the commuting-or-anticommuting rule.
Functions of a matrix: where the rotation formulas come from
You can apply a function to a matrix by applying it to the eigenvalues. The most important case in quantum computing is the exponential, because evolving a quantum system for some time is described by e^(−iHt) for a Hermitian matrix H (the Hamiltonian, here in units where ħ = 1). The same formula gives every single-qubit rotation gate.
Take a Pauli matrix P, with P² = I. Expand the exponential as a power series, e^(−iθP/2) = Σ (−iθ/2)ⁿ Pⁿ / n!. Because P² = I, even powers of P equal I and odd powers equal P. Collecting terms, the even-power part sums to cos(θ/2) and the odd-power part sums to −i sin(θ/2), so
e^(−iθP/2) = cos(θ/2) I − i sin(θ/2) P
This is exactly the rotation formula used in the Bloch-sphere lesson. It also explains the half angle: the exponent contains θ/2 because the Pauli matrices have eigenvalues ±1, and the two eigenvalues of the rotation are e^(∓iθ/2), which differ by a relative phase of θ.
Worked example
A rotation by π about z is the Z gate (up to phase)
- Rz(π) = cos(π/2) I − i sin(π/2) Z = −iZ.
- So Rz(π) = −iZ, which equals Z multiplied by the global phase −i. As a global phase is unobservable, Rz(π) and Z are the same gate.
Worked example
A small rotation
- Rx(π/2) = cos(π/4) I − i sin(π/4) X = (1/√2)[[1, −i], [−i, 1]].
- Applied to |0⟩ this gives (1/√2)(|0⟩ − i|1⟩), the state |−i⟩ on the equator. A quarter turn about x carries the north pole to the equator, as expected.
The same idea lets you exponentiate any Hermitian matrix once you know its eigenvectors: write H = Σ λₖ|vₖ⟩⟨vₖ|, then e^(−iHt) = Σ e^(−iλₖt)|vₖ⟩⟨vₖ|. Every eigenvector gets its own phase, and the phases advance at rates set by the eigenvalues. Simulating quantum systems on a quantum computer is largely the task of implementing this unitary.
Worked problems
Try each problem on paper before opening the solution. They use everything above.
Worked example
Problem 1: Is M = (1/√2)[[1, i], [i, 1]] a valid gate?
- Compute M†: conjugate the entries and transpose. Since the matrix is symmetric, M† = (1/√2)[[1, −i], [−i, 1]].
- M†M = (1/2)[[1·1 + (−i)(i), 1·i + (−i)·1], [(−i)·1 + 1·i, (−i)(i) + 1·1]] = (1/2)[[2, 0], [0, 2]] = I.
- So M is unitary and a valid gate. (It equals Rx(π/2) up to a global phase.)
Worked example
Problem 2: Measure (1 + i)/2 |0⟩ + (1 − i)/2 |1⟩ in the ± basis
- Here α = (1 + i)/2 and β = (1 − i)/2. First check normalisation: |α|² = 2/4 = ½ and |β|² = 2/4 = ½. Total 1. ✓
- ⟨+|ψ⟩ = (α + β)/√2 = (1/√2)(1) = 1/√2, since α + β = (1 + i + 1 − i)/2 = 1. So P(+) = ½.
- ⟨−|ψ⟩ = (α − β)/√2 = (1/√2)(i) since α − β = (1 + i − 1 + i)/2 = i. So P(−) = |i/√2|² = ½.
- The state is a fair coin in this basis as well. Which basis would give certainty? The Y basis, since this is |−i⟩ up to a relabelling.
Worked example
Problem 3: Show that Z and X anticommute using their action on |0⟩
- ZX|0⟩ = Z|1⟩ = −|1⟩, while XZ|0⟩ = X|0⟩ = |1⟩.
- So ZX|0⟩ = −XZ|0⟩. Doing the same for |1⟩ gives ZX|1⟩ = Z|0⟩ = |0⟩ and XZ|1⟩ = −X|1⟩ = −|0⟩, again opposite signs. Hence ZX = −XZ.
Worked example
Problem 4: Find the eigenvalues of the Hadamard matrix
- H² = I, so any eigenvalue λ satisfies λ² = 1, hence λ = ±1.
- The trace of H is (1 − 1)/√2 = 0, which equals the sum of the eigenvalues. With two eigenvalues from {+1, −1} summing to zero, they must be +1 and −1.
- An eigenvector for +1 is cos(π/8)|0⟩ + sin(π/8)|1⟩, the state halfway between |0⟩ and |+⟩.
Common mistakes
- Forgetting the conjugate. ⟨ψ| is the conjugate transpose, not just the transpose. With real numbers the difference is invisible, which hides the error until complex phases appear.
- Squaring instead of taking the squared modulus. For complex α, the probability is |α|² = α*α, not α².
- Reversing the order of gates. In a product BA the matrix A acts first. Circuit diagrams read left to right, but the matrix product reads right to left.
- Confusing global and relative phase. Multiplying the whole state by a phase is invisible; multiplying only one amplitude is not.
- Treating a non-normalised vector as a state. Always check that squared lengths sum to 1 before using the measurement rule.
- Assuming AB = BA. Quantum gates generally do not commute.
Test yourself
Check yourself
What is |1 + i|, and what is (1 + i)/(1 − i)?
|1 + i| = √2. For the quotient multiply top and bottom by the conjugate of the bottom: (1 + i)(1 + i)/((1 − i)(1 + i)) = (1 + 2i − 1)/2 = i.
Is (1, 1)ᵀ a valid qubit state? If not, fix it.
No, its squared length is 2. Divide by √2 to get (1/√2, 1/√2)ᵀ, which is |+⟩.
If a qubit is in (√3/2)|0⟩ + (1/2)|1⟩, what are P(0) and P(1)?
P(0) = 3/4 = 75% and P(1) = 1/4 = 25%. They sum to 1.
Compute Z|+⟩.
Z|+⟩ = (1/√2)(|0⟩ − |1⟩) = |−⟩. The Z gate turns |+⟩ into |−⟩; it changes the relative phase.
Why can a gate not be the matrix [[1, 0], [0, 2]]?
It sends |1⟩ to 2|1⟩, a vector of length 2. Gates must be unitary so that lengths stay 1.
What is the difference between ⟨0|1⟩ and |0⟩⟨1|?
⟨0|1⟩ is an inner product, equal to the number 0. |0⟩⟨1| is an outer product, the matrix [[0, 1], [0, 0]].
References and further reading
The explanations on this page are written for this site. I opened each page below to confirm its title, author and access terms; I did not read the full texts here. Chapter pointers for the Nielsen and Chuang book come from its standard table of contents and were not opened.
- Quantum Computation and Quantum Information, 10th Anniversary Edition (Nielsen and Chuang, Cambridge University Press (2011)) The standard textbook. Chapter 2 develops this material; not opened in full here.
- Basics of quantum information: Single systems (IBM Quantum Learning, presented by John Watrous) Opened. Covers states as complex vectors, measurement and unitary operations.
- The Theory of Quantum Information (John Watrous, Cambridge University Press (2018)) Opened. The page offers a free manuscript for personal use.
- Physics 219 Quantum Computation: lecture notes (John Preskill, Caltech) Opened. Chapter 2 is Foundations I: States and Ensembles; Chapter 3 is Foundations II: Measurement and Evolution.
- Linear Algebra Done Right, fourth edition (Sheldon Axler) Opened. Open-access under a Creative Commons BY-NC licence; covers eigenvalues, inner product spaces and the spectral theorem.
- 18.06 Linear Algebra (MIT, Gil Strang) Opened. Course page with video lectures, including complex matrices and the singular value decomposition.
Key terms in the dictionary