Level 7 · Capstone Topics

Practice Set 1: Qubits, Gates and Entanglement with Worked Solutions

About 4,889 words · roughly 22 minute read · sources checked December 3, 2026

This is the first of three practice sets. It covers the material from the Math Foundations, Foundations and Core Principles levels: amplitudes and probabilities, the single-qubit gates, tensor products and the simplest test for entanglement.

Each problem has a hidden answer. Click a question to open its solution. Try it on paper first; the learning is in the attempt, not in reading the answer.

Every number in the solutions was calculated with NumPy, and I checked each one with an assertion in the code that generated this page (for example, that U†U = I where claimed). Where a problem uses a standard identity, such as XZ = −ZX, I confirmed it numerically.

What you will learn

  • How to normalise a state and read off probabilities.
  • How to multiply, compare and test gate matrices.
  • How to build a Bell state and tell entangled from product states.
  • How fast the number of amplitudes grows with qubits.

Helpful first: What is a Qubit?, Quantum Gates.

States, amplitudes and probabilities

Try each problem on paper first. Then open the answer to compare. Every number in the solutions was computed with NumPy, and I re-checked that each result is consistent (for example, that probabilities add to 1).

Check yourself

A1. The unnormalised state (1 + i)|0⟩ + 1|1⟩ is given. Normalise it and find the probabilities of measuring 0 and 1.

The squared length is |1+i|² + |1|² = 2 + 1 = 3, so divide by √3 = 1.7321. The normalised amplitudes are (1+i)/√3 and 1/√3. P(0) = 2/3 = 0.6667 and P(1) = 1/3 = 0.3333. They add to 1, as they must.

A2. A qubit is in the state 0.6|0⟩ + 0.8i|1⟩. Is it normalised? What are P(0), P(1), and the average value of Z?

0.6² + 0.8² = 0.36 + 0.64 = 1, so yes. The factor i has size 1 and does not change probabilities. P(0) = 0.36, P(1) = 0.64. The average of Z (which is +1 for outcome 0 and −1 for outcome 1) is 0.36 − 0.64 = -0.28.

A3. The gate Ry(θ) turns |0⟩ into cos(θ/2)|0⟩ + sin(θ/2)|1⟩. For θ = π/3, find P(0) and P(1).

cos(π/6) = 0.866 and sin(π/6) = 0.5. So P(0) = cos²(π/6) = 0.75 and P(1) = 0.25. Check: 0.75 + 0.25 = 1.

A4. Which point on the Bloch sphere is Ry(π/2)|0⟩, and what is P(0)?

Ry(π/2)|0⟩ = (|0⟩ + |1⟩)/√2 = |+⟩, which points along the +x axis, so the Bloch vector is (1, 0, 0). P(0) = cos²(π/4) = 0.5.

Gates and matrices

Check yourself

B1. Compute XZ and ZX. Are they equal?

XZ = [[0, −1], [1, 0]] and ZX = [[0, 1], [−1, 0]]. They are not equal; in fact XZ = −ZX. Order matters for gates, so a circuit read left to right is a product written right to left.

B2. What do HH and H|1⟩ give?

HH = I (the identity), because H applied twice returns the original state. H|1⟩ = (|0⟩ − |1⟩)/√2 = |−⟩. Measuring |−⟩ gives 0 or 1 with probability 0.5 each, just like |+⟩; the sign is invisible until another H is applied.

B3. Show that T² = S and S² = Z, where T = diag(1, e^(iπ/4)) and S = diag(1, i).

Squaring a diagonal matrix squares its entries. T²: e^(iπ/4)² = e^(iπ/2) = i, so T² = diag(1, i) = S. S²: i² = −1, so S² = diag(1, −1) = Z. So Z = S² = T⁴, which is the phase pattern used in the phase estimation lesson.

B4. Is [[1, 1], [0, 1]] a valid quantum gate? What about [[1, 0], [0, i]]?

A gate must be unitary: U†U = I. For [[1,0],[0,i]], the conjugate transpose is [[1,0],[0,−i]], and the product is the identity, so it is valid (it is the S gate). For [[1,1],[0,1]], U†U = [[1,1],[1,2]], which is not the identity, so it is not a valid gate. It would change the total probability.

