Quantum Information Processing: Foundations - Part 4
In part 3 of this series, we talked briefly about an important term in quantum computing called entanglement, which we said could be gotten when a CNOT gate acts on superposed qubits. We will expand on this in this…
In
part 3
of this series, we talked briefly about an important term in quantum computing called entanglement, which we said could be gotten when a CNOT gate acts on superposed qubits. We will expand on this in this article and, as usual, buttress our explanation with worked examples. Most of them come from (Rieffel, E. G. & Polak, W. H., 2014), and we will check every answer with cirq code.
Prerequisite
As with all articles in this series, a working knowledge of high/secondary school math is needed to understand quantum mechanics. Also, if you want to understand the checks we write using cirq and/or qiskit, Python programming or related language's knowledge is needed. The tensor product and the CNOT gate, both treated in
part 3
, will be used heavily here.
What really is quantum entanglement?
A little history
In 1935, Albert Einstein, Boris Podolsky and Nathan Rosen published a paper asking whether quantum mechanics gives a complete description of reality (Einstein, A. et al., 1935). Their argument, now called the EPR paradox, rested on pairs of particles whose properties are tied together so tightly that measuring one seems to settle the other at once, however far apart they are. To them, this suggested that something was missing from the theory. Einstein later called the effect "spooky action at a distance" in a letter to Max Born (Born, M. (Ed.)., 1971).
The same year, Erwin Schrödinger gave the phenomenon its name, Verschränkung in German and entanglement in English. He went further than Einstein and described it as "the characteristic trait of quantum mechanics" (Schrödinger, E., 1935). Almost thirty years later, John Bell showed that the question could be settled by experiment (Bell, J. S., 1964). The experiments came, and in 2022 Alain Aspect, John Clauser and Anton Zeilinger received the Nobel Prize in Physics for experiments with entangled photons that confirmed the predictions of quantum mechanics (The Royal Swedish Academy of Sciences., 2022).
That is the story. Now, we will see what entanglement actually is, using the math we already have.
Two qubits that mind their own business
Suppose we have two qubits, each prepared on its own:
∣u⟩=α0∣0⟩+α1∣1⟩,∣v⟩=β0∣0⟩+β1∣1⟩
Recall from
part 3
that the state of both qubits together is their tensor product, ∣u⟩⊗∣v⟩. To expand it, we multiply every term in the first bracket by every term in the second, exactly as we would expand (p+q)(r+s)=pr+ps+qr+qs in school algebra:
Two more rules tidy this up. Plain numbers can be moved to the front of a tensor product, and ∣x⟩⊗∣y⟩ is written in short as ∣xy⟩. So, α0∣0⟩⊗β0∣0⟩=α0β0∣00⟩, and the same for the other three terms:
Keep this expansion in mind; everything in the next section comes from it. A state of this kind is called a product state (or separable state). Each qubit has a state of its own, and whatever we do to one leaves the other untouched. If we measure the first qubit, the result tells us nothing about the second.
When the qubits cannot be separated
A general two-qubit state has four amplitudes, one for each basis state:
∣ψ⟩=a∣00⟩+b∣01⟩+c∣10⟩+d∣11⟩
Here, a, b, c and d are numbers (amplitudes), not states. The question is: can every such state be written as ∣u⟩⊗∣v⟩ for some single-qubit states ∣u⟩ and ∣v⟩? No, and that is the whole point of this article. A state that cannot be written as a product of single-qubit states is called entangled (Nielsen, M. A. & Chuang, I. L., 2010).
To decide which states are products, we compare the general state with the expansion of ∣u⟩⊗∣v⟩ from the previous section, one basis state at a time. Two states are equal only when the amplitude of every basis state matches:
Basis state
Amplitude in ∣ψ⟩
Amplitude in ∣u⟩⊗∣v⟩
∣00⟩
a
α0β0
∣01⟩
b
α0β1
∣10⟩
c
α1β0
∣11⟩
d
α1β1
So, if ∣ψ⟩ is a product state, then:
a=α0β0,b=α0β1,c=α1β0,d=α1β1
Now, multiply the first amplitude by the last, and the two middle ones together:
The order in which numbers are multiplied does not matter, so both lines end in the same product of the same four numbers! Therefore, every product state satisfies:
ad−bc=0
The reverse is also true: if ad−bc=0, the state can be split into two single-qubit states. Let us prove it, because the proof shows how to find the two states. Suppose ad=bc.
If a=0, we may divide by a, which gives d=abc. Now, try the product (∣0⟩+ac∣1⟩)⊗(a∣0⟩+b∣1⟩) and expand it with the same rule as before:
That is exactly ∣ψ⟩, written as a product. The two factors are not normalized, but this does not matter: multiplying the first factor by any number k and dividing the second by the same k leaves the product unchanged, so k can always be chosen to give both factors length 1.
If a=0, then ad−bc=0 becomes −bc=0, so b=0 or c=0. When b=0, the state is c∣10⟩+d∣11⟩=∣1⟩⊗(c∣0⟩+d∣1⟩). Otherwise c=0, and the state is b∣01⟩+d∣11⟩=(b∣0⟩+d∣1⟩)⊗∣1⟩. Both are products.
In every case, ad−bc=0 gives a product state. Together with the first half, this gives us a simple test for two qubits:
A two-qubit state a∣00⟩+b∣01⟩+c∣10⟩+d∣11⟩ is entangled if and only if ad−bc=0.
If you have done some linear algebra, you may recognize ad−bc as the determinant of the matrix [acbd]. Let us try the test on two states, step by step.
First, ∣+⟩∣+⟩, where both qubits are in an equal superposition. Recall that:
∣+⟩=21∣0⟩+21∣1⟩
So, both qubits have α0=α1=β0=β1=21. Using the expansion of ∣u⟩⊗∣v⟩, each amplitude of the pair is a product of two of these numbers, and 21⋅21=(2)21=21:
Not entangled, as expected, since we built it as a product.
Next, the state we obtained at the end of
part 3
:
∣Φ+⟩=2∣00⟩+∣11⟩=21∣00⟩+21∣11⟩
The basis states ∣01⟩ and ∣10⟩ do not appear at all. A basis state that does not appear has an amplitude of 0, so, writing all four terms out:
∣Φ+⟩=21∣00⟩+0∣01⟩+0∣10⟩+21∣11⟩
Reading off the amplitudes as before:
a=21,b=0,c=0,d=21
Substituting them into the test:
ad−bc=21⋅21−0⋅0=21−0=21=0
Entangled! Since every product state gives 0, no choice of ∣u⟩ and ∣v⟩ can ever produce ∣Φ+⟩.
We can also see this directly from the table above, without the test. For ∣Φ+⟩ to be ∣u⟩⊗∣v⟩, we would need α0β0=21 and α1β1=21, so none of α0, β0, α1 and β1 can be 0. But we would also need α0β1=0, which is only possible if α0=0 or β1=0. Both demands cannot hold at the same time.
The four Bell states
∣Φ+⟩ belongs to a family of four states named after John Bell. They are called the Bell states or EPR pairs (Nielsen, M. A. & Chuang, I. L., 2010):
In the Φ states, the two qubits always agree (00 or 11). The Ψ states, on the other hand, always disagree (01 or 10). The sign in the middle is the relative phase we met with the Z-gate in
part 3
. All four are entangled; for each of them, one of ad and bc is ±21 and the other is 0.
Each of them comes from the same small circuit: a Hadamard on the first qubit, then a CNOT with the first qubit as the control. Only the input changes:
Bell-state circuit Six components joined by five nets, carrying quantum signals.
We need three facts from
part 3
. First, H∣0⟩=2∣0⟩+∣1⟩ and H∣1⟩=2∣0⟩−∣1⟩. Second, the CNOT leaves the target alone when the control is 0 and flips it when the control is 1: ∣00⟩→∣00⟩, ∣01⟩→∣01⟩, ∣10⟩→∣11⟩ and ∣11⟩→∣10⟩. Third, gates are linear, so a gate acting on a sum acts on each term separately.
Now, we will not take the table on trust. Here is each input, gate by gate. The H only touches the first qubit, and the second qubit comes along unchanged.
In each line, the CNOT step only changes the terms whose first qubit is 1: their second qubit flips. The table below collects the four results:
Input ∣xy⟩
After H on the first qubit
After CNOT
∣00⟩
2∣00⟩+∣10⟩
∣Φ+⟩
∣01⟩
2∣01⟩+∣11⟩
∣Ψ+⟩
∣10⟩
2∣00⟩−∣10⟩
∣Φ−⟩
∣11⟩
2∣01⟩−∣11⟩
∣Ψ−⟩
There is a second, very useful way to read this table: backwards. Both gates undo themselves. For H, we showed H2=I in
part 3
. As for CNOT, applying it twice to ∣c,t⟩ gives:
∣c,t⟩CNOT∣c,t⊕c⟩CNOT∣c,(t⊕c)⊕c⟩=∣c,t⟩
since c⊕c=0, one of the XOR properties from
part 3
. To undo a circuit, the gates are undone in the reverse order: the last gate applied is the first one undone. So, applying CNOT first and then H takes each Bell state back to the basis state it came from. For example:
The last step uses H(2∣0⟩+∣1⟩)=H∣+⟩=∣0⟩, also from
part 3
. We will rely on this in the worked examples to "measure in the Bell basis".
What makes entanglement strange
Now, suppose both qubits of ∣Φ+⟩ are measured in the computational basis. By the Born rule (Born, M., 1926), the probability of each outcome is the squared size of its amplitude. Using the amplitudes we read off earlier (a=d=21 and b=c=0):
So, each qubit on its own is a fair coin: 0 half the time, 1 the other half. Yet the two coins always land the same way. If the first qubit gives 0, only the term ∣00⟩ is consistent with that result, so the state has collapsed to ∣00⟩, and the second qubit will give 0 with certainty, even if it has been carried to the other side of the world in the meantime.
You may object that there is nothing quantum about this. Bell himself told the story of his colleague, Reinhold Bertlmann, who always wore socks of different colours (Bell, J. S., 1981). If you see that one of his socks is pink, you know at once that the other is not pink. Nothing travelled from one sock to the other; the colours were fixed in the morning when he dressed. Perhaps the qubits also "decide" their values when they are created, and the measurement only reveals them?
Socks, however, have a harder time with the next fact. We will rewrite ∣Φ+⟩ in the Hadamard basis, {∣+⟩,∣−⟩}. First, we need ∣0⟩ and ∣1⟩ in terms of ∣+⟩ and ∣−⟩. Adding and subtracting the definitions ∣+⟩=2∣0⟩+∣1⟩ and ∣−⟩=2∣0⟩−∣1⟩:
Adding the two lines, the ∣+−⟩ and ∣−+⟩ terms cancel, while the ∣++⟩ and ∣−−⟩ terms double:
∣00⟩+∣11⟩=21(2∣++⟩+2∣−−⟩)=∣++⟩+∣−−⟩
Dividing both sides by 2:
∣Φ+⟩=2∣00⟩+∣11⟩=2∣++⟩+∣−−⟩
The two qubits agree in the Hadamard basis as well! Even so, socks could imitate this. Each pair might leave the factory with two hidden instructions, one for each question, fixed before anyone looks. That is close to what Einstein, Podolsky and Rosen believed: the answers exist all along, and quantum mechanics simply fails to describe them (Einstein, A. et al., 1935). Bell's insight was to ask questions in between the two bases (Bell, J. S., 1964). David Mermin later turned Bell's argument into a version that needs nothing more than counting (Mermin, N. D., 1981), and we will follow it here.
First, we need a way to measure a qubit "at an angle". Recall from
part 2
that a qubit state is a point on the Bloch sphere. The rotation about the y-axis of the sphere is the gate (Nielsen, M. A. & Chuang, I. L., 2010):
Ry(θ)=[cos2θsin2θ−sin2θcos2θ]
Multiplying it by ∣0⟩=[10] picks out its first column, and multiplying by ∣1⟩=[01] picks out its second column:
Two quick examples. With θ=0, cos0=1 and sin0=0, so Ry(0)=[1001]=I. Taking θ=2π instead, cos4π=sin4π=21, so Ry(2π)∣0⟩=21∣0⟩+21∣1⟩=∣+⟩.
"Measuring at angle $\theta$" means asking whether the *qubit* is in $R_y(\theta)\ket{0}$ or in $R_y(\theta)\ket{1}$. For $\theta=0$, these are $\ket{0}$ and $\ket{1}$, the computational basis. When $\theta=\frac{\pi}{2}$, they are $\ket{+}$ and $\frac{-\ket{0}+\ket{1}}{\sqrt{2}}=-\ket{-}$, which is $\ket{-}$ up to a global phase, so this is the Hadamard basis. Hardware, however, only measures in the computational basis. The trick is to rotate the *qubit* back by $-\theta$ first. Since $\cos(-x)=\cos x$ and $\sin(-x)=-\sin x$:
Ry(−θ)=[cos2θ−sin2θsin2θcos2θ]
Writing c=cos2θ and s=sin2θ to save space, and using c2+s2=1:
So, Ry(−θ) sends Ry(θ)∣0⟩ back to ∣0⟩ and Ry(θ)∣1⟩ back to ∣1⟩. After it, the question "Ry(θ)∣0⟩ or Ry(θ)∣1⟩?" has become "∣0⟩ or ∣1⟩?", which an ordinary measurement answers.
Now, suppose the first qubit of ∣Φ+⟩ is measured at angle θA and the second at angle θB. That means applying Ry(−θA) to the first qubit and Ry(−θB) to the second, then measuring both normally. To keep the expressions short, write:
The trigonometric identities cos(x−y)=cosxcosy+sinxsiny and sin(x−y)=sinxcosy−cosxsiny (Wikipedia., 2025) tidy this up. With x=2θA, y=2θB and Δ=2θA−θB:
We can test it on what we already know. Equal angles give Δ=0 and cos20=1: the results always agree, which covers both bases we have seen. Angles 90∘ apart give Δ=45∘, and since cos45∘=21, Psame=21: the results are unrelated.
Next, let each side pick one of three angles, 0∘, 120∘ or 240∘, at random and independently. With three choices on each side, there are 3×3=9 equally likely pairs of angles. In 3 of them, both sides pick the same angle, so the probability of equal angles is 93=31, and then the results always agree. In the other 6 (probability 96=32), the angles differ by ±120∘ or ±240∘, so Δ is ±60∘ or ±120∘. Since cos60∘=21 and cos120∘=−21, and squaring removes the sign, cos2Δ=41 in every one of these cases. On average:
Psame=31⋅1+32⋅41=31+61=62+61=63=21
What would socks do? Each pair would carry a ready answer for each of the three angles, the same for both socks, since they must agree whenever the angles are equal. Take the instruction "0 at 0∘, 0 at 120∘, 1 at 240∘" and list the nine equally likely choices of angles:
First angle
Second angle
Answers
Same?
0∘
0∘
0,0
yes
0∘
120∘
0,0
yes
0∘
240∘
0,1
no
120∘
0∘
0,0
yes
120∘
120∘
0,0
yes
120∘
240∘
0,1
no
240∘
0∘
1,0
no
240∘
120∘
1,0
no
240∘
240∘
1,1
yes
That is 5 out of 9. Three answers, each 0 or 1, can only come in two patterns. Either all three are equal, and then all 9 pairs agree. Or two are equal and one is different, as in the table. Then the pairs that agree are the 3 with equal angles, plus the 2 that use the two angles with equal answers in either order: 5 in total. So, however the socks are made, they agree at least 95≈0.56 of the time. Quantum mechanics predicts 21=0.5, which is less. No set of answers written in advance can produce what ∣Φ+⟩ produces. This is the heart of Bell's theorem, and the experiments honoured by the 2022 Nobel Prize found that nature agrees with quantum mechanics (The Royal Swedish Academy of Sciences., 2022).
Before we get carried away, one thing entanglement cannot do is carry a message. The state above shows why. The second qubit gives 0 for the outcomes 00 and 10, so its probability of giving 0 is:
2cosΔ2+−2sinΔ2=2cos2Δ+sin2Δ=21
since cos2Δ+sin2Δ=1. Whatever angle the first person chooses, the second person, looking only at their own qubit, sees 0 half of the time and 1 half of the time. The correlation only appears when the two lists of results are brought together and compared, and that comparison travels by ordinary means (Nielsen, M. A. & Chuang, I. L., 2010).
How much entanglement?
Not all entangled states are equally entangled. For a two-qubit state a∣00⟩+b∣01⟩+c∣10⟩+d∣11⟩, a common measure is the concurrence, defined by William Wootters (Wootters, W. K., 1998) as:
C=2∣ad−bc∣
It is built on the same quantity as our test, so it is 0 exactly for product states. How large can it get? Two facts from school algebra settle this. First, the size of a difference is at most the sum of the sizes: ∣ad−bc∣≤∣a∣∣d∣+∣b∣∣c∣. Second, for any real numbers x and y, (x−y)2≥0, which expands to x2−2xy+y2≥0, so xy≤2x2+y2. Applying the second fact to ∣a∣∣d∣ and to ∣b∣∣c∣:
The last step holds because the probabilities of all four outcomes add up to 1. Therefore, C=2∣ad−bc∣≤2⋅21=1. The concurrence runs from 0 for product states to 1 for the most entangled ones. For ∣Φ+⟩, we found ad−bc=21, so:
C=2⋅21=1
It reaches the largest possible value. The Bell states are, therefore, maximally entangled. We will meet a state in between in Q3.
The Bell states as a basis
Just like ∣00⟩, ∣01⟩, ∣10⟩ and ∣11⟩, the four Bell states have length 1 (for example, 212+212=1 for ∣Φ+⟩), and no two of them overlap. So, any two-qubit state can be written in terms of them. In particular, adding and subtracting pairs of Bell states gives back the basis states. Adding ∣Φ+⟩ and ∣Φ−⟩, the ∣11⟩ terms cancel:
Keep these four results close. They are the key to Q4 and Q5.
Worked examples
Q1:
Compute (H⊗H⊗⋯⊗H)∣0n⟩.
Solution
Here, ∣0n⟩ is short for nqubits, all in ∣0⟩:
∣0n⟩=n times∣0⟩⊗∣0⟩⊗⋯⊗∣0⟩=∣0⟩⊗n
In the same way, H⊗n is short for H⊗H⊗⋯⊗H, one H for each qubit. A tensor product of gates acts on a tensor product of states one factor at a time: the first gate acts on the first qubit, the second gate on the second qubit, and so on. In symbols, (A⊗B)(∣x⟩⊗∣y⟩)=A∣x⟩⊗B∣y⟩.
We can check this rule against the matrix of H⊗I from Q2 of
part 3
. Multiplying a matrix by ∣00⟩=[1000]T picks out its first column, which for H⊗I is 21[1010]T=2∣00⟩+∣10⟩. The rule gives the same answer: H∣0⟩⊗I∣0⟩=2∣0⟩+∣1⟩⊗∣0⟩=2∣00⟩+∣10⟩.
So, each H meets one ∣0⟩:
H⊗n∣0⟩⊗n=H∣0⟩⊗H∣0⟩⊗⋯⊗H∣0⟩
Recall that H∣0⟩=2∣0⟩+∣1⟩=∣+⟩. Substituting it n times:
H⊗n∣0n⟩=2∣0⟩+∣1⟩⊗2∣0⟩+∣1⟩⊗⋯⊗2∣0⟩+∣1⟩
Each of the n factors carries a 21, and numbers can be moved to the front of a tensor product. The n copies multiply to (21)n=(2)n1=2n1, since raising 2 to the power n is the same as taking the square root of 2n. Therefore:
Look at how each term was formed: we picked either ∣0⟩ or ∣1⟩ from the first bracket, and either ∣0⟩ or ∣1⟩ from the second. Every possible way of picking gives one term, so every two-bit string appears exactly once, each with the same amplitude, 21.
The same happens for any n. Expanding n brackets means picking ∣0⟩ or ∣1⟩ from each of them. That is 2 choices, n times over, or 2×2×⋯×2=2n ways in total, and each way spells out a different n-bit string. For n=3, the 23=8 strings ∣000⟩,∣001⟩,…,∣111⟩ each appear once, with amplitude 231=81. In general:
∴H⊗n∣0n⟩=2n1x∈{0,1}n∑∣x⟩
Here, {0,1}n is the set of all strings of n bits, and ∑x∈{0,1}n∣x⟩ means "add ∣x⟩ for every such string x". With only n gates, we have put nqubits into an equal superposition of 2n states. This is the opening move of many quantum algorithms, including the Deutsch-Jozsa algorithm.
Now, is this state entangled? It looks impressive, but no. We built it as ∣+⟩⊗∣+⟩⊗⋯⊗∣+⟩, so it is a product state by construction. For n=2, it is exactly the state ∣+⟩∣+⟩ we tested in
When the qubits cannot be separated
, with a=b=c=d=21, and there we found ad−bc=41−41=0.
Superposition and entanglement are different things. A state can hold all 2n bit strings at once and still be a simple product of n independent qubits. Entanglement needs gates that act on two or more qubits together, such as CNOT.
Check
check.py
python
1import cirq
2import numpy as np
3
4for n in (1, 2, 3, 4):
5 qubits = cirq.LineQubit.range(n)
6
7# Apply H to every qubit of |00...0>
8 circuit = cirq.Circuit(cirq.H.on_each(*qubits))
9 state = cirq.Simulator().simulate(circuit, qubit_order=qubits).final_state_vector
10
11# Every one of the 2^n amplitudes should equal 1/sqrt(2^n)
22print(f"n = {n}: all {2**n} amplitudes equal {1 / np.sqrt(2**n):.4f}")
Q2:
Show the quantum circuits that generate the n-qubit GHZ state, 21(∣00…0⟩+∣11…1⟩), and the n-qubit W state, n1(∣10…0⟩+∣01…0⟩+⋯+∣00…1⟩), from ∣0n⟩.
Some texts call the second state the Werner state. The usual name is the W state (Dür, W. et al., 2000). A Werner state is something else: a mixture of a Bell state and pure noise, introduced by Reinhard Werner (Werner, R. F., 1989).
Solution
Both states spread entanglement across more than two qubits, but in very different ways. The GHZ state, named after Daniel Greenberger, Michael Horne and Anton Zeilinger (Greenberger, D. M. et al., 1989), is "all or nothing": every qubit is 0, or every qubit is 1. In the W state, exactly one qubit is 1, and that 1 is shared equally among all the positions.
(i) GHZ state
GHZ is the Bell state ∣Φ+⟩ grown to nqubits, so we build it the same way. First, apply H to the first qubit and leave the rest alone (the identity, I, on each of the other n−1qubits). By the rule from Q1, each gate acts on its own qubit:
The first qubit is now in superposition while the rest are ∣0⟩. We call the two terms branches. Next, we apply CNOT gates with the first qubit as the control. Recall that a CNOT flips its target only when its control is 1. We will follow n=3 to see what happens:
In the first branch, the first qubit is 0, so neither CNOT does anything, and ∣000⟩ stays as it is. In the second branch, the first qubit is 1, so CNOT1,2 flips the second qubit (∣100⟩→∣110⟩) and CNOT1,3 flips the third (∣110⟩→∣111⟩). Each CNOT copies the value of the first qubit onto one more qubit. For nqubits, we continue until every qubit has been reached:
The control of each CNOT does not have to be the first qubit. After CNOT1,2, the second qubit holds the same value as the first in each branch (0 in the first branch and 1 in the second). So, CNOT2,3 flips the third qubit in exactly the same branch as CNOT1,3 would. Chaining them like this, each qubit controlling the next, is common on hardware where only neighbouring qubits can interact (Cruz, D. et al., 2019). For three qubits, the chained version looks like this:
GHZ-state circuit for three qubits Nine components joined by eight nets, carrying quantum signals.
The GHZ state is fragile in an interesting way. Suppose one qubit is measured and gives 0. Of the two branches, only ∣0n⟩ has a 0 in that position, so the state collapses to ∣0n⟩. That is a product state, so none of the remaining qubits is entangled any more. A single measurement destroys all of it.
(ii) W state
The W state needs a different idea, because its amplitudes are n1, not 21. Our approach is to start with a single 1 on the first qubit and pass it down the line. At each qubit, a fair share is left behind and the rest is passed on.
We need a gate that splits a qubit between ∣0⟩ and ∣1⟩ in any proportion we like. The rotation Ry(θ), which we met in
What makes entanglement strange
, does exactly this, since Ry(θ)∣0⟩=cos2θ∣0⟩+sin2θ∣1⟩. By choosing θ, we choose how the amplitude is split. We also need the inverse cosine, arccos: arccosy is the angle whose cosine is y. Now, we build ∣W3⟩=31(∣100⟩+∣010⟩+∣001⟩) step by step.
We begin with an X-gate on the first qubit, which turns ∣000⟩ into ∣100⟩. The single 1 sits on the first qubit.
In the first step, the first qubit should keep 31 of the probability, and so end with amplitude 31, while the remaining 32 moves on. We use two gates for this. A controlled-Ry(θ1), with the first qubit as the control, rotates the second qubit only when the first is ∣1⟩. In ∣100⟩, it is ∣1⟩, so the second qubit turns from ∣0⟩ into Ry(θ1)∣0⟩:
Then a CNOT with the second qubit as the control and the first as the target clears the first qubit wherever the second has become 1. In ∣100⟩, the control (second qubit) is 0, so nothing happens. In ∣110⟩, the control is 1, so the first qubit flips from 1 to 0, giving ∣010⟩:
cos2θ1∣100⟩+sin2θ1∣010⟩
The amplitude of ∣100⟩ must be 31, so:
cos2θ1=31⟹2θ1=arccos31≈0.9553 rad⟹θ1≈1.9106 rad
The other amplitude follows from cos2x+sin2x=1:
sin2θ1=1−cos22θ1=1−31=32
So, after the first step, the state is 31∣100⟩+32∣010⟩. The first qubit has its share, and the remaining (32)2=32 of the probability now sits on the second qubit.
In the second step, we repeat the move between the second and third qubits: a controlled-Ry(θ2) from the second qubit to the third, then a CNOT from the third to the second. In ∣010⟩, the second qubit is 1, so the rotation acts and turns the third qubit into Ry(θ2)∣0⟩. The CNOT then clears the second qubit wherever the third has become 1:
since cos4π=21. Then sin2θ2=sin4π=21 as well, and both of the last two amplitudes are 32⋅21=62=31=31. So, the final state is:
31∣100⟩+31∣010⟩+31∣001⟩=31(∣100⟩+∣010⟩+∣001⟩)=∣W3⟩W-state circuit for three qubits 11 components joined by 12 nets, carrying quantum signals.
For nqubits, the same move is repeated n−1 times, and the angles follow the same reasoning. Before step k (counting from 1), the first k−1qubits have each kept their share, n1 of the probability. The probability still travelling is therefore 1−nk−1=nn−k+1, which is an amplitude of nn−k+1, and it sits on qubitk. Qubitk should keep an amplitude of n1, so:
For n=3, k=1 gives θ1=2arccos31 and k=2 gives θ2=2arccos21=2π, as above. At the last step, k=n−1, the travelling amplitude is n2 and cos2θn−1=21, so it splits evenly between the last two qubits, n1 each. With n=2, there is a single angle, θ1=2arccos21=2π, and the circuit produces 2∣10⟩+∣01⟩=∣Ψ+⟩, a Bell state. This construction is the linear version of the one given by (Cruz, D. et al., 2019).
The W state behaves very differently from GHZ under loss. Suppose the first qubit of ∣W3⟩ is measured and gives 0. Only the terms ∣010⟩ and ∣001⟩ have a 0 in that position, so they are all that remains. Their probabilities, 31 each, add up to 32, so the state has to be rescaled to length 1 by dividing by 32. Each amplitude becomes 31÷32=31⋅23=21, and the other two qubits are left in 2∣10⟩+∣01⟩, which is still a Bell state. Dür, Vidal and Cirac showed that GHZ and W are two genuinely different kinds of three-qubit entanglement; no local operations can turn one into the other, even with some chance of failure (Dür, W. et al., 2000).
Check
check.py
python
1import cirq
2import numpy as np
3
4
5defghz_circuit(n):
6"""H on the first qubit, then a CNOT from the first qubit to every other qubit."""
7 q = cirq.LineQubit.range(n)
8return cirq.Circuit(cirq.H(q[0]), [cirq.CNOT(q[0], q[k]) for k inrange(1, n)]), q
9
10
11defw_circuit(n):
12"""Start from |10...0> and pass the 1 down the line, leaving a share behind at each step."""
13 q = cirq.LineQubit.range(n)
14 circuit = cirq.Circuit(cirq.X(q[0]))
15for k inrange(n - 1):
16# Keep a share 1/(n-k) of what is left on qubit k, pass the rest to qubit k+1
Design a circuit that constructs the state ∣ψ⟩=121(3∣00⟩+∣01⟩+∣10⟩+∣11⟩).
Solution
Before designing anything, we should determine what kind of state this is. Moving 121 into each term, the amplitudes are the numbers in front of the basis states:
∣ψ⟩=123∣00⟩+121∣01⟩+121∣10⟩+121∣11⟩
so a=123, b=121, c=121 and d=121. As a sanity check, the state is normalized, since the squared amplitudes add up to 1:
The state is entangled, so we will need a two-qubit gate. Its concurrence is:
C=2∣ad−bc∣=2⋅61=31
It is entangled, but much less than a Bell state, whose concurrence is 1.
The plan is to prepare the first qubit first, and then prepare the second qubit differently depending on the first. To do that, we group the terms by the value of the first qubit. The terms 3∣00⟩ and ∣01⟩ both start with ∣0⟩, so ∣0⟩ can be taken out as a common factor, the reverse of expanding a bracket: 3∣00⟩+∣01⟩=∣0⟩⊗(3∣0⟩+∣1⟩). In the same way, ∣10⟩+∣11⟩=∣1⟩⊗(∣0⟩+∣1⟩). Therefore:
∣ψ⟩=121(∣0⟩⊗(3∣0⟩+∣1⟩)+∣1⟩⊗(∣0⟩+∣1⟩))
The two brackets are not valid single-qubit states yet, because their lengths are not 1. Recall from
part 1
that the length of x∣0⟩+y∣1⟩ is ∣x∣2+∣y∣2. So, 3∣0⟩+∣1⟩ has length 32+12=10, and ∣0⟩+∣1⟩ has length 12+12=2. Dividing each bracket by its length, and multiplying by the same number outside so that nothing changes:
We can confirm that the pieces are consistent. The first qubit is in α∣0⟩+β∣1⟩, a valid state, because α2+β2=1210+122=1. The bracket γ∣0⟩+δ∣1⟩ is valid too, because γ2+δ2=109+101=1. Multiplying back gives the original amplitudes:
This calls for a gate that acts only when the control is ∣0⟩. It is drawn with an open (hollow) circle on the control. It works like a normal controlled gate with an X-gate on the control wire before and after it: the first X turns a control of ∣0⟩ into ∣1⟩, so the gate fires, and the second X turns the control back.
Third, when the first qubit is ∣1⟩, put the second into 2∣0⟩+∣1⟩. Since H∣0⟩=2∣0⟩+∣1⟩, that is simply a controlled-H.
We can follow the state through. Both qubits start in ∣0⟩. The first step only touches the first qubit:
Ry(θ1)∣0⟩⊗∣0⟩=(α∣0⟩+β∣1⟩)⊗∣0⟩=α∣00⟩+β∣10⟩
The second step fires only where the first qubit is 0, that is, on α∣00⟩, and turns its second qubit into Ry(θ2)∣0⟩=γ∣0⟩+δ∣1⟩. The third step fires only where the first qubit is 1, on β∣10⟩, and turns its second qubit into H∣0⟩:
Circuit for (3|00⟩ + |01⟩ + |10⟩ + |11⟩)/√12 Seven components joined by seven nets, carrying quantum signals.
The same recipe works for any two-qubit state: rotate the first qubit, then prepare the second with one gate controlled on ∣0⟩ and another controlled on ∣1⟩.
24print("ad - bc =", round(a * d - b * c, 4), "(not zero, so the state is entangled)")
25print("concurrence =", round(2 * abs(a * d - b * c), 4))
26print(circuit)
Q4:
Verify the entanglement-swapping protocol: given two Bell pairs, AB and CD, show that the teleportation protocol applied to the qubits B, C and D yields a Bell pair on the qubits A and D.
Solution
First, we put people to the qubits. Alice holds A and Dave holds D. Bob created the pair AB and sent A to Alice; Carol created the pair CD and sent D to Dave. Later, the two of them meet in the middle with B and C. Alice and Dave have never met, and their qubits have never interacted. The claim is that a single measurement in the middle, by Bob and Carol, leaves Alice and Dave holding a Bell pair. This is called entanglement swapping, and it was proposed by Żukowski and colleagues in 1993 (Żukowski, M. et al., 1993).
Entanglement swapping 16 components joined by 17 nets, carrying classical and quantum signals.
The two pairs are ∣Φ+⟩ states. Each qubit carries its letter as a subscript, so we always know which is which:
The four qubits together are in the tensor product of the two. We expand it exactly as in the first section, each term of the first bracket with each term of the second, and the two 21 factors multiply to 21:
Bob and Carol are going to measure B and C together in the Bell basis. So, we write the pair BC in the middle of each term and A and D on the outside. Since every qubit carries its label, changing the order in which we write them changes nothing. Reading the labels in each term:
Opening the four brackets gives eight terms. We now collect them by the Bell state of BC, moving it to the front of each term and leaving A and D together behind it:
∣Φ+⟩BC appears in the first bracket with ∣0A⟩…∣0D⟩ (sign +) and in the fourth with ∣1A⟩…∣1D⟩ (sign +). It therefore carries ∣Φ+⟩BC(∣0A0D⟩+∣1A1D⟩).
∣Φ−⟩BC appears in the first bracket with ∣0A⟩…∣0D⟩ (sign +) and in the fourth with ∣1A⟩…∣1D⟩ (sign −), so it carries ∣Φ−⟩BC(∣0A0D⟩−∣1A1D⟩).
∣Ψ+⟩BC appears in the second bracket with ∣0A⟩…∣1D⟩ (sign +) and in the third with ∣1A⟩…∣0D⟩ (sign +), which gives ∣Ψ+⟩BC(∣0A1D⟩+∣1A0D⟩).
∣Ψ−⟩BC appears in the second bracket with ∣0A⟩…∣1D⟩ (sign +) and in the third with ∣1A⟩…∣0D⟩ (sign −); the result is ∣Ψ−⟩BC(∣0A1D⟩−∣1A0D⟩).
Writing 221 as 21⋅21 and giving the 21 to each AD part:
We have not done anything to the qubits yet. This is the same state as before, written differently. Yet it already says everything: whichever Bell state Bob and Carol find on BC, Alice and Dave are left holding the matching Bell state on AD. Each of the four terms has amplitude 21 in front of states of length 1, so, by the Born rule, each outcome has probability 212=41, and the four probabilities add up to 1.
How do Bob and Carol measure "in the Bell basis"? In
The four Bell states
, we saw that running the Bell circuit backwards, a CNOT from B to C followed by H on B, takes each Bell state back to the basis state it came from. Reading the table there from right to left, with B as the first qubit and C as the second, ∣Φ+⟩→∣00⟩, ∣Ψ+⟩→∣01⟩, ∣Φ−⟩→∣10⟩ and ∣Ψ−⟩→∣11⟩. Bob and Carol then measure B and C normally and obtain two bits, mB and mC:
Bell state of BC
(mB,mC)
State of AD
Dave's correction
∣Φ+⟩
(0,0)
∣Φ+⟩
none
∣Φ−⟩
(1,0)
∣Φ−⟩
Z
∣Ψ+⟩
(0,1)
∣Ψ+⟩
X
∣Ψ−⟩
(1,1)
∣Ψ−⟩
X, then Z
If Alice and Dave want ∣Φ+⟩ every time, Bob and Carol phone Dave with the two bits, and Dave applies the correction in the last column to his qubit. Recall that X swaps ∣0⟩ and ∣1⟩, while Z leaves ∣0⟩ alone and changes ∣1⟩ into −∣1⟩. Each row can then be checked:
∣Φ−⟩AD=2∣0A0D⟩−∣1A1D⟩∣Ψ+⟩AD=2∣0A1D⟩+∣1A0D⟩∣Ψ−⟩AD=2∣0A1D⟩−∣1A0D⟩Z on D2∣0A0D⟩−(−∣1A1D⟩)=2∣0A0D⟩+∣1A1D⟩X on D2∣0A0D⟩+∣1A1D⟩X on D2∣0A0D⟩−∣1A1D⟩Z on D2∣0A0D⟩+∣1A1D⟩
Every row ends in ∣Φ+⟩AD. Notice that X is needed exactly when mC=1, and Z exactly when mB=1. These are the gates "X if mC=1" and "Z if mB=1" in the circuit above, applied in that order.
This verifies the protocol. Notice the phone call. Without the two bits, Dave cannot tell which of the four Bell states he shares with Alice, so nothing travels faster than light, just as we said earlier.
Why should anyone care? Entanglement fades over long optical fibres, so it cannot be sent directly across a continent. With swapping, short entangled links can be joined end to end, with a measurement at each junction, into one long link. Devices that do this are called quantum repeaters (Briegel, H.-J. et al., 1998). The first experiment, in 1998, swapped entanglement between photons that had never interacted (Pan, J.-W. et al., 1998).
Check
check.py
python
1import cirq
2import numpy as np
3
4A, B, C, D = cirq.LineQubit.range(4)
5
6circuit = cirq.Circuit(
7 cirq.H(A), cirq.CNOT(A, B), # Bell pair |Phi+> on A, B
8 cirq.H(C), cirq.CNOT(C, D), # Bell pair |Phi+> on C, D
9 cirq.CNOT(B, C), cirq.H(B), # Bell circuit run backwards on B, C
29print("A and D share |Phi+> for every outcome (mB, mC):", sorted(seen))
Q5:
Does the entanglement-swapping protocol generalize to the case where AB is an arbitrary entangled state? Prove or disprove.
Solution
Let A and B start in any two-qubit state:
∣ψ⟩AB=α∣0A0B⟩+β∣0A1B⟩+γ∣1A0B⟩+δ∣1A1B⟩
where the complex numbers α, β, γ and δ satisfy ∣α∣2+∣β∣2+∣γ∣2+∣δ∣2=1 (Born, M., 1926). C and D are still the Bell pair ∣Φ+⟩CD=2∣0C0D⟩+∣1C1D⟩. We follow exactly the steps of Q4, only with more bookkeeping.
First, the tensor product. Each of the four terms of ∣ψ⟩AB is multiplied by each of the two terms of ∣Φ+⟩CD, which gives 4×2=8 terms, all sharing the factor 21. For example, α∣0A0B⟩⊗∣1C1D⟩=α∣0A0B1C1D⟩. As in Q4, we write each term with BC in the middle; this one becomes α∣0A⟩∣01⟩BC∣1D⟩. All eight are:
These four lines tell us exactly where each Bell state comes from, and with which sign:
∣Φ+⟩ comes from ∣00⟩ (sign +) and from ∣11⟩ (sign +);
∣Φ−⟩ comes from ∣00⟩ (sign +) and from ∣11⟩ (sign −);
∣Ψ+⟩ comes from ∣01⟩ (sign +) and from ∣10⟩ (sign +);
∣Ψ−⟩ comes from ∣01⟩ (sign +) and from ∣10⟩ (sign −).
Every replacement also brings a 21, which joins the 21 already in front: 21⋅21=21. So, to collect, for example, all the ∣Φ+⟩BC terms, we take the ∣00⟩ row of the table and the ∣11⟩ row, both with a plus sign. To collect the ∣Φ−⟩BC terms, we take the ∣00⟩ row with a plus sign and the ∣11⟩ row with a minus sign, and so on:
Look at the first one. ∣ϕ+⟩AD is ∣ψ⟩ itself, with D in the place of B! Each of the four states has length 1, because its squared amplitudes are ∣α∣2, ∣±β∣2=∣β∣2, ∣γ∣2 and ∣±δ∣2=∣δ∣2, which add up to 1. So, as in Q4, each outcome has probability 212=41.
If Bob and Carol find ∣Φ+⟩BC, Alice and Dave already hold the original state. The other three are close relatives, and Dave's corrections from Q4 repair them. Recall that Z on D changes the sign of every term where D is 1, and X on D swaps 0D and 1D in every term:
∣ϕ−⟩AD∣χ+⟩AD∣χ−⟩ADZ on Dα∣0A0D⟩+β∣0A1D⟩+γ∣1A0D⟩+δ∣1A1D⟩X on Dα∣0A0D⟩+β∣0A1D⟩+γ∣1A0D⟩+δ∣1A1D⟩X on Dα∣0A0D⟩−β∣0A1D⟩+γ∣1A0D⟩−δ∣1A1D⟩Z on Dα∣0A0D⟩+β∣0A1D⟩+γ∣1A0D⟩+δ∣1A1D⟩
In the first line, the terms with 1D were −β and −δ, and Z turns them into +β and +δ. In the second, swapping 0D and 1D moves each amplitude to its proper place. The third combines the two.
∴ Once Bob and Carol have measured and Dave has corrected, A and D are always in:
α∣0A0D⟩+β∣0A1D⟩+γ∣1A0D⟩+δ∣1A1D⟩
which is the original state of AB, now living on AD. The protocol does generalize. In fact, it generalizes further than the question asks: the proof never used the fact that ∣ψ⟩AB was entangled. What the protocol really does is teleport B's part of the state onto D (Bennett, C. H. et al., 1993). If A and B are entangled, the entanglement goes along. Otherwise, B's state is simply teleported to Dave. As a special case, taking α=δ=21 and β=γ=0 gives back Q4.
25 state = result.final_state_vector.reshape(2, 2, 2, 2) # indices: A, B, C, D
26 ad = state[:, m_b, m_c, :].reshape(4)
27
28# A and D now hold the original state of A and B (up to a global phase)
29assert np.isclose(abs(np.vdot(psi, ad)), 1)
30 seen.add((m_b, m_c))
31
32print("A and D hold the original AB state for every outcome (mB, mC):", sorted(seen))
Outro
Enjoyed this article? I'm a Software Engineer and Technical Writer actively seeking new opportunities to impact and learn, particularly in areas related to web security, finance, healthcare, and education. If you think my expertise aligns with your team's needs, let's chat! You can find me on
LinkedIn
and
X
. I am also an
email
away.
Bennett, C. H., Brassard, G., Crépeau, C., Jozsa, R., Peres, A., & Wootters, W. K. (1993).Teleporting an unknown quantum state via dual classical and Einstein-Podolsky-Rosen channels.Physical Review Letters, 70(13), 1895-1899. https://doi.org/10.1103/PhysRevLett.70.1895
Briegel, H.-J., Dür, W., Cirac, J. I., & Zoller, P. (1998).Quantum repeaters: The role of imperfect local operations in quantum communication.Physical Review Letters, 81(26), 5932-5935. https://doi.org/10.1103/PhysRevLett.81.5932
Cruz, D., Fournier, R., Gremion, F., Jeannerot, A., Komagata, K., Tosic, T., Thiesbrummel, J., Chan, C. L., Macris, N., Dupertuis, M.-A., & Javerzac-Galy, C. (2019).Efficient quantum algorithms for GHZ and W states, and implementation on the IBM quantum computer.Advanced Quantum Technologies, 2(5-6), 1900015. https://doi.org/10.1002/qute.201900015
Dür, W., Vidal, G., & Cirac, J. I. (2000).Three qubits can be entangled in two inequivalent ways.Physical Review A, 62(6), 062314. https://doi.org/10.1103/PhysRevA.62.062314
Einstein, A., Podolsky, B., & Rosen, N. (1935).Can quantum-mechanical description of physical reality be considered complete?.Physical Review, 47(10), 777-780. https://doi.org/10.1103/PhysRev.47.777
Greenberger, D. M., Horne, M. A., & Zeilinger, A. (1989).Going beyond Bell's theorem.In M. Kafatos (Ed.), Bell's Theorem, Quantum Theory and Conceptions of the Universe (pp. 69-72). Kluwer Academic.
Mermin, N. D. (1981).Bringing home the atomic world: Quantum mysteries for anybody.American Journal of Physics, 49(10), 940-943. https://doi.org/10.1119/1.12594
Schrödinger, E. (1935).Discussion of probability relations between separated systems.Mathematical Proceedings of the Cambridge Philosophical Society, 31(4), 555-563. https://doi.org/10.1017/S0305004100013554
The Royal Swedish Academy of Sciences. (2022).The Nobel Prize in Physics 2022: Press release.NobelPrize.org. https://www.nobelprize.org/prizes/physics/2022/press-release/.
Werner, R. F. (1989).Quantum states with Einstein-Podolsky-Rosen correlations admitting a hidden-variable model.Physical Review A, 40(8), 4277-4281. https://doi.org/10.1103/PhysRevA.40.4277
Wootters, W. K. (1998).Entanglement of formation of an arbitrary state of two qubits.Physical Review Letters, 80(10), 2245-2248. https://doi.org/10.1103/PhysRevLett.80.2245
Żukowski, M., Zeilinger, A., Horne, M. A., & Ekert, A. K. (1993)."Event-ready-detectors" Bell experiment via entanglement swapping.Physical Review Letters, 71(26), 4287-4290. https://doi.org/10.1103/PhysRevLett.71.4287