Measurement in quantum computing

This post explores what happens when you measure one entangled qubit in a part-entangled three-qubit system. The sums turn out to be straightforward once you get over the weird Dirac notation.

It’s easy to think about measurement for a single qubit. Suppose the qubit is in the following superposition:

\(\displaystyle \alpha |0\rangle + \beta|1\rangle\).

If we measure it, then by the Born rule

\(\displaystyle P(|0\rangle) = |\alpha|^2\) and

\(\displaystyle P(|1\rangle) = |\beta|^2\),

where \(|z|\) is the modulus of \(z\).

For example, if

\(\displaystyle |\psi\rangle = \sqrt{0.2} |0\rangle + \sqrt{0.8}|1\rangle\),


\(\displaystyle P(|0\rangle) = |\sqrt{0.2}|^2 = 0.2\) and

\(\displaystyle P(|1\rangle) = |\sqrt{0.8}|^2 = 0.8\).

Following measurement, the qubit’s posterior state, \(|\psi’\rangle\), collapses to whatever the measurement outcome was, so \(|\psi’\rangle = |0\rangle\) or \(|\psi’\rangle = |1\rangle\).

We can measure one qubit in a system of two or more qubits, but now things are more complex. If the qubit we measure is entangled with others, then their superpositions collapse too. Any qubits that are unentangled with the one being measured should survive measurement unscathed.

Quantum mechanics gives us predictions for systems of any number of qubits and configurations (see Matuschak and Nielsen, 2020, postulate 3). Let’s see what happens when we apply it to the following three qubit system:

\(\displaystyle |\psi\rangle = \frac{|000\rangle + |011\rangle + |100\rangle + |111\rangle}{2}\)

Numbering the qubits right to left, the first two (call them \(q[0]\) and \(q[1]\)) are entangled, the third, \(q[2]\), is unentangled with the first two. We are going to measure \(q[0]\).

We need a set of measurement operators. For a single qubit in the classical measurement basis these are \(|0\rangle\langle 0|\) and \(|1\rangle\langle 1|\). To parse this Dirac notation, note that \(\langle \phi |^\dagger = |\phi \rangle\) and \(|\phi \rangle^\dagger = \langle \phi |\), where \(M^\dagger\) is the conjugate transpose of \(M\); i.e., transpose a row vector to a column vector, or vice versa, and take the complex conjugate of each element.


\(\displaystyle |0\rangle\langle 0| = \begin{pmatrix} 1\\ 0 \end{pmatrix} \begin{pmatrix} 1 & 0 \end{pmatrix} = \begin{pmatrix} 1 & 0 \\ 0 & 0 \end{pmatrix}\)

\(\displaystyle |1\rangle\langle 1| = \begin{pmatrix} 0\\ 1 \end{pmatrix} \begin{pmatrix} 0 & 1 \end{pmatrix} = \begin{pmatrix} 0 & 0 \\ 0 & 1 \end{pmatrix}\)

We have three qubits, so we need to pad out these measurement operators with the identity matrix to give

\(M_{q[0] = 0} = I \otimes I \otimes  |0\rangle\langle 0|\)

\(M_{q[0] = 1} = I \otimes I \otimes  |1\rangle\langle 1|\)


\(\displaystyle I = \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix}\)

and \(\otimes\) is the tensor product. This is exactly what we did previously when applying one qubit gates to systems of more than one qubit.

The probability that the measurement outcome for the first qubit is \(1\) is

\(\displaystyle P(q[0] = 1)  =  \langle \psi | M_{q[0] = 1}^\dagger  M_{q[0] = 1} |\psi\rangle = \frac{1}{2}\).

Suppose \(q[0] = 1\) is indeed the measurement outcome. What’s left of the system state (the posterior state), call it \(|\psi’\rangle\)?

\(\displaystyle |\psi’\rangle= \frac{M_{q[0] = 1} | \psi \rangle}{\sqrt{P(q[0] = 1)}} = \frac{\frac{1}{2}(|011\rangle + |111\rangle)}{\sqrt{\frac{1}{2}}} = \frac{|011\rangle + |111\rangle}{\sqrt{2}}\)

So, the first two qubits have collapsed to the same state, \(|1\rangle\). The third is still in superposition (it would be \(|0\rangle\) or \(|1\rangle\) if we measured it). The arithmetic works!

Maybe it’s easier to see what’s going on if we write \(|\psi’\rangle\) as

\(\displaystyle \frac{|011\rangle + |111\rangle}{\sqrt{2}} = \sqrt{0.5}|0{\underline{11}}\rangle + \sqrt{0.5}|1{\underline{11}}\rangle\).

The previously entangled qubits are now underlined. There’s a 50-50 chance that measuring again would give \(q[2]  = 1\) and a 100% chance that \(q[0] = q[1]  = 1\).

Similarly, the probability that \(q[0] = 0\)  is

\(\displaystyle P(q[0] = 0)  =  \langle \psi | M_{q[0] = 0}^\dagger  M_{q[0] = 0} |\psi\rangle = \frac{1}{2}\).