B5. Rx(π) = [[cos(π/2), −i sin(π/2)], [−i sin(π/2), cos(π/2)]]. Simplify it and compare with X.

cos(π/2) = 0 and sin(π/2) = 1, so Rx(π) = [[0, −i], [−i, 0]] = −iX. It flips |0⟩ and |1⟩ just like X, but with an extra global phase of −i. A global phase cannot be detected by measurement, so the two gates act the same in practice.

B6. The commutator is [X, Y] = XY − YX. Compute it.

XY = iZ and YX = −iZ, so [X, Y] = iZ − (−iZ) = 2iZ. I checked this numerically. The fact that X and Y do not commute is the reason you cannot measure both at once with certainty.

Several qubits and entanglement

Check yourself

C1. Write the two-qubit state |+⟩ ⊗ |0⟩ and its probabilities.

|+⟩ = (|0⟩ + |1⟩)/√2, so |+⟩⊗|0⟩ = (|00⟩ + |10⟩)/√2. The amplitudes in the order 00, 01, 10, 11 are 0.7071, 0, 0.7071, 0, so P(00) = P(10) = 0.5.

C2. Start from |00⟩. Apply H to the first qubit, then CNOT with the first qubit as control. What state results?

After H: (|00⟩ + |10⟩)/√2. The CNOT flips the second qubit when the first is 1, so |10⟩ becomes |11⟩. The result is (|00⟩ + |11⟩)/√2, a Bell state, with P(00) = P(11) = 0.5 and P(01) = P(10) = 0. Measuring one qubit tells you the other.

C3. A two-qubit state has amplitudes (a, b, c, d) for 00, 01, 10, 11. It is a product state exactly when ad = bc. Test (½, ½, ½, ½) and (1/√2, 0, 0, 1/√2).

For (½, ½, ½, ½): ad = ¼ and bc = ¼, equal, so it is a product state (it is |+⟩|+⟩). For (1/√2, 0, 0, 1/√2): ad = ½ and bc = 0, not equal, so it is entangled. This is the quickest test for two qubits; it does not extend to three or more.

C4. How many complex amplitudes describe n qubits? How much memory do 20 qubits need at 16 bytes per amplitude?

2ⁿ amplitudes. For 20 qubits that is 1,048,576 amplitudes, and 16 × 1,048,576 = 16,777,216 bytes, which is about 16.8 megabytes, or exactly 16 MiB. For 30 qubits the same arithmetic gives 17.2 GB, which is why classical simulation gets hard so quickly.

More problems on states, probabilities and the Bloch sphere

These problems repeat the first skill of the course: take a state written in amplitudes, normalise it, and predict what a measurement shows. Add the Bloch-sphere picture, where every pure single-qubit state is a point on a sphere and the three expectation values ⟨X⟩, ⟨Y⟩ and ⟨Z⟩ are its coordinates. All numbers below were computed with NumPy.

Check yourself

D1. The unnormalised state 2|0⟩ + (1 − i)|1⟩ is given. Normalise it and find P(0) and P(1).

The squared length is |2|² + |1 − i|² = 4 + 2 = 6. Dividing by √6 gives the normalised state. P(0) = 4/6 = 0.6667 and P(1) = 2/6 = 0.3333. Note that |1 − i|² = 1² + (−1)² = 2, not (1 − i)². The probability uses the squared magnitude, and mixing up the two is the most common error in this kind of problem.

D2. A state is 0.6|0⟩ + 0.8i|1⟩. Find ⟨X⟩, ⟨Y⟩ and ⟨Z⟩, and check that ⟨X⟩² + ⟨Y⟩² + ⟨Z⟩² = 1.

For a state a|0⟩ + b|1⟩, ⟨Z⟩ = |a|² − |b|², ⟨X⟩ = 2 Re(a*b) and ⟨Y⟩ = 2 Im(a*b). Here a = 0.6 and b = 0.8i, so a*b = 0.48i. Then ⟨X⟩ = 0, ⟨Y⟩ = 0.96 and ⟨Z⟩ = 0.36 − 0.64 = −0.28. The squares add to 0 + 0.9216 + 0.0784 = 1.0000, as they must for a pure state. The Bloch vector is (0, 0.96, −0.28), which lies in the y–z plane, a little below the equator.

