More Related Content Similar to Quantum Computing 101, Part 2 - Hello Entangled World (20) Quantum Computing 101, Part 2 - Hello Entangled World1. Copyright © 2021 BigMother.AI CIC. All rights reserved. 1
Quantum Computing 101, Part 2 –
Hello Entangled World
Aaron Turner, March 2021
Introduction
This is the second part of a blog series on quantum computing, broadly derived from CERN’s
Practical introduction to quantum computing video series, Michael Nielson’s Quantum computing
for the determined video series, and the following (widely regarded as definitive) references:
• [Hidary] Quantum Computing: An Applied Approach
• [Nielsen & Chuang] Quantum Computing and Quantum Information [a.k.a. “Mike & Ike”]
• [Yanofsky & Mannucci] Quantum Computing for Computer Scientists
My objective is to keep the mathematics to an absolute minimum (albeit not quite zero), in order
to engender an intuitive understanding. You can think it as a quantum computing cheat sheet.
The Y gate (a.k.a. Pauli gate 𝝈𝒀)
The Y gate, defined as
Y = X(𝑒𝑖
𝜋
2 0
0 𝑒𝑖𝜋
𝑒𝑖
𝜋
2
) = X(
𝑖 0
0 −𝑖
) = (
0 1
1 0
) (
𝑖 0
0 −𝑖
) = (
0 −𝑖
𝑖 0
)
shifts the α0 and α1 amplitudes by phase factors of 𝑒𝑖
𝜋
2 = 𝑖 and 𝑒𝑖𝜋
𝑒𝑖
𝜋
2 = −𝑖, and then swaps them.
2. Copyright © 2021 BigMother.AI CIC. All rights reserved. 2
If |ψ⟩ = (
α0
α1
) = α0|0⟩ + α1|1⟩ then
Y |ψ⟩ = (
0 −𝑖
𝑖 0
) (
α0
α1
) = (
−𝑖α1
𝑖α0
) = −𝑖α1|0⟩ + 𝑖α0|1⟩
Y |0⟩ = (
0 −𝑖
𝑖 0
) (
1
0
) = (
0
𝑖
) = 𝑖 |1⟩ = 𝑒𝑖
𝜋
2 |1⟩ ≡ |1⟩
Y |1⟩ = (
0 −𝑖
𝑖 0
) (
0
1
) = (
−𝑖
0
) = −𝑖 |0⟩ = 𝑒𝑖𝜋
𝑒𝑖
𝜋
2 |0⟩ ≡ |0⟩
Y |+⟩ = (
0 −𝑖
𝑖 0
)
1
√2
(
1
1
) =
1
√2
(
−𝑖
𝑖
) = −𝑖 |−⟩ = 𝑒𝑖𝜋
𝑒𝑖
𝜋
2 |−⟩ ≡ |−⟩
Y |−⟩ = (
0 −𝑖
𝑖 0
)
1
√2
(
1
−1
) =
1
√2
(
𝑖
𝑖
) = 𝑖 |+⟩ = 𝑒𝑖
𝜋
2 |+⟩ ≡ |+⟩
The Z (phase flip) gate (a.k.a. Pauli gate 𝝈𝒁)
The Z gate, defined as
Z = (
1 0
0 𝑒𝑖𝜋) = (
1 0
0 −1
)
shifts the α1 amplitude by a phase factor of 𝑒𝑖𝜋
= −1.
If |ψ⟩ = (
α0
α1
) = α0|0⟩ + α1|1⟩ then
Z |ψ⟩ = (
1 0
0 −1
) (
α0
α1
) = (
α0
−α1
) = α0|0⟩ − α1|1⟩
Z |0⟩ = (
1 0
0 −1
) (
1
0
) = (
1
0
) = |0⟩
3. Copyright © 2021 BigMother.AI CIC. All rights reserved. 3
Z |1⟩ = (
1 0
0 −1
) (
0
1
) = (
0
−1
) = −1 |1⟩ = 𝑒𝑖𝜋 |1⟩ ≡ |1⟩
Z |+⟩ = (
1 0
0 −1
)
1
√2
(
1
1
) =
1
√2
(
1
−1
) = |−⟩
Z |−⟩ = (
1 0
0 −1
)
1
√2
(
1
−1
) =
1
√2
(
1
1
) = |+⟩
The S (or phase) gate (a.k.a. √𝒁 gate)
The S gate, defined as
S = (
1 0
0 𝑒𝑖
𝜋
2
) = (
1 0
0 𝑖
)
shifts the α1 amplitude by a phase factor of 𝑒𝑖
𝜋
2 = 𝑖.
If |ψ⟩ = (
α0
α1
) = α0|0⟩ + α1|1⟩ then
S |ψ⟩ = (
1 0
0 𝑖
) (
α0
α1
) = (
α0
𝑖α1
) = α0|0⟩ + 𝑖α1|1⟩
S |0⟩ = (
1 0
0 𝑖
) (
1
0
) = (
1
0
) = |0⟩
S |1⟩ = (
1 0
0 𝑖
) (
0
1
) = (
0
𝑖
) = 𝑖 |1⟩ = 𝑒𝑖
𝜋
2 |1⟩ ≡ |1⟩
4. Copyright © 2021 BigMother.AI CIC. All rights reserved. 4
S |+⟩ = (
1 0
0 𝑖
)
1
√2
(
1
1
) =
1
√2
(
1
𝑖
)
S |−⟩ = (
1 0
0 𝑖
)
1
√2
(
1
−1
) =
1
√2
(
1
−𝑖
)
The T (or
𝝅
𝟖
) gate (a.k.a. √𝒁
𝟒
gate)
The T gate, defined as
T = (
1 0
0 𝑒𝑖
𝜋
4
)
shifts the α1 amplitude by a phase factor of 𝑒𝑖
𝜋
4.
If |ψ⟩ = (
α0
α1
) = α0|0⟩ + α1|1⟩ then
T |ψ⟩ = (
1 0
0 𝑒𝑖
𝜋
4
) (
α0
α1
) = (
α0
𝑒𝑖
𝜋
4 α1
) = α0|0⟩ + 𝑒𝑖
𝜋
4 α1|1⟩
T |0⟩ = (
1 0
0 𝑒𝑖
𝜋
4
) (
1
0
) = (
1
0
) = |0⟩
T |1⟩ = (
1 0
0 𝑒𝑖
𝜋
4
) (
0
1
) = (
0
𝑒𝑖
𝜋
4
) = 𝑒𝑖
𝜋
4 |1⟩ ≡ |1⟩
T |+⟩ = (
1 0
0 𝑒𝑖
𝜋
4
)
1
√2
(
1
1
) =
1
√2
(
1
𝑒𝑖
𝜋
4
)
5. Copyright © 2021 BigMother.AI CIC. All rights reserved. 5
T |−⟩ = (
1 0
0 𝑒𝑖
𝜋
4
)
1
√2
(
1
−1
) =
1
√2
(
1
−𝑒𝑖
𝜋
4
)
Properties of I, X, Y, Z, S, T, and H
The following identities are easily proved [reminder: 𝑒𝑖𝜑
= cos 𝜑 + 𝑖 sin 𝜑, 𝑒𝑖𝜋
= −1, 𝑒𝑖
𝜋
2 = 𝑖]
I2
= X2
= Y2
= Z2
= H2
= I [the I, X, Y, Z, and H gates are their own inverses]
S2
= Z [the S gate is not its own inverse]
T2
= S [the T gate is not its own inverse]
X = HZH
Y = −HYH = −XYX
Z = HXH
H =
1
√2
(X + Z)
The Rx(𝝋) gate
The Rx(𝜑) gate, defined as
Rx(𝜑) = (
cos (
𝜑
2
) −𝑖 sin (
𝜑
2
)
−𝑖 sin (
𝜑
2
) cos (
𝜑
2
)
)
rotates the state 𝜑 radians about the x-axis [reminder: 𝑑° =
𝑑𝜋
180
rad].
If |ψ⟩ = (
α0
α1
) = α0|0⟩ + α1|1⟩ then
Rx(𝜑) |ψ⟩ = (cos (
𝜑
2
) α0 − 𝑖 sin (
𝜑
2
) α1) |0⟩ + (−𝑖 sin (
𝜑
2
) α0 + cos (
𝜑
2
)α1) |1⟩
= (cos (
𝜑
2
) α0 − 𝑖 sin (
𝜑
2
) α1) |0⟩ + (cos (
𝜑
2
) α1 − 𝑖 sin (
𝜑
2
) α0)|1⟩
We will present some representative rotations applied to the basis states {|0⟩, |1⟩, |+⟩, |−⟩}.
6. Copyright © 2021 BigMother.AI CIC. All rights reserved. 6
Rx(
0𝜋
180
) |0⟩ = (1 + 0i)|0> + (0 + 0i)|1>
Rx(
30𝜋
180
) |0⟩ = (0.9659258262 + 0i)|0> + (0 + -0.2588190451i)|1>
Rx(
60𝜋
180
) |0⟩ = (0.8660254037 + 0i)|0> + (0 + -0.5i)|1>
Rx(
90𝜋
180
) |0⟩ = (0.7071067811 + 0i)|0> + (0 + -0.7071067811i)|1>
Rx(
0𝜋
180
) |1⟩ = (0 + 0i)|0> + (1 + 0i)|1>
Rx(
30𝜋
180
) |1⟩ = (0 + -0.2588190451i)|0> + (0.9659258262 + 0i)|1>
Rx(
60𝜋
180
) |1⟩ = (0 + -0.5i)|0> + (0.8660254037 + 0i)|1>
Rx(
90𝜋
180
) |1⟩ = (0 + -0.7071067811i)|0> + (0.7071067811 + 0i)|1>
7. Copyright © 2021 BigMother.AI CIC. All rights reserved. 7
Rx(
0𝜋
180
) |+⟩ = (0.7071067811 + 0i)|0> + (0.7071067811 + 0i)|1>
Rx(
30𝜋
180
) |+⟩ = (0.6830127018 + -0.1830127018i)|0> + (0.6830127018 + -0.1830127018i)|1>
Rx(
60𝜋
180
) |+⟩ = (0.6123724356 + -0.3535533905i)|0> + (0.6123724356 + -0.3535533905i)|1>
Rx(
90𝜋
180
) |+⟩ = (0.5 + -0.5i)|0> + (0.5 + -0.5i)|1>
Rx(
0𝜋
180
) |−⟩ = (0.7071067811 + 0i)|0> + (-0.7071067811 + 0i)|1>
Rx(
30𝜋
180
) |−⟩ = (0.6830127018 + 0.1830127018i)|0> + (-0.6830127018 + -0.1830127018i)|1>
Rx(
60𝜋
180
) |−⟩ = (0.6123724356 + 0.3535533905i)|0> + (-0.6123724356 + -0.3535533905i)|1>
Rx(
90𝜋
180
) |−⟩ = (0.5 + 0.5i)|0> + (-0.5 + -0.5i)|1>
8. Copyright © 2021 BigMother.AI CIC. All rights reserved. 8
The Ry(𝝋) gate
The Ry(𝜑) gate, defined as
Ry(𝜑) = (
cos (
𝜑
2
) −sin (
𝜑
2
)
sin (
𝜑
2
) cos (
𝜑
2
)
)
rotates the state 𝜑 radians about the y-axis [reminder: 𝑑° =
𝑑𝜋
180
rad].
If |ψ⟩ = (
α0
α1
) = α0|0⟩ + α1|1⟩ then
Ry(𝜑) |ψ⟩ = (cos (
𝜑
2
)α0 − sin (
𝜑
2
) α1) |0⟩ + (sin (
𝜑
2
)α0 + cos (
𝜑
2
) α1) |1⟩
We will present some representative rotations applied to the basis states {|0⟩, |1⟩, |+⟩, |−⟩}.
Ry(
0𝜋
180
) |0⟩ = (1 + 0i)|0> + (0 + 0i)|1>
Ry(
30𝜋
180
) |0⟩ = (0.9659258262 + 0i)|0> + (0.2588190451 + 0i)|1>
Ry(
60𝜋
180
) |0⟩ = (0.8660254037 + 0i)|0> + (0.5 + 0i)|1>
Ry(
90𝜋
180
) |0⟩ = (0.7071067811 + 0i)|0> + (0.7071067811 + 0i)|1>
9. Copyright © 2021 BigMother.AI CIC. All rights reserved. 9
Ry(
0𝜋
180
) |1⟩ = (0 + 0i)|0> + (1 + 0i)|1>
Ry(
30𝜋
180
) |1⟩ = (-0.2588190451 + 0i)|0> + (0.9659258262 + 0i)|1>
Ry(
60𝜋
180
) |1⟩ = (-0.5 + 0i)|0> + (0.8660254037 + 0i)|1>
Ry(
90𝜋
180
) |1⟩ = (-0.7071067811 + 0i)|0> + (0.7071067811 + 0i)|1>
Ry(
0𝜋
180
) |+⟩ = (0.7071067811 + 0i)|0> + (0.7071067811 + 0i)|1>
Ry(
30𝜋
180
) |+⟩ = (0.5 + 0i)|0> + (0.8660254037 + 0i)|1>
Ry(
60𝜋
180
) |+⟩ = (0.2588190451 + 0i)|0> + (0.9659258262 + 0i)|1>
Ry(
90𝜋
180
) |+⟩ = (0 + 0i)|0> + (1 + 0i)|1>
10. Copyright © 2021 BigMother.AI CIC. All rights reserved. 10
Ry(
0𝜋
180
) |−⟩ = (0.7071067811 + 0i)|0> + (-0.7071067811 + 0i)|1>
Ry(
30𝜋
180
) |−⟩ = (0.8660254037 + 0i)|0> + (-0.5 + 0i)|1>
Ry(
60𝜋
180
) |−⟩ = (0.9659258262 + 0i)|0> + (-0.2588190451 + 0i)|1>
Ry(
90𝜋
180
) |−⟩ = (1 + 0i)|0> + (0 + 0i)|1>
The Rz(𝝋) gate
The Rz(𝜑) gate, defined as
Rz(𝜑) = (𝑒−𝑖
𝜑
2 0
0 𝑒𝑖
𝜑
2
) = 𝑒−𝑖
𝜑
2 (
1 0
0 𝑒
𝑖
𝜑
2
−(−𝑖
𝜑
2
)
) = 𝑒−𝑖
𝜑
2 (
1 0
0 𝑒𝑖
𝜑
2
+𝑖
𝜑
2
) ≡ (
1 0
0 𝑒𝑖𝜑)
rotates the state 𝜑 radians about the z-axis [reminder: 𝑑° =
𝑑𝜋
180
rad].
If |ψ⟩ = (
α0
α1
) = α0|0⟩ + α1|1⟩ then
Rz(𝜑) |ψ⟩ = (
1 0
0 𝑒𝑖𝜑)(
α0
α1
) = (
α0
𝑒𝑖𝜑
α1
) = α0|0⟩ + 𝑒𝑖𝜑
α1|1⟩
We will present some representative rotations applied to the basis states {|0⟩, |1⟩, |+⟩, |−⟩}.
11. Copyright © 2021 BigMother.AI CIC. All rights reserved. 11
Rz(
0𝜋
180
) |0⟩ = (1 + 0i)|0> + (0 + 0i)|1>
Rz(
30𝜋
180
) |0⟩ = (1 + 0i)|0> + (0 + 0i)|1>
Rz(
60𝜋
180
) |0⟩ = (1 + 0i)|0> + (0 + 0i)|1>
Rz(
90𝜋
180
) |0⟩ = (1 + 0i)|0> + (0 + 0i)|1>
Rz(
0𝜋
180
) |1⟩ = (0 + 0i)|0> + (1 + 0i)|1>
Rz(
30𝜋
180
) |1⟩ = (0 + 0i)|0> + (0.8660254037 + 0.5i)|1>
Rz(
60𝜋
180
) |1⟩ = (0 + 0i)|0> + (0.5 + 0.8660254037i)|1>
Rz(
90𝜋
180
) |1⟩ = (0 + 0i)|0> + (0 + 1i)|1>
12. Copyright © 2021 BigMother.AI CIC. All rights reserved. 12
Rz(
0𝜋
180
) |+⟩ = (0.7071067811 + 0i)|0> + (0.7071067811 + 0i)|1>
Rz(
30𝜋
180
) |+⟩ = (0.7071067811 + 0i)|0> + (0.6123724356 + 0.3535533905i)|1>
Rz(
60𝜋
180
) |+⟩ = (0.7071067811 + 0i)|0> + (0.3535533905 + 0.6123724356i)|1>
Rz(
90𝜋
180
) |+⟩ = (0.7071067811 + 0i)|0> + (0 + 0.7071067811i)|1>
Rz(
0𝜋
180
) |−⟩ = (0.7071067811 + 0i)|0> + (-0.7071067811 + 0i)|1>
Rz(
30𝜋
180
) |−⟩ = (0.7071067811 + 0i)|0> + (-0.6123724356 + -0.3535533905i)|1>
Rz(
60𝜋
180
) |−⟩ = (0.7071067811 + 0i)|0> + (-0.3535533905 + -0.6123724356i)|1>
Rz(
90𝜋
180
) |−⟩ = (0.7071067811 + 0i)|0> + (0 + -0.7071067811i)|1>
13. Copyright © 2021 BigMother.AI CIC. All rights reserved. 13
Properties of single-cubit operations
(1) The following are easily proved, thus we may visualise X, Y, Z, S, T, and H as rotations [note:
these are equivalences, not identities, as global phase has been factored out in each case]
X ≡ Rx(𝜋) [rotation about x-axis by 180°]
Y ≡ Ry(𝜋) [rotation about y-axis by 180°]
Z ≡ Rz(𝜋) [rotation about z-axis by 180°]
S ≡ Rz(
𝜋
2
) [rotation about z-axis by 90°]
T ≡ Rz(
𝜋
4
) [rotation about z-axis by 45°]
H ≡ Rx(𝜋)Ry(
𝜋
2
) [rotation about y-axis by 90°, then x-axis by 180°]
(2) For any 1-qubit operation U, it is always possible to find a Bloch sphere axis (3D vector) r and
angle 𝜑 such that U is equivalent to a rotation of 𝜑 radians about the axis represented by r.
(3) For any 1-qubit operation U, there exist angles 𝛼, 𝛽, 𝛾, and 𝜑 such that
U = 𝑒𝑖𝜑
Rz(𝛼) Ry(𝛽)Rz(𝛾) ≡ Rz(𝛼) Ry(𝛽)Rz(𝛾)
In other words, U is equivalent to a rotation of 𝛾 radians about the z-axis, followed by a rotation
of 𝛽 radians about the y-axis, followed by a rotation of 𝛼 radians about the z-axis (in that order!)
(4) For any 1-qubit operation U, there exist 1-qubit operations A, B, C and angle 𝜑 such that
ABC = I and U = 𝑒𝑖𝜑
AXBXC ≡ AXBXC
Inner product
The inner product ⟨ψ0|ψ1⟩ of two quantum states
|ψ0⟩ = α00|0⟩ + α01|1⟩
and
|ψ1⟩ = α10|0⟩ + α11|1⟩
14. Copyright © 2021 BigMother.AI CIC. All rights reserved. 14
is calculated as follows
⟨ψ0|ψ1⟩ = (α00
̅̅̅̅̅ α01
̅̅̅̅̅)(
α10
α11
) = α00
̅̅̅̅̅α10 + α01
̅̅̅̅̅α11
Note that this is an example of bra-ket notation, where
the bra ⟨ψ0| denotes the row vector
(α00
̅̅̅̅̅ α01
̅̅̅̅̅)
the ket |ψ1⟩ denotes the column vector
(
α10
α11
)
and the bra-ket combination ⟨ψ0|ψ1⟩ denotes the inner product as defined above.
Notice also that
⟨0|0⟩ = ⟨1|1⟩ = ⟨+|+⟩ = ⟨−|−⟩ = 1
⟨0|1⟩ = ⟨1|0⟩ = ⟨+|−⟩ = ⟨−|+⟩ = 0
If ⟨ψ0|ψ1⟩ = 0 then ψ0 and ψ1 are orthogonal, meaning they are antipodal on the Bloch sphere.
Any pair of orthogonal states, such as {|0⟩, |1⟩} or {|+⟩, |−⟩}, may be used as basis states.
The BB84 quantum key distribution protocol
Now that we’ve covered all the basic single-qubit operations, it’s time to consider a more
substantial algorithm than the simple random bit stream generator we looked at in Part 1.
We will imagine that Alice and Bob wish to communicate securely over an insecure classical (i.e.
non-quantum) communications channel, such as a normal telephone line + modem. They decide
to encrypt their messages using a one-time pad: a random bit sequence K that only they know.
Rather than sending an N-bit string P (the plaintext) to Bob, Alice instead generates an N-bit
string C (the ciphertext) from P and K such that C[i] = P[i] XOR K[i] for each message bit i, and
sends C to Bob. Because Bob also knows the one-time pad K, he is able to recover the plaintext
P by performing the reverse calculation, i.e. P[i] = C[i] XOR K[i] for each message bit i. Should an
eavesdropper, Eve, intercept C on its way from Alice to Bob, she will only be able to recover the
plaintext P if she also knows the one-time pad K. As long as K is a shared secret between Alice
and Bob, Eve will not be able to recover the plaintext P, and their communication will be secure.
15. Copyright © 2021 BigMother.AI CIC. All rights reserved. 15
If Bob and Alice are able to meet securely in the real world prior to their need to communicate
securely over an insecure channel, then things are simple. In this scenario, they can just agree,
during their real-world meeting, on the one-time pad K to use for their subsequent communication.
However, this is not always possible. Sometimes Alice will need to securely communicate a one-
time pad K to Bob, over an insecure channel, before then being able to communicate with him
securely by using that one-time pad K to encrypt and decrypt messages as described above. We
therefore have a textbook chicken-and-egg situation: in order to be able to communicate
plaintext messages P securely over an insecure communications channel, Alice and Bob must
first be able to communicate a one-time pad K securely over an insecure channel. But how..?
Alice and Bob agree to use the BB84 quantum key distribution protocol, as follows:
1. Alice generates two arbitrarily-long private random bit strings KA and BA (for example,
using the simple “Hadamard gate + measurement” quantum algorithm we saw in Part 1).
2. Alice encodes KA (one bit at a time) onto an insecure quantum channel, as follows:
a. if BA[i] is 0, then Alice encodes KA[i] using the basis states |0⟩ and |1⟩, i.e.
if KA[i] is 0 then Alice sends Bob |0⟩
if KA[i] is 1 then Alice sends Bob |1⟩ = X |0⟩
b. if BA[i] is 1, then Alice encodes KA[i] using the basis states |+⟩ and |−⟩, i.e.
if KA[i] is 0 then Alice sends Bob |+⟩ = H |0⟩
if KA[i] is 1 then Alice sends Bob |−⟩ = H |1⟩ = HX |0⟩
3. (We imagine Eve may attempt to intercept each bit KA[i] at this point, of which more later…)
4. At the other end of the quantum channel, Bob would also like to receive each bit KA[i];
however, for each bit, Bob doesn’t know the basis with which Alice encoded that bit
5. Following the protocol, Bob generates an arbitrarily-long private random bit string BB
To Bob
To Bob
To Bob
To Bob
16. Copyright © 2021 BigMother.AI CIC. All rights reserved. 16
6. Bob decodes (measures) each qubit on the quantum channel into bit string KB, as follows:
a. if BB[i] is 0, then Bob measures KB[i] assuming basis states |0⟩ and |1⟩, i.e.
b. if BB[i] is 1, then Bob measures KB[i] assuming basis states |+⟩ and |−⟩, i.e.
7. For each bit i, if Bob chose the correct basis in which to measure the state of the quantum
channel (i.e. if BB[i] = BA[i]) then KB[i] = KA[i]; however, if Bob chose the wrong basis (i.e. if
BB[i] ≠ BA[i]) then KB[i] = KA[i] ~50% of the time, and thus KB[i] ≠ KA[i] ~50% of the time
8. Alice and Bob now talk over an insecure classical channel (e.g. telephone), and compare
their two random bit strings BA and BB (Eve, if she’s listening, can hear everything at this
point); by doing so, they are able to determine those bit positions i for which BB[i] = BA[i],
and therefore those positions i for which KB[i] = KA[i] with 100% probability; Alice and Bob
agree to use as one-time pad K exactly those bits of KB[i] and KA[i] for which BB[i] = BA[i].
Having followed the BB84 protocol, Alice and Bob have managed to agree a one-time pad K with
which they can now communicate over an insecure classical channel as described above. But
has Eve been able to reconstruct the one-time pad K from the information she was able to glean
from listening to Alice and Bob’s key distribution communications? Is K a shared secret, or not?
Let’s imagine that, at Step 3, Eve was able to take a copy of each qubit as it was sent from Alice
to Bob via the quantum channel (but without actually measuring the state of the channel in order
to do so), and that, at Step 8, she then listened in on Alice and Bob’s conversation about the
random bit strings BA and BB. Having learned the exact contents of BA (and BB), she would then
know exactly how Alice had encoded each bit of KA, and would therefore be able to correctly
measure each qubit of her stored copy of the message, allowing her to both recover KA and work
out which bits of KA to retain; in other words, she would be able to determine the one-time pad K.
Unfortunately for Eve, the no-cloning theorem means that it is impossible for her to make a
quantum copy of the message at Step 3. Her only option is to measure, at Step 3, each qubit sent
by Alice, and to then retransmit each qubit to Bob. Just like Bob, however, Eve does not know
which basis to use when measuring each qubit, or when retransmitting to Bob, and will only guess
correctly ~50% of the time, thereby corrupting the message. By the time she learns the exact
contents of BA and BB at Step 8 it’s too late – she can’t re-measure each qubit because she has
no copies. Thus, not only has Alice failed to learn K, but, by using an insecure channel to compare
a non-secret part of the message, Alice and Bob can easily detect Eve’s attempts at interception.
From Alice
From Alice
KB[i]
KB[i]
17. Copyright © 2021 BigMother.AI CIC. All rights reserved. 17
Tensor product
The tensor product 𝑎 ⨂ 𝑏 of two vectors a and b is calculated by copying; for example
The tensor product 𝐴 ⨂ 𝐵 of two matrices A and B, for example
is similarly calculated, as follows
(Images stolen from [Yanofsky & Mannucci] Quantum Computing for Computer Scientists)
18. Copyright © 2021 BigMother.AI CIC. All rights reserved. 18
Two-qubit systems
Assuming the basis states |0⟩ and |1⟩ for single qubits, a 2-qubit system can be in 4 basis states
|0⟩ ⨂ |0⟩ also written |0⟩|0⟩ or |00⟩
|0⟩ ⨂ |1⟩ also written |0⟩|1⟩ or |01⟩
|1⟩ ⨂ |0⟩ also written |1⟩|0⟩ or |10⟩
|1⟩ ⨂ |1⟩ also written |1⟩|1⟩ or |11⟩
Note that each of the above calculations yields a 4-element column vector, for example
|00⟩ = (
1
0
0
0
)
More generally, a 2-qubit system |ψ⟩ can be in a superposition of all 4 basis states
|ψ⟩ = (
α00
α01
α10
α11
) = α00|00⟩ + α01|01⟩ + α10|10⟩ + α11|11⟩
where the following normalisation condition must always hold
(∑ |𝛼𝑥𝑦|
2
𝑥,𝑦 ∈ {0,1} ) = 1
Measuring a two-qubit system
If we measure both qubits of |ψ⟩ = α00|00⟩ + α01|01⟩ + α10|10⟩ + α11|11⟩ simultaneously then
|ψ⟩ will collapse to |00⟩ with probability |𝛼00|2
|01⟩ with probability |𝛼01|2
|10⟩ with probability |𝛼10|2
|11⟩ with probability |𝛼11|2
19. Copyright © 2021 BigMother.AI CIC. All rights reserved. 19
If instead we measure just one of the two qubits
that qubit will collapse to |0⟩ with probability |𝛼00|2
+ |𝛼01|2
|1⟩ with probability |𝛼10|2
+ |𝛼11|2
Two-qubit operations (gates)
We can represent a 2-qubit operation (gate) U as a 4 × 4 complex matrix
U = (
𝑢00 𝑢01
𝑢10 𝑢11
𝑢02 𝑢03
𝑢12 𝑢13
𝑢20 𝑢21
𝑢30 𝑢31
𝑢22 𝑢23
𝑢32 𝑢33
)
We can then calculate the result of applying U to state |ψ⟩ = α00|00⟩ + α01|01⟩ + α10|10⟩ + α11|11⟩
(
𝑢00 𝑢01
𝑢10 𝑢11
𝑢02 𝑢03
𝑢12 𝑢13
𝑢20 𝑢21
𝑢30 𝑢31
𝑢22 𝑢23
𝑢32 𝑢33
) (
α00
α01
α10
α11
) = (
𝑢00α00 + 𝑢01α01 + 𝑢02α10 + 𝑢03α11
𝑢10α00 + 𝑢11α01 + 𝑢12α10 + 𝑢13α11
𝑢20α00 + 𝑢21α01 + 𝑢22α10 + 𝑢23α11
𝑢30α00 + 𝑢31α01 + 𝑢32α10 + 𝑢33α11
)
In order for the result on the RHS to be a valid state it must satisfy the normalisation condition
(∑ |𝛼𝑥𝑦|
2
𝑥,𝑦 ∈ {0,1} ) = 1. In order to preserve normalisation, a 4-qubit operation
U = (
𝑢00 𝑢01
𝑢10 𝑢11
𝑢02 𝑢03
𝑢12 𝑢13
𝑢20 𝑢21
𝑢30 𝑢31
𝑢22 𝑢23
𝑢32 𝑢33
)
must be unitary, meaning that U multiplied by its conjugate transpose yields the identity.
In other words
(
𝑢00 𝑢01
𝑢10 𝑢11
𝑢02 𝑢03
𝑢12 𝑢13
𝑢20 𝑢21
𝑢30 𝑢31
𝑢22 𝑢23
𝑢32 𝑢33
) (
𝑢00
̅̅̅̅̅ 𝑢10
̅̅̅̅
𝑢01
̅̅̅̅̅ 𝑢11
̅̅̅̅
𝑢20
̅̅̅̅̅ 𝑢30
̅̅̅̅̅
𝑢21
̅̅̅̅̅ 𝑢31
̅̅̅̅̅
𝑢02
̅̅̅̅̅ 𝑢12
̅̅̅̅
𝑢03
̅̅̅̅̅ 𝑢13
̅̅̅̅
𝑢22
̅̅̅̅̅ 𝑢32
̅̅̅̅̅
𝑢23
̅̅̅̅̅ 𝑢33
̅̅̅̅̅
) = (
1 0
0 1
0 0
0 0
0 0
0 0
1 0
0 1
)
where 𝑥̅ is the complex conjugate of complex number 𝑥.
20. Copyright © 2021 BigMother.AI CIC. All rights reserved. 20
Two-qubit gates built from single-qubit gates
The simplest 2-qubit gates U are constructed from two 1-qubit gates A and B.
The matrix representing such a gate is simply the tensor product of A and B
U = 𝐴 ⨂ 𝐵
The CNOT (Controlled-NOT) gate
An example of a 2-qubit gate that cannot be constructed from two 1-qubit gates is CNOT
CNOT = (
1 0
0 1
0 0
0 0
0 0
0 0
0 1
1 0
)
which operates as follows
CNOT |00⟩ = |00⟩
CNOT |01⟩ = |01⟩
CNOT |10⟩ = |11⟩
CNOT |11⟩ = |10⟩
Control qubit is |1⟩, target qubit is flipped
Control qubit) is |0⟩, nothing changes
Control
Target
Control
Target
Control
Target
Control
Target
21. Copyright © 2021 BigMother.AI CIC. All rights reserved. 21
CNOT in practice
The CNOT gate can be difficult to implement, which means that, in a real quantum computer, we
can sometimes only apply CNOT to specific qubits (and no others). To compensate
(1) we can swap the control and target qubits using Hadamard gates, as follows
(2) or we can use 3 CNOTs to swap qubit states, for example
Controlled-U gates
For any 1-qubit operation U, we can construct a controlled-U gate operating as follows
if the control qubit is set then U is applied to the target qubit
if the control qubit is not set then I is applied to the target qubit (i.e. it’s unchanged)
in either case, I is applied to the control qubit
Control qubit is |1⟩, target qubit is flipped
Control qubit is |0⟩, nothing changes
Target
Control
Target
Control
Target
Control
Target
Control
q0
q1
q1
q0
22. Copyright © 2021 BigMother.AI CIC. All rights reserved. 22
Given 1-qubit operations A, B, C, U and angle 𝜑 such that
ABC = I and U = 𝑒𝑖𝜑
AXBXC ≡ AXBXC
(which we know always exist for any given U) we can construct a controlled-U gate as follows
Entanglement
If an n-qubit quantum state |ψ⟩ is a tensor product of quantum states |ψ1⟩ and |ψ2⟩, i.e.
|ψ⟩ = |ψ1⟩|ψ2⟩ = |ψ1⟩ ⨂ |ψ2⟩
then |ψ⟩ is a separable state, otherwise |ψ⟩ is an entangled state
If one qubit of a separable 2-qubit quantum state is measured, yielding classical bit c0, then that
qubit will immediately collapse, but the other qubit will not collapse until it is separately measured,
yielding classical bit c1. In this scenario, c0 and c1 are independent (statistically uncorrelated).
If one qubit of an entangled 2-qubit quantum state is measured, yielding c0, the entire system
of entangled states will collapse together, such that, when the other qubit is measured,
yielding c1, bits c0 and c1 will be highly correlated. (And similarly for n-qubit quantum states.)
The following 2-qubit quantum states, known as the Bell states, are all entangled
|Φ+⟩ =
|00⟩ + |11⟩
√2
|Φ−⟩ =
|00⟩ − |11⟩
√2
|ψ+⟩ =
|01⟩ + |10⟩
√2
|ψ−⟩ =
|01⟩ − |10⟩
√2
23. Copyright © 2021 BigMother.AI CIC. All rights reserved. 23
Hello Entangled World
The following quantum circuit creates an entangled state
Initially, the state of the system is |00⟩.
After we apply the H gate, the state is
|00⟩ + |10⟩
√2
When we apply the CNOT gate, the state changes to
|Φ+⟩ =
|00⟩ + |11⟩
√2
which is one of the Bell states, and therefore entangled.
The measurements then behave as follows
the first measurement will yield either 0 or 1, each with probability
1
2
if the first measurement yields 0
the new state will be |00⟩
the second measurement will yield 0 with probability 1
if the first measurement yields 1
the new state will be |11⟩
the second measurement will yield 1 with probability 1
24. Copyright © 2021 BigMother.AI CIC. All rights reserved. 24
Remember, of course, that the results of actually executing the above algorithm are probabilistic.
On a quantum simulator, which simulates an ideal (perfect) quantum computer, the probability
distribution obtained by running the above algorithm say N=1000 times will be as follows:
|00⟩ ~50% (tending towards 50% exactly as N increases)
|01⟩ 0% (exactly)
|10⟩ 0% (exactly)
|11⟩ ~50% (tending towards 50% exactly as N increases)
This is because the simulator does exactly what the quantum equations say. In particular, the
first measurement (which collapses the entanglement) will choose evenly (on average) between
collapsing the state to |00⟩ or |11⟩. On a real quantum computer, which is vulnerable to quantum
errors due to decoherence and other quantum noise, the results won’t be quite so perfect.
The following indicates the differences between a simulator and a real machine. Note that, on the
real machine (“Device”), the final states |01⟩ and |10⟩ have occurred a non-zero number of times.