If this is the actual measurement outcome, then the posterior state is

\(\displaystyle |\psi’\rangle= \frac{M_{q[0] = 0} | \psi \rangle}{\sqrt{P(q[0] = 0)}} = \frac{\frac{1}{2}(|000\rangle + |011\rangle)}{\sqrt{\frac{1}{2}}} = \frac{|000\rangle + |100\rangle}{\sqrt{2}}\)

Again, the first two qubits have collapsed to the same state, this time \(|0\rangle\). The third is still in superposition.


That’s the sums. Let’s see what happens when we run this on one of IBM Quantum’s computers. The circuit that establishes the state above and measures \(q[0]\), \(q[1]\), and \(q[2]\) (in that order) is as follows:

The OpenQASM code (auto generated) is:

include ""

qreg q[3];
creg c[3];

reset q[0];
reset q[1];
reset q[2];
h q[0];
h q[2];
cx q[0], q[1];
measure q[0] -> c[0];
measure q[1] -> c[1];
measure q[2] -> c[2];

Results following 1,000 runs on ibmq_lima (a Falcon r4T):

Outcomes matched predictions for entanglement (\(q[0] = q[1]\)) on 92.3% of runs. Of these, 48.3% were both 1s (versus both 0s), 95% CI = [45.0, 51.6], which is compatible with the 50-50 split we would expect. However, \(q[2] = 1\) on 42% of those entangled trials, which is statistically significantly lower than the predicted 50% (95% CI = [39.1, 45.5]).

Second time lucky, in case that was a fluke:

The bar chart looks a little more symmetrical. This time on correctly entangled runs, \(q[2] = 1\) across 47.5% of those runs. This wasn’t statistically significantly different to 50% (95% CI = [44.3, 50.8]) so it’s compatible with what we expect. But maybe this series of runs was a fluke…?

Another time, with 10,000 runs: \(q[2] = 1\) across 46.2% of correctly entangled runs (95% CI = [45.2, 47.3]). So it seems possible there is some bias on ibmq_lima.

I tried again on another computer: ibm_oslo (a Falcon r5.11H). Now with 20,000 runs – the maximum allowed in one booking. The outcomes for \(q[0]\) and \(q[1]\) were the same (i.e., as predicted) on 93.9% of runs. Of those, \(q[2] = 1\) on 50.1% of runs and this was not statistically significantly different to 50%, 95% CI = [49.4, 50.8].

Digression on quantum randomness

At this point I began to suspect that I’m not the first person to investigate bias. Tamura and Shikano (2021) ran a series of random number generator tests on measurements on a 20 qubit computer, IBM 20Q Poughkeepsie, obtaining 4,743,168 samples for each qubit. The circuit had a Hadmard gate, establishing the state

\(\displaystyle H|0\rangle = \frac{|0\rangle + |1\rangle}{\sqrt{2}}\).

The bias is already visible from their Figure 3, without examining the tests (though note the y-axis range – it’s not as bad as it first looks). The Born rule would predict results around 0.5:

So it looks like Poughkeepsie is an imperfect implementation.

I tried the same circuit on ibm_oslo with 10,000 runs on 7 qubits:

Here are the results:

0 1 % of 1s Lower CI Upper CI CI inc. 50%
c[0] 5078 4922 49.2 48.2 50.2 TRUE
c[1] 4852 5148 51.5 50.5 52.5 FALSE
c[2] 5065 4935 49.4 48.4 50.3 TRUE
c[3] 4963 5037 50.4 49.4 51.4 TRUE
c[4] 5092 4908 49.1 48.1 50.1 TRUE
c[5] 5025 4975 49.8 48.8 50.7 TRUE
c[6] 4797 5203 52.0 51.0 53.0 FALSE

Looking only at the marginal frequencies, that looks random enough… Two of the 95% CIs didn’t include 50%, perhaps due to a fluke. There are a dozen other properties we would want to check (see Tamura and Shikano, 2021) . But I’ll stop there.

This illustrates that imperfect implementations of quantum theory (and an imperfect universe, perhaps!) means we can’t assume that random sequences generated by a quantum process will be any more random than a pseudorandom generator – even if the theory says they will be. We need to check. This is another illustration of the role of implementation in trustworthiness that arose when exploring the BB84 quantum key distribution protocol. BB84 is perfectly secure in theory, but lots of extra work is needed to take account of imperfect implementation.


Matuschak, A., & Nielsen, M. A. (2020). Quantum Mechanics Distilled.

Tamura, K., & Shikano, Y. (2021). Quantum Random Numbers Generated by a Cloud Superconducting Quantum Computer. In T. Takagi, M. Wakayama, K. Tanaka, N. Kunihiro, K. Kimoto, & Y. Ikematsu (Eds.), International Symposium on Mathematics, Quantum Theory, and Cryptography (Vol. 33, pp. 17–37). Springer Singapore.