D3. Find the Bloch vector of Ry(π/3)|0⟩. What is the probability of measuring + when you measure in the X basis?

Ry(θ)|0⟩ has Bloch vector (sin θ, 0, cos θ). For θ = π/3 that is (0.8660, 0, 0.5). The probability of the + outcome in the X basis is (1 + ⟨X⟩)/2 = (1 + 0.8660)/2 = 0.9330. In the Z basis the same state gives P(0) = (1 + 0.5)/2 = 0.75, which matches cos²(π/6). One state, two measurement bases, two different probabilities: the choice of basis is part of the question.

D4. The gate Rz(θ) leaves P(0) and P(1) unchanged when applied to any state. Yet H Rz(θ) H |0⟩ has P(1) = sin²(θ/2). Compute P(1) for θ = π/2 and θ = π/3, and explain why the phase became visible.

For θ = π/2, P(1) = sin²(π/4) = 0.5. For θ = π/3, P(1) = sin²(π/6) = 0.25. I confirmed both with a matrix calculation: 0.5/0.5 and 0.75/0.25 for P(0)/P(1). The first Hadamard turns |0⟩ into |+⟩, a state whose two components have a relative phase that can change. Rz changes that relative phase, and the second Hadamard turns a relative phase into a probability. This 'Hadamard sandwich' is the basic interference trick behind almost every algorithm, and the HH widget below shows the θ = 0 case.

D5. A student applies S to |+⟩ and then H, and measures. What are the probabilities? Which Bloch-sphere rotation did S perform?

S|+⟩ = (|0⟩ + i|1⟩)/√2. Applying H gives amplitudes (1 + i)/2 on |0⟩ and (1 − i)/2 on |1⟩. Each has squared magnitude 0.5, so P(0) = P(1) = 0.5. (I computed this as H S H |0⟩ = (0.5 + 0.5i, 0.5 − 0.5i).) On the Bloch sphere, S is a quarter turn about the z-axis, and it takes the +x point to the +y point. A measurement in the Z basis after H is a measurement of ⟨X⟩ before it, and ⟨X⟩ of the +y state is zero, hence 50/50.

More problems on gates and unitarity

A quantum gate must be unitary: U†U = I. This guarantees that probabilities still add to one after the gate. The problems below test unitarity, identities between gates and the way one gate becomes another when it is wrapped in Hadamards.

Check yourself

E1. Check whether each matrix is unitary: (a) (1/√2)[[1, 1], [1, −1]], (b) [[1, 1], [1, 1]]/2, (c) [[0, 1], [1, 0]], (d) [[1, 0], [0, 0]].

(a) is the Hadamard gate, which is unitary. (b) is a projector onto |+⟩: it squares to itself but is not unitary, because it sends |−⟩ to zero and so loses information. (c) is the X gate, which is unitary. (d) is the projector onto |0⟩, again not unitary. A quick test: a unitary never sends a non-zero vector to zero, and its columns are orthonormal. Projectors are measurements, not gates.

E2. Show that HZH = X and HXH = Z. What is HYH?

Multiply the matrices. HZH sends |0⟩ → H|0⟩ = |+⟩ → Z|+⟩ = |−⟩ → H|−⟩ = |1⟩, and |1⟩ → |−⟩ → |+⟩ → |0⟩, which is the action of X. Likewise HXH = Z. For Y, the numerical check gives HYH = −Y. All three identities were confirmed by direct matrix multiplication. Conjugating by H swaps the roles of the x and z axes and flips the sign of y.

E3. The identity HZH = X means a Z gate can be turned into an X gate. Write the CNOT in terms of a CZ and two Hadamards.

CNOT with control c and target t equals H on t, then CZ(c, t), then H on t. The reason is HZH = X on the target: the target sees an X exactly when the control is 1, which is the definition of CNOT. This is why hardware that natively provides CZ can still run any circuit written with CNOT, and why the czAsCx widget below gives the same result as a CNOT circuit.

