MULT20015 Lecture 5 2021 FINAL
MULT20015 Elements of Quantum Computing
Lecture 5
Subject outline
Lecture topics (by week)
1 – Introduction to quantum computing and maths basics
2 – Single qubit representations and logic operations
3 – Two qubit states and logic gates
4 – Multi-qubit states and quantum arithmetic
5 – Basic quantum algorithms
6 – Period finding, cryptography and quantum factoring
7 – Shor’s algorithm, post-quantum crypto, quantum key distribution
8 – Quantum search algorithms
9 – Grover search applications, optimisation problems
10 – Solving optimisation problems on quantum computers
11 – Applications in quantum machine learning
12 – Real quantum computer devices
Assignment schedule:
#1: Hand out in Week 2
#2: Hand out in Week 8
MULT20015 Elements of Quantum Computing
Lecture 5
Week 3
Lecture 5
5.1 Two-qubit systems
5.2 Two qubit example – independent Alice and Bob
5.3 General two qubit states: measurement and operations
Lecture 6
6.1 Two-qubit logic operations
6.2 Entanglement
Practice class 3
Two qubit states and operations
MULT20015 Elements of Quantum Computing
Lecture 5
Recap: angles in context – abundant use of 𝜃
Angle specifying position on the Bloch sphere:
Phase angle of complex amplitudes in polar coordinates:
Re a
Im a
✓a
|a|
Angle of rotation of a qubit state on the Bloch sphere about a
specified axis (unit vector), n:
| i = a0 |0i+ a1 |a1i ! cos
✓B
2
|0i+ sin
✓B
2
ei�B |1i
| i = a0 |0i+ a1 |1i =
✓
a0
a1
◆
! | i = |a0|ei✓0 |0i+ |a1|ei✓1 |1i
| 0i = Rn̂(✓R) | i
𝜃!
𝜙!
MULT20015 Elements of Quantum Computing
Lecture 5
Lecture 4 recap: X Gate (the X operator): 𝜋 around X-axis
X =
0 1
1 0
�
Circuit symbol:
Matrix representation:
Action on ket states:
QUI example:
Re
Im
✓
i
-i
-1 +1
x
z
y
p
3
2
|0i+
�i
2
|1i complexamplitudes
↵|0i+ �|1i ! ↵|1i+ �|0i↵|0i+ �|1i ! ↵|1i+ �|0i↵|0i+ �|1i ! ↵|1i+ �|0i↵|0i+ �|1i ! ↵|1i+ �|0i
X (a0 |0i+ a1 |1i) =
0 1
1 0
�
a0
a1
�
=
a1
a0
�
i.e. X (a0 |0i+ a1 |1i) = a1 |0i+ a0 |1i
a0 |0i+ a1 |1i ! a1 |0i+ a0 |1i
�i
2
|0i+
p
3
2
|1i
MULT20015 Elements of Quantum Computing
Lecture 5
Lecture 4 recap: H Gate (Hadamard): 𝜋 around X+Z-axis
Circuit symbol:
Matrix representation:
Action on ket states:
x
z
y
QUI example:
Re
Im
✓
i
-i
-1 +1p
3
2
|0i+
�i
2
|1i complexamplitudes
H =
1
p
2
1 1
1 �1
�
|0i !
|0i+ |1i
p
2
|1i !
|0i � |1i
p
2
a0 |0i+ a1 |1i !
a0 + a1p
2
|0i+
a0 � a1p
2
|1i
|0i !
|0i+ |1i
p
2
|1i !
|0i � |1i
p
2
a0 |0i+ a1 |1i !
a0 + a1p
2
|0i+
a0 � a1p
2
|1i
↵|0i+ �|1i ! ↵|1i+ �|0i↵|0i+ �|1i ! ↵|1i+ �|0i↵|0i+ �|1i ! ↵|1i+ �|0i↵|0i+ �|1i ! ↵|1i+ �|0i
p
3� i
2
p
2
|0i+
p
3 + i
2
p
2
|1i
MULT20015 Elements of Quantum Computing
Lecture 5
Lecture 4 recap: the single qubit gate library
With the qubit maths background – complex amplitudes, Bloch sphere, Pauli operations etc
we covered all the single qubit gates in the QUI library…
MULT20015 Elements of Quantum Computing
Lecture 5
5.1 Two qubit systems
MULT20015
Lecture 5
MULT20015 Elements of Quantum Computing
Lecture 5
|0ñ “and” |1ñ
|0ñ
state collapse ® random
outcome
quantum superposition
measurement/observation
|1ñ
|0ñY|0i
|1i
Recap: quantum superposition/measurement
Bubble: Brocken commons.wikimedia.org
Bursting bubble: wallpaperswide.com
One electron in quantum
superposition.
For a single qubit :
MULT20015 Elements of Quantum Computing
Lecture 5
Recap: qubits and binary numbers
Computers represent digits as binary numbers. Similarly, we can think as the
state of several qubits as a binary digits.
|0i
|1i
|0i
|1i
|0i
|1i
For example, the number 5 can be represented in binary as
101, and this can be encoded directly in the state of three
individual atoms.
This lecture we will talk about how we describe and control two-qubit systems…
MULT20015 Elements of Quantum Computing
Lecture 5
Two qubits: tensor product
| i = a|0i+ b|1i |�i = c|0i+ d|1i
Then the joint state of both atoms is:
| i ⌦ |�i
Tensor product!
Two atoms, each with one
electron in a superposition of
the computational basis states:
MULT20015 Elements of Quantum Computing
Lecture 5
Tensor product -> binaries
For these two atoms in the states indicated:
| i ⌦ |�i = (a|0i+ b|1i)⌦ (c|0i+ d|1i)
= ac |0i ⌦ |0i+ ad |0i ⌦ |1i+ bc |1i ⌦ |0i+ bd |1i ⌦ |1i
= ac |00i+ ad |01i+ bc |10i+ bd |11i
| i = a|0i+ b|1i |�i = c|0i+ d|1i
multiplying them out
Note the simpler “consolidated” notation, e.g. ⟩|0 ⊗ ⟩|1 → ⟩|01 , with qubit ordering implied.
Two atoms, each with one
electron in a superposition of
the computational basis states:
MULT20015 Elements of Quantum Computing
Lecture 5
Tensor product -> binaries
So, for two general qubits in the states indicated:
| i ⌦ |�i = (a|0i+ b|1i)⌦ (c|0i+ d|1i)
= ac |0i ⌦ |0i+ ad |0i ⌦ |1i+ bc |1i ⌦ |0i+ bd |1i ⌦ |1i
= ac |00i+ ad |01i+ bc |10i+ bd |11i
| i = a|0i+ b|1i |�i = c|0i+ d|1i
The binary number representation {00, 01, 10, 11} now becomes more apparent…
i.e. Binary {00, 01, 10, 11} <-> Decimal {0, 1 , 2, 3}
| i ⌦ |�i = (a|0i+ b|1i)⌦ (c|0i+ d|1i)
= ac |0i ⌦ |0i+ ad |0i ⌦ |1i+ bc |1i ⌦ |0i+ bd |1i ⌦ |1i
= ac |00i+ ad |01i+ bc |10i+ bd |11i
The two-qubit state is usually written as:
“consolidated” notation, e.g. ⟩|0 ⊗ ⟩|1 → ⟩|01
qubit 1 qubit 2
MULT20015 Elements of Quantum Computing
Lecture 5
Tensor product of vectors
a
b
�
⌦
c
d
�
=
2
66
4
ac
ad
bc
bd
3
77
5
00 amplitude
01 amplitude
10 amplitude
11 amplitude
| i = a|0i+ b|1i |�i = c|0i+ d|1i
|0i =
1
0
�
|1i =
0
1
�
| i =
a0
a1
�
a0, a1 2 C
Recall matrix notation:
MULT20015 Elements of Quantum Computing
Lecture 5
Tensor product of operators
Similarly, we can define a Kronecker tensor product of qubit operators:
a b
c d
�
⌦
m n
p q
�
=
2
66
4
am an bm bn
ap aq bp bq
cm cn dm dn
cp cq dp dq
3
77
5
!!”
!#”
!!
!#
|”!⟩ = & |”⟩
= 2 x 2matrix
Recall, single qubit operators -> 2×2 matrix
MULT20015 Elements of Quantum Computing
Lecture 5
5.2 Two qubit example – independent Alice and Bob
MULT20015
Lecture 5
MULT20015 Elements of Quantum Computing
Lecture 5
Two qubit independent superposition state, and measure
The combined quantum state (tensor product):
| alice&bobi = | alicei ⇥ | bobi
= (
1
p
2
|0i+
1
p
2
|1i)⇥ (
1
p
2
|0i+
1
p
2
|1i)
=
1
2
|0i |0i+
1
2
|0i |1i+
1
2
|1i |0i+
1
2
|1i |1i
=
1
2
|00i+
1
2
|01i+
1
2
|10i+
1
2
|11i
| alice&bobi = | alicei ⇥ | bobi
= (
1
p
2
|0i+
1
p
2
|1i)⇥ (
1
p
2
|0i+
1
p
2
|1i)
=
1
2
|0i |0i+
1
2
|0i |1i+
1
2
|1i |0i+
1
2
|1i |1i
=
1
2
|00i+
1
2
|01i+
1
2
|10i+
1
2
|11i
No gate linking the two qubits,
so Bob’s superposition unchanged…
|0ñ
|1ñ
Alice qubit
| alicei =
1
p
2
|0i+
1
p
2
|1i
| alicei = H |0i
Bob qubit
| bobi =
1
p
2
|0i+
1
p
2
|1i
| bobi = H |0i
|0ñ
|1ñ
Alice qubit Bob qubit
e.g. outcome = “0”
?
| alice&bobi ! |0i ⇥
✓
1
p
2
|0i+
1
p
2
|1i
◆
meas. no
meas.
| alice&bobi =
✓
1
p
2
|0i+
1
p
2
|1i
◆
⇥
✓
1
p
2
|0i+
1
p
2
|1i
◆
Alice qubit Bob qubit
Now, let’s make a measurement on e.g. Alice:
Let’s do an example in more detail…consider this code where we apply
a H-gate to each initialized qubit, but no “linking” gates (e.g. CNOT) yet
–> we’ll name the qubits for clarity…Top = “Alice”, bottom = “Bob”
“Alice”
“Bob”
⊗
⊗
⊗
⊗
MULT20015 Elements of Quantum Computing
Lecture 5
Summary of measurement scenarios
Measure Alice only| alice&bobi = | alicei ⇥ | bobi
= (
1
p
2
|0i+
1
p
2
|1i)⇥ (
1
p
2
|0i+
1
p
2
|1i)
=
1
2
|0i |0i+
1
2
|0i |1i+
1
2
|1i |0i+
1
2
|1i |1i
=
1
2
|00i+
1
2
|01i+
1
2
|10i+
1
2
|11i
0
| alice&bobi ! |0i ⇥
✓
1
p
2
|0i+
1
p
2
|1i
◆
| alice&bobi =
✓
1
p
2
|0i+
1
p
2
|1i
◆
⇥
✓
1
p
2
|0i+
1
p
2
|1i
◆
Alice qubit Bob qubit
| alice&bobi = | alicei ⇥ | bobi
= (
1
p
2
|0i+
1
p
2
|1i)⇥ (
1
p
2
|0i+
1
p
2
|1i)
=
1
2
|0i |0i+
1
2
|0i |1i+
1
2
|1i |0i+
1
2
|1i |1i
=
1
2
|00i+
1
2
|01i+
1
2
|10i+
1
2
|11i
1
!
✓
1
p
2
|0i+
1
p
2
|1i
◆
⇥ |0i
!
✓
1
p
2
|0i+
1
p
2
|1i
◆
⇥ |1i! |1i ⇥
✓
1
p
2
|0i+
1
p
2
|1i
◆
| alice&bobi = | alicei ⇥ | bobi
= (
1
p
2
|0i+
1
p
2
|1i)⇥ (
1
p
2
|0i+
1
p
2
|1i)
=
1
2
|0i |0i+
1
2
|0i |1i+
1
2
|1i |0i+
1
2
|1i |1i
=
1
2
|00i+
1
2
|01i+
1
2
|10i+
1
2
|11i
0
| alice&bobi = | alicei ⇥ | bobi
= (
1
p
2
|0i+
1
p
2
|1i)⇥ (
1
p
2
|0i+
1
p
2
|1i)
=
1
2
|0i |0i+
1
2
|0i |1i+
1
2
|1i |0i+
1
2
|1i |1i
=
1
2
|00i+
1
2
|01i+
1
2
|10i+
1
2
|11i
1
Measure Bob only
Measure “0” on Alice
Measure “1” on Alice
Measure “0” on Bob
Measure “1” on Bob
If we measure one of the qubits we get a partial collapse of the quantum state:
Bob will get “0” or “1” at random no matter Alice qubit result Alice will get “0” or “1” at random no matter Bob qubit result
“Alice”
“Bob”
⊗
⊗
⊗
⊗
⊗ ⊗
⊗
⊗
⊗
MULT20015 Elements of Quantum Computing
Lecture 5
Two qubits – binary and decimal representations
|0ñ
|1ñ
Alice qubit
| alicei =
1
p
2
|0i+
1
p
2
|1i
| alicei = H |0i
Bob qubit
| bobi =
1
p
2
|0i+
1
p
2
|1i
| bobi = H |0i
|0ñ
|1ñ
“Alice”
“Bob”
Binary representation:
| alice&bobi = | alicei ⇥ | bobi
= (
1
p
2
|0i+
1
p
2
|1i)⇥ (
1
p
2
|0i+
1
p
2
|1i)
=
1
2
|0i |0i+
1
2
|0i |1i+
1
2
|1i |0i+
1
2
|1i |1i
=
1
2
|00i+
1
2
|01i+
1
2
|10i+
1
2
|11i
| alice&bobi = | alicei ⇥ | bobi
= (
1
p
2
|0i+
1
p
2
|1i)⇥ (
1
p
2
|0i+
1
p
2
|1i)
=
1
2
|0i |0i+
1
2
|0i |1i+
1
2
|1i |0i+
1
2
|1i |1i
=
1
2
|00i+
1
2
|01i+
1
2
|10i+
1
2
|11i
Alice Bob
Decimal representation:
| alice&bobi
=
1
2
|00i+
1
2
|01i+
1
2
|10i+
1
2
|11i
=
1
2
|0i+
1
2
|1i+
1
2
|2i+
1
2
|3i
| alice&bobi = | alicei ⇥ | bobi
= (
1
p
2
|0i+
1
p
2
|1i)⇥ (
1
p
2
|0i+
1
p
2
|1i)
=
1
2
|0i |0i+
1
2
|0i |1i+
1
2
|1i |0i+
1
2
|1i |1i
=
1
2
|00i+
1
2
|01i+
1
2
|10i+
1
2
|11i
QUI:
“binary
notation”
QUI:
“decimal
notation”
etc
Measure both qubits: e.g. Prob “01” = 1/4 etc (all same)
Measure both qubits: e.g. Prob “3” = 1/4 etc (all same)
Binary ® decimal representation:
00 ® 0, 01 ® 1, 10 ® 2, 11 ® 3
⊗
⊗
MULT20015 Elements of Quantum Computing
Lecture 5
Binary and decimal in the QUI
| alice&bobi = | alicei ⇥ | bobi
= (
1
p
2
|0i+
1
p
2
|1i)⇥ (
1
p
2
|0i+
1
p
2
|1i)
=
1
2
|0i |0i+
1
2
|0i |1i+
1
2
|1i |0i+
1
2
|1i |1i
=
1
2
|00i+
1
2
|01i+
1
2
|10i+
1
2
|11i
| alice&bobi
=
1
2
|00i+
1
2
|01i+
1
2
|10i+
1
2
|11i
=
1
2
|0i+
1
2
|1i+
1
2
|2i+
1
2
|3i
| alice&bobi = | alicei ⇥ | bobi
= (
1
p
2
|0i+
1
p
2
|1i)⇥ (
1
p
2
|0i+
1
p
2
|1i)
=
1
2
|0i |0i+
1
2
|0i |1i+
1
2
|1i |0i+
1
2
|1i |1i
=
1
2
|00i+
1
2
|01i+
1
2
|10i+
1
2
|11i
binary: amplitude “𝑎!!” = 1/2
deci
mal:
“𝑎!”
= 1/
2
binary amplitude “𝑎””” = 1/2
decimal: “𝑎#” = 1/2
⊗
MULT20015 Elements of Quantum Computing
Lecture 5
Two-qubit example: measurement scenarios
| alice&bobi =
✓
1
p
2
|0i+
1
p
2
|1i
◆
⇥
✓
1
p
2
|0i+
1
p
2
|1i
◆Alice qubit Bob qubit
Measure both of the qubits we get a total collapse of the quantum state over the register:
| alice&bobi = | alicei ⇥ | bobi
= (
1
p
2
|0i+
1
p
2
|1i)⇥ (
1
p
2
|0i+
1
p
2
|1i)
=
1
2
|0i |0i+
1
2
|0i |1i+
1
2
|1i |0i+
1
2
|1i |1i
=
1
2
|00i+
1
2
|01i+
1
2
|10i+
1
2
|11i
| alice&bobi = | alicei ⇥ | bobi
= (
1
p
2
|0i+
1
p
2
|1i)⇥ (
1
p
2
|0i+
1
p
2
|1i)
=
1
2
|0i |0i+
1
2
|0i |1i+
1
2
|1i |0i+
1
2
|1i |1i
=
1
2
|00i+
1
2
|01i+
1
2
|10i+
1
2
|11i
Alice qubit Bob qubit
Binary number
representation
Alice qubit
Bob qubit
outcome binary decimal
0 0 00 0
0 1 01 1
1 0 10 2
1 1 11 3
probability
0.25
0.25
0.25
0.25
a00 = 0.5
Prob[00] = a002= 0.25 etc
⊗
So far we have used a simple even (independent) superposition as our
example two-qubit state…we will consider it more generally now…
MULT20015 Elements of Quantum Computing
Lecture 5
5.3 General two qubit states: measurement and operations
MULT20015
Lecture 5
MULT20015 Elements of Quantum Computing
Lecture 5
Two-qubit measurement & collapse
Measurement on a two-qubit state:
(1) Apply collapse principle to the measured state
(2) Renormalize the state probabilities
For example, consider the
general two-qubit state:
If the first qubit were measured to be “0”, keep
only those states and renormalize to get the
new state:
| i = a |00i+ b |01i+ c |10i+ d |11i
| 0i =
a |00i+ b |01i
p
|a|2 + |b|2
re-normalization
Later: this generalizes to measurements on multi-qubit states.
If the first qubit were measured to be “1”, keep
only those states and renormalize to get the
new state:
| 0i =
c |10i+ d |11i
p
|c|2 + |d|2
e.g. “c” is the
complex amplitude
for the ⟩|10 state etc
MULT20015 Elements of Quantum Computing
Lecture 5
Explicit example – QUI does all this for you
⟩|𝜓 = !
”
𝑒#$/& ⟩|00 + !
‘
𝑒#$/( ⟩|01 + !
”
𝑒#$/& ⟩|10 + !
‘
𝑒#$/( ⟩|11
Measure “0” on 1st qubit:
⟩|𝜓 →
1
6
𝑒
#$
& ⟩|00 + 1
3
𝑒
#$
( ⟩|01
|𝑒
#$
& / 6|&+|𝑒
#$
( / 3|&
=
1
3
𝑒
#$
& ⟩|00 +
2
3
𝑒
#$
( ⟩|01
Measure “1” on 1st qubit:
⟩|𝜓 →
1
6
𝑒
#$
& ⟩|10 + 1
3
𝑒
#$
( ⟩|11
|𝑒
#$
& / 6|&+|𝑒
#$
( / 3|&
=
1
3
𝑒
#$
& ⟩|10 +
2
3
𝑒
#$
( ⟩|11
NB. Scale has changed!
NB. Scale has changed!
MULT20015 Elements of Quantum Computing
Lecture 5
Single qubit gates on multi-qubit systems
We can apply single-qubit operators to multi-qubit systems:
To work out the operator we are applying in matrix representation, we use the
Kronecker (tensor) product with the identity matrix, e.g.:
X ⌦ I =
0 1
1 0
�
⌦
1 0
0 1
�
=
2
66
4
0 0 1 0
0 0 0 1
1 0 0 0
0 1 0 0
3
77
5
Simplest way to think of it: the
subscript represents which qubit
the operation is applied to.
Identity is
applied to
second qubit
where there’s
no operation
X1 |00i = |10i
X2 |00i = |01i
(X ⌦ I) |0i ⌦ |0i
(I ⌦X) |0i ⌦ |0i
MULT20015 Elements of Quantum Computing
Lecture 5
Shorthand notation for multi-qubit states/operations
We write as: ⟩|𝜓(𝑡 = 1) = 𝐻&𝐻! ⟩|00 where:
𝐻!applies a H-gate to qubit #1 in t=0->1
𝐻&applies a H-gate to qubit #2 in t=0->1
Note for operators on different qubits, order doesn’t matter:
i.e. we can write ⟩|𝜓(𝑡 = 1) = 𝐻!𝐻& ⟩|00
(but ordering for same qubit operators does!)
t=0 t=1
qubit 1
qubit 2
⟩|𝜓(𝑡 = 1)
Single qubit gates on two-qubit states – examples:
⟩|𝜓(𝑡 = 1) = 𝐻&𝐻! ⟩|00 ⟩|𝜓(𝑡 = 1) = 𝐻!𝐻& ⟩|00
Either ordering between operators for different qubits gives the same:
same as
MULT20015 Elements of Quantum Computing
Lecture 5
Shorthand notation for multi-qubit states/operations
We write as: ⟩|𝜓(𝑡 = 2) = 𝑌!𝐻!𝑋&𝐻& ⟩|00 where
𝐻!applies a H-gate to qubit #1 in t=0->1, then
𝑌! applies a Y-gate to qubit #1 in t=1->2
𝐻&applies a H-gate to qubit #2 in t=0->1, then
𝑋& applies a X-gate to qubit #2 in t=1->2
NB. Order for different qubit operators doesn’t matter
i.e. we can write ⟩|𝜓(𝑡 = 2) = 𝑋&𝐻&𝑌!𝐻! ⟩|00
qubit 1
qubit 2
t=0 t=1 t=2
⟩|𝜓(𝑡 = 2)
Single qubit gates on two-qubit states – examples:
Either ordering between operators for different qubits gives the same:
⟩|𝜓(𝑡 = 2) = 𝑌!𝐻!𝑋&𝐻& ⟩|00 ⟩|𝜓(𝑡 = 2) = 𝑋&𝐻&𝑌!𝐻! ⟩|00same as
MULT20015 Elements of Quantum Computing
Lecture 5
Week 3
Lecture 5
5.1 Two-qubit systems
5.2 Two qubit example – independent Alice and Bob
5.3 General two qubit states: measurement and operations
Lecture 6
6.1 Two-qubit logic operations
6.2 Entanglement
Practice class 3
Two qubit states and operations
MULT20015 Elements of Quantum Computing
Lecture 5
Subject outline
Lecture topics (by week)
1 – Introduction to quantum computing and maths basics
2 – Single qubit representations and logic operations
3 – Two qubit states and logic gates
4 – Multi-qubit states and quantum arithmetic
5 – Basic quantum algorithms
6 – Period finding, cryptography and quantum factoring
7 – Shor’s algorithm, post-quantum crypto, quantum key distribution
8 – Quantum search algorithms
9 – Grover search applications, optimisation problems
10 – Solving optimisation problems on quantum computers
11 – Applications in quantum machine learning
12 – Real quantum computer devices
Assignment schedule:
#1: Hand out in Week 2
#2: Hand out in Week 8