E4. Compute the single-qubit gate X H X and apply it to |0⟩. Is the result a valid gate? What are P(0) and P(1)?

Conjugating H by X swaps its rows and columns, so X H X = (1/√2)[[−1, 1], [1, 1]]. Check by action: X|0⟩ = |1⟩, H|1⟩ = (|0⟩ − |1⟩)/√2, and X of that is (|1⟩ − |0⟩)/√2. So X H X |0⟩ = (−|0⟩ + |1⟩)/√2, with P(0) = P(1) = 0.5. The product of unitaries is unitary, so the composite is a valid gate (it also equals −ZHZ, which I checked by matrix multiplication). The point of the problem is that a product of gates is itself a gate, and the result is checked by tracking a basis state, not by trusting a half-remembered matrix.

E5. A qubit passes through the same gate G twice and ends in the starting state for every input. Name three gates that have this property and one that does not.

X, Y, Z and H each satisfy G² = I, so applying them twice returns the input. S does not: S² = Z, which changes the phase of |1⟩. T does not either: T⁴ = Z and T⁸ = I. This is a useful fact for circuit simplification, because two identical self-inverse gates in a row cancel, as the HH widget shows.

More problems on several qubits and entanglement

With two or more qubits the state space grows exponentially, and entanglement appears. The problems below put numbers on both facts.

Check yourself

F1. How much memory does a classical computer need to store the state of 30 qubits at 16 bytes per amplitude? What about 40 and 50?

A 30-qubit state has 2³⁰ amplitudes, so 2³⁰ × 16 bytes = 17.18 × 10⁹ bytes, which is 16 GiB. For 40 qubits it is 2⁴⁰ × 16 = 17.6 × 10¹² bytes, about 17.6 terabytes. For 50 qubits it is 2⁵⁰ × 16 ≈ 1.8 × 10¹⁶ bytes, about 18 petabytes. This is the reason classical simulation stops being practical in the range of 45 to 50 qubits for a general state, and it is a memory limit before it is a speed limit.

F2. Apply H to qubit 0 and CNOT (control 0, target 1), then CNOT (control 1, target 2) on |000⟩. What state results, and what outcomes does a Z measurement show?

After H and the first CNOT, the state is (|00⟩ + |11⟩)/√2 on the first two qubits; the second CNOT copies the second qubit's value into the third. The result is (|000⟩ + |111⟩)/√2, the GHZ state. A Z measurement shows 000 or 111, each with probability 0.5, and never anything else. The GHZ widget below runs this circuit.

F3. Is (|00⟩ + |01⟩ + |10⟩ + |11⟩)/2 a product state? Is (|00⟩ + |11⟩)/√2 a product state? Use ad − bc.

For amplitudes (a, b, c, d) on 00, 01, 10, 11, the state is a product exactly when ad = bc. For the first state, a = b = c = d = 1/2, so ad − bc = 1/4 − 1/4 = 0: it is a product state, namely |+⟩ ⊗ |+⟩. For the second, a = d = 1/√2 and b = c = 0, so ad − bc = 1/2 ≠ 0, so the state is entangled. The value 1/2 is the largest possible for a normalised two-qubit state, so the Bell state is maximally entangled.

F4. The four Bell states are produced by applying I, X, Z or XZ to the first qubit of (|00⟩ + |11⟩)/√2. List the resulting states.

I gives (|00⟩ + |11⟩)/√2. X gives (|10⟩ + |01⟩)/√2. Z gives (|00⟩ − |11⟩)/√2. XZ gives (|01⟩ − |10⟩)/√2 up to a global sign. These four states are orthogonal and form a basis for two qubits. Alice can choose among them with one qubit's worth of operations, which is the idea behind superdense coding, where two classical bits travel on one transmitted qubit.

F5. For (|00⟩ + |11⟩)/√2, what are P(first = 0 and second = 0), P(first = 0 and second = 1), and what happens if both qubits are measured in the X basis?

P(00) = 0.5, P(01) = 0, P(10) = 0, P(11) = 0.5. In the X basis the same state gives both qubits the same outcome again: (|++⟩ + |−−⟩)/√2, so ++ and −− each have probability 0.5. The correlation is not specific to one basis. This is what separates entanglement from a shared coin that was flipped in advance, and it is the starting point for the Bell-inequality experiments.

F6. SWAP can be built from three CNOT gates. Give the controls and targets and verify on |10⟩ and |11⟩.

SWAP(a, b) = CNOT(a → b), then CNOT(b → a), then CNOT(a → b). Take |ab⟩ = |10⟩: the first CNOT gives |11⟩, the second gives |01⟩, the third leaves |01⟩. The values were swapped. Take |11⟩: the first CNOT gives |10⟩, the second does nothing because b = 0, and the third gives |11⟩. It is unchanged, which is correct because swapping two equal bits does nothing.

More problems on measurement and statistics

Measurement is where theory meets the lab. A circuit gives a distribution, and you see it only through a finite number of shots. These problems connect the probabilities you have computed to the counts you would see on a real device. The numbers are my own arithmetic.

Check yourself

G1. A circuit gives P(1) = 0.25. You run 1,000 shots. What count of 1s do you expect, and what is the standard deviation of that count?

The expected count is 1,000 × 0.25 = 250. The standard deviation of a count from N independent shots is √(N p (1 − p)) = √(1000 × 0.25 × 0.75) = √187.5 = 13.69. So most runs land between about 236 and 264 (within one standard deviation), and a count of 220 or 280 would be unusual, though not impossible. The result is a statement about the distribution, and not about any single run.

G2. For the same circuit, how many shots are needed so that the standard error of the estimated P(1) is 0.005?

The standard error of the estimated probability is √(p(1 − p)/N). Setting √(0.1875/N) = 0.005 gives N = 0.1875 / 0.000025 = 7,500 shots. Halving the error again to 0.0025 needs 30,000 shots, four times as many. The cost grows with the inverse square of the error, which is the same square-root law that governs variational algorithms.

G3. Two states, |+⟩ and Ry(π/3)|0⟩, are each measured in the Z basis. Can you tell them apart from the counts? What if you measure in the X basis?

In the Z basis, |+⟩ gives P(1) = 0.5 and Ry(π/3)|0⟩ gives P(1) = sin²(π/6) = 0.25. These are different, so with enough shots you can tell them apart; with 1,000 shots the gap of 0.25 is about 15 standard deviations. In the X basis, |+⟩ gives P(+) = 1, while Ry(π/3)|0⟩ gives P(+) = 0.933. That gap of 0.067 is much harder to detect and needs thousands of shots. Choosing a good measurement basis is a real skill.

G4. A coin-flip circuit (one Hadamard, then measure) is run 10 times and shows 0 each time. Is that evidence of a bug?

The chance of ten zeros in a row from a fair coin is (1/2)¹⁰ = 1/1,024 ≈ 0.001. That is rare enough to be suspicious, though not impossible. Check the circuit first: a missing Hadamard gives exactly this result. This is a good habit: when a surprising result has a probability of about 0.1 percent, test the simplest explanation, a wiring error, before looking for new physics.

The five mistakes that cost the most marks

In my experience of writing these solutions, a handful of slips account for most wrong answers. Treat the list as a checklist before you open any solution.

  1. Forgetting to normalise. The vector (1, 1) has length √2, and the state is (1, 1)/√2.
  2. Squaring a complex number instead of taking its squared magnitude. |1 − i|² is 2, not (1 − i)² = −2i.
  3. Multiplying matrices in the wrong order. The first gate applied is the rightmost matrix in the product, so X then Z is ZX.
  4. Mixing up bit orders. Qiskit prints qubit 0 on the right, while many textbooks write qubit 0 on the left.
  5. Treating a global phase as meaningful. A factor of −1 on the whole state changes nothing measurable, but a −1 on only one component does.

Each of these mistakes has a quick test. Normalisation: probabilities add to 1. Complex squares: the answer must be a non-negative real number. Order: test the product on |0⟩ by hand. Bit order: run it in the browser widget. Phase: apply a Hadamard and see whether the result changes.

A study plan for this set

Do the problems in three sittings. First, states and probabilities (A and D). Second, gates and unitarity (B and E). Third, several qubits and statistics (C, F and G). Between sittings, run the matching widgets, because seeing a circuit produce your predicted number is what makes the formula stick.

One problem solved in full, slowly

The solutions above are short on purpose. Here is one problem done with every step visible, so you can see what a complete answer looks like. The problem: start from |00⟩, apply H to qubit 0, apply CNOT with control 0 and target 1, then apply H to qubit 0 again, and give the measurement probabilities.

Step 1: write the starting state

The state is |00⟩, meaning both qubits are 0. In vector form it has amplitude 1 on 00 and 0 on 01, 10 and 11.

Step 2: apply H to qubit 0

H turns the first qubit into (|0⟩ + |1⟩)/√2, so the state is (|00⟩ + |10⟩)/√2. Each of the two terms has amplitude 1/√2 = 0.7071, and each probability is 0.5.

Step 3: apply CNOT

CNOT flips the second qubit when the first is 1. The term |00⟩ is unchanged. The term |10⟩ becomes |11⟩. The state is now (|00⟩ + |11⟩)/√2, the Bell state. At this point P(00) = P(11) = 0.5 and the other two are zero.

Step 4: apply H to qubit 0 again

Apply H to the first qubit of each term, keeping the second qubit as it is. H|0⟩ = (|0⟩ + |1⟩)/√2 and H|1⟩ = (|0⟩ − |1⟩)/√2. So |00⟩ becomes (|00⟩ + |10⟩)/√2 and |11⟩ becomes (|01⟩ − |11⟩)/√2. Combining with the overall factor 1/√2 gives (|00⟩ + |10⟩ + |01⟩ − |11⟩)/2.

Step 5: read off the probabilities

Each of the four terms has amplitude of magnitude 1/2, so each has probability 1/4 = 0.25. The minus sign on |11⟩ does not change its probability. The sum of the four is 1, which is the normalisation check. The final answer is a uniform distribution over all four outcomes.

Step 6: reflect

The answer is surprising. After the Bell state the two qubits were perfectly correlated, and one more Hadamard on one qubit made the outcomes look independent. The correlation did not vanish: it moved into the phases, where the Z-basis counts cannot see it. A measurement of the right combination of X and Z would still show it. This is the sense in which probabilities hide information that the amplitudes hold, and it is the reason the order of gates and the choice of measurement basis matter.

Habit worth building

After every gate, rewrite the state in a single line and check that the squared magnitudes still add to 1. A slip is then caught one step after it happens, not at the end.

Run the circuits behind these answers

Use the widgets below to check your solutions. Remember to predict first. The strings use Qiskit's bit order, with qubit 0 on the right.

A fair coin from one Hadamard

Run this circuit

One Hadamard: a fair quantum coin

q0H

Bit order: q0 is the rightmost digit of each result, as in Qiskit. All qubits start in |0⟩ unless marked. This is an ideal simulator with no hardware noise.

Predict first: Starting from |0⟩, one H gate. What fractions of 0 and 1 do you expect over many shots?

Press Run to simulate. Results appear here with a short explanation.

D4 with θ = 0: two Hadamards cancel

Run this circuit

H then H: interference undoes the superposition

q0HH

Bit order: q0 is the rightmost digit of each result, as in Qiskit. All qubits start in |0⟩ unless marked. This is an ideal simulator with no hardware noise.

Predict first: Two Hadamards in a row. If H made the qubit truly random, a second H should keep it random. Does it?

Press Run to simulate. Results appear here with a short explanation.

E2: HZH acts like X

Run this circuit

H, Z, H: a phase becomes a bit

q0HZH

Bit order: q0 is the rightmost digit of each result, as in Qiskit. All qubits start in |0⟩ unless marked. This is an ideal simulator with no hardware noise.

Predict first: Z does nothing to |0⟩ and only flips the sign of |1⟩. Sandwiched between two H gates, will it matter?

Press Run to simulate. Results appear here with a short explanation.

E3: the CZ-with-Hadamards version of a CNOT

Run this circuit

CZ sandwiched by H equals CNOT

q0q1XHH

Bit order: q0 is the rightmost digit of each result, as in Qiskit. All qubits start in |0⟩ unless marked. This is an ideal simulator with no hardware noise.

Predict first: Qubit 0 is set to 1. Wrapping CZ in Hadamards on the target should behave like a CNOT. What is the final string?

Press Run to simulate. Results appear here with a short explanation.

F2: the GHZ state

Run this circuit

GHZ state across three qubits

q0q1q2H

Bit order: q0 is the rightmost digit of each result, as in Qiskit. All qubits start in |0⟩ unless marked. This is an ideal simulator with no hardware noise.

Predict first: Extend the Bell circuit with one more CNOT. Which strings appear now?

Press Run to simulate. Results appear here with a short explanation.

The Bell pair for F4 and F5

Run this circuit

Bell pair: H then CNOT

q0q1H

Bit order: q0 is the rightmost digit of each result, as in Qiskit. All qubits start in |0⟩ unless marked. This is an ideal simulator with no hardware noise.

Predict first: H puts qubit 0 in superposition; CNOT copies its value onto qubit 1 as an XOR. Which of 00, 01, 10, 11 can appear?

Press Run to simulate. Results appear here with a short explanation.

A disagreement between a widget and your hand calculation almost always comes from bit order or from an off-by-one in which gate came first. Fix the method, not only the number.

How to get the most from this set

This set covers the mathematical core of the course in the smallest space. If you can do every problem here without looking, you have the tools for every algorithm lesson. A few habits make the difference.

  • Always write the normalisation check first. A state whose probabilities do not add to 1 means you have an error already.
  • Keep a table of the Pauli gates: X flips, Z adds a sign to |1⟩, Y does both with a factor of i.
  • Use Bloch coordinates to sanity-check a single-qubit answer. If ⟨X⟩² + ⟨Y⟩² + ⟨Z⟩² is not 1 for a pure state, something is wrong.
  • For two qubits, use ad − bc to decide if a state is entangled before trying to factor it by hand.
  • When a gate looks new, check unitarity with U†U = I, or by checking that the columns are orthonormal.

The next set, on algorithms, builds directly on these skills. If you struggled with F2 or F3, practise the tensor-product lesson first, because every algorithm uses multi-qubit states.

Answer key and how to use this set

Work through the sections in order: states, gates, then several qubits. If you miss a problem, go back to the lesson named below it and redo the matching example before continuing.

ProblemFinal answer
A1P(0)=2/3, P(1)=1/3
A2Normalised; ⟨Z⟩ = −0.28
A3P(0)=0.75, P(1)=0.25
A4Bloch vector (1,0,0); P(0)=0.5
B1XZ = −ZX
B2HH = I; H|1⟩ = |−⟩
B3T²=S, S²=Z
B4Second matrix is not unitary
B5Rx(π) = −iX
B6[X,Y] = 2iZ
C1P(00)=P(10)=0.5
C2Bell state
C3First is product; second is entangled
C42ⁿ amplitudes; 16,777,216 bytes for 20 qubits
D1P(0) = 0.6667, P(1) = 0.3333
D2Bloch vector (0, 0.96, −0.28)
D3(0.866, 0, 0.5); P(+) = 0.933
D4P(1) = 0.5 and 0.25
D550/50; S is a quarter turn about z
E1(a) and (c) unitary; (b) and (d) not
E2HZH = X, HXH = Z, HYH = −Y
E3CNOT = H · CZ · H on the target
E4P(0) = P(1) = 0.5
E5X, Y, Z, H square to I; S and T do not
F116 GiB, 17.6 TB, 18 PB
F2GHZ state; 000 or 111
F3First is a product; the Bell state is entangled
F4Four orthogonal Bell states
F500 and 11 at 0.5; also ++ and −−
F6CNOT(a→b), CNOT(b→a), CNOT(a→b)
G1250 ± 13.7
G27,500 shots
G3Z basis separates; X basis is harder
G4Probability 0.001; check for a missing H

Quick answer key. Cover the right column and try each one first.

If you get stuck on A, read What is a Qubit and The Math of a Qubit. For B, read Quantum Gates. For C, read Multi-Qubit Systems and Entanglement.

References and further reading

All answers are my own numerical calculations. No external source was needed for this set beyond standard definitions of the gates.