MULT20015 Lecture 2 2021 v2
MULT20015 Elements of Quantum Computing
Lecture 2
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 2
Week 1
Lecture 1
1.1 A very brief history of computing
1.2 The quantum world and quantum computing
Lecture 2
2.1 The mathematics of quantum states
2.2 Complex numbers and quantum amplitudes
2.3 Basic linear algebra: ket and matrix notation
2.4 State representation in the QUI
Practice class 1
The Quantum User Interface (QUI), lecture 1 & 2 review exercises
MULT20015 Elements of Quantum Computing
Lecture 2
Lecture 1 recap
22 nm Tri-Gate Transistor
Gates
8
Fins
on “1”
off “0”
Intel.com
Only “0” or “1” at a time in any given
physical representation (transistor)
|0ñ “and” |1ñ
|0ñ
state collapse ® random outcome
quantum superposition measurement/observation
|1ñ
|0ñY
|0i
|1i
One electron in quantum
superposition.
Notation for bits:
Classical ® 0 and 1
Quantum ® |0ñ and |1ñ
Bubble: Brocken commons.wikimedia.org
Bursting bubble: wallpaperswide.com
MULT20015 Elements of Quantum Computing
Lecture 2
2.1 The mathematics of quantum states
MULT20015
Lecture 2
MULT20015 Elements of Quantum Computing
Lecture 2
Quantum bits and probabilities
|1ñ|0ñ
Y
A qubit in a particular
quantum superposition,
say with more 0 than 1
(as many times as we like)
Analyse all outcomes
|1ñ
|0ñ
“0” outcomes
Say 60 times out of 100 trials
Probability: Prob[“0”] ~ 60/100 = 0.6
“1” outcomes
Say 40 times out of 100 trials
Probability: Prob[“1”] ~ 40/100 = 0.4
repeat
the process…
measurement
? or
and
quantum
superposition
collapse
Prepare Measure Results
Quantum systems are stochasticBubble: Brocken commons.wikimedia.org
Bursting bubble: wallpaperswide.com
MULT20015 Elements of Quantum Computing
Lecture 2
Qubits – how we describe them mathematically
|0ñ
|1ñ
A qubit, e.g. an electron in an atom
First let’s look at the case of no quantum superposition: or
i.e. definitive scenarios, one state or the other (no surprises)
The qubit can be in |0ñ or |1ñ or both at the same time.
The overall quantum state is denoted by |𝜓ñ
The electron is in the ground state
| i = |0i
Outcome always “0” ® probability: Prob[“0”] = 1.0
measurement
Before:
| i = |0iCollapses to:
| i = |0i The electron is in the excited state
Outcome always “1” ® probability: Prob[“1”] = 1.0
measurement
Before:
Collapses to:
| i = |1i
| i = |1i
| i = |1i
| i = |0i | i = |1i
MULT20015 Elements of Quantum Computing
Lecture 2
Qubit maths – quantum superposition
Qubit in both |0ñ and |1ñ states
® i.e. |𝜓ñ is a quantum superposition of |0ñ and |1ñ
• a0 and a1 are the “quantum state amplitudes” (over ℂ -> complex numbers)
® tell us how much of |0ñ and |1ñ are in the superposition |𝜓ñ
• modulus squared of the amplitudes, |a0|2 and |a1|2 ® probabilities of measuring “0” or “1”
• total probability must be 1, so we have the “normalization” condition: |a0|2 + |a1|2 = 1
| i = a0 |0i+ a1 |1i =
✓
a0
a1
◆
Maths: we describe |𝜓ñ as a linear combination of basis states over the linear space {|0ñ,|1ñ}:
Let’s recap complex numbers…
MULT20015 Elements of Quantum Computing
Lecture 2
2.2 Complex numbers and quantum amplitudes
MULT20015
Lecture 2
MULT20015 Elements of Quantum Computing
Lecture 2
Complex numbers: basics
| i = a0 |0i+ a1 |1i =
a0
a1
�
Complex numbers recap:
𝑧 = 𝑥 + 𝑖𝑦
“Real” part is denoted by Re[𝑧] = 𝑥
“Imaginary” part is denoted by Im[𝑧] = 𝑦
where a0 and a1 are complex numbers.
Re[z]
1 2-2 -1
2
1
-1
-2
𝑧 = 1 + 2𝑖
𝑧 = 1 − 2𝑖
𝑧 = −2 + 𝑖
𝑧 = −2 − 2𝑖
Im[z]
i = −1 , and so 𝑖! = −1
𝑧” + 𝑧! = (𝑥”+𝑖𝑦”) + (𝑥!+𝑖𝑦!) = 𝑥” + 𝑥! + 𝑖 𝑦” + 𝑦!
Multiplication: 𝑧”𝑧! = (𝑥”+𝑖𝑦”) 𝑥! + 𝑖𝑦! = 𝑥”𝑥! − 𝑦”𝑦! + 𝑖(𝑥”𝑦! + 𝑦”𝑥!)
Addition:
𝑧 = 𝑥 + 𝑖𝑦 → 𝑧∗ = 𝑥 − 𝑖𝑦Conjugate:
𝑧 𝑧∗ = 𝑥 + 𝑖𝑦 𝑥 − 𝑖𝑦 = 𝑥! − 𝑖𝑥𝑦 + 𝑖𝑦𝑥 + 𝑦! = 𝑥! + 𝑦!
i.e. 𝑧 𝑧∗ = 𝑥! + 𝑦! = |𝑧|! i.e. 𝑧 = 𝑥! + 𝑦!
Re[z]
Im[z]
𝑧 = 𝑥 + 𝑖𝑦
𝑥
𝑦
𝑧
=
𝑥!
+ 𝑦
!
|z| is referred to as the “modulus” or “magnitude”
MULT20015 Elements of Quantum Computing
Lecture 2
Complex numbers: polar notation
In the QUI, we use “polar notation”. e.g. for amplitudes in the state:
Re[z]
Im[z]
z = 𝑥 + 𝑖𝑦
𝑥
𝑦
𝜃
𝑧
=
𝑥
! +
𝑦
!
𝑧 sin 𝜃
𝑧 cos 𝜃
“phase”
angle
Re
Im
✓
| i = a0 |0i+ a1 |1i =
✓
a0
a1
◆
a = Re[a] + i Im[a] = |a|ei✓ !
|a| =
p
Re[a]2 + Im[a]2
✓ = tan�1 (Im[a]/Re[a])
Ignoring subscripts, consider a complex amplitude a
Cartesian: z = x + iy in terms of x=Re[z] and y=Im[z]
Polar: z = 𝑟 (cos 𝜃 + 𝑖 sin 𝜃) = 𝑟 𝑒$%
NB: 𝑒$% = cos 𝜃 + 𝑖 sin 𝜃, 𝑟 = 𝑧 = 𝑥! + 𝑦!
| i = a0 |0i+ a1 |1i =
✓
a0
a1
◆
! | i = |a0|ei✓0 |0i+ |a1|ei✓1 |1i
|a|
For each complex amplitude we have a magnitude and phase angle:
MULT20015 Elements of Quantum Computing
Lecture 2
Continuing: Qubit maths – quantum superposition
Qubit in both |0ñ and |1ñ states
® i.e. |𝜓ñ is a quantum superposition of |0ñ and |1ñ
• a0 and a1 are the “quantum state amplitudes” (complex numbers in general)
® tell us how much of |0ñ and |1ñ are in the superposition |𝜓ñ
| i = a0 |0i+ a1 |1i =
✓
a0
a1
◆
Maths: we describe |𝜓ñ as an “addition” of states over a linear space {|0ñ,|1ñ}:
• modulus squared of the amplitudes, |a0|2 and |a1|2 ® probabilities of measuring “0” or “1”
• total probability must be 1, so we have the “normalization” condition: |a0|2 + |a1|2 = 1
MULT20015 Elements of Quantum Computing
Lecture 2
Qubit superposition, amplitudes, and measurement
| i = a0 |0i+ a1 |1i =
✓
a0
a1
◆
Prob[“0”] = |a0|2
Prob[“1”] = |a1|2
Outcome probability
Prepared state |𝜓ñ
|𝜓ñ “collapsed” to:Outcome
“0”
“1”
? or
| i ! |0i
| i ! |1i
Measurement
Back to qubit superposition and measurement.
Amplitudes and probability:
MULT20015 Elements of Quantum Computing
Lecture 2
Examples
Y
Let’s prepare a qubit in that
particular “60:40” superposition
Measurement
|1ñ
|0ñ
The probability of getting a
“0” outcome is given by:
Prob[“0”] = (0.775)2 = 0.6
The probability of getting a
“1” outcome is given by:
Prob[“1”] = (0.633)2 = 0.4
NB. In any given prepare-measure shot, the outcome will appear random!
But, by repeating the prepare-measurement process many times
the probabilities emerge from |𝜓ñ = (0.775) |0ñ + (0.633) |1ñ
measurement
? or
|𝜓ñ = (0.775) |0ñ + (0.633) |1ñ
a0 a1
Assume for now the amplitudes are real:
Bubble: Brocken commons.wikimedia.org
Bursting bubble: wallpaperswide.com
MULT20015 Elements of Quantum Computing
Lecture 2
Examples
Quantum state (before)
Assume the amplitudes a0 and a1 are real.
Probability measuring 1Probability measuring 0 Histogram (many shots)
| i =
1
p
2
|0i+
1
p
2
|1i
✓
1
p
2
◆2
=
1
2
✓
1
p
2
◆2
=
1
2
1.
0
0.
5 |0ñ |1ñ state
pr
ob
ab
ili
ty
| i =
1
2
|0i+
p
3
2
|1i
1.
0
0.
5 |0ñ |1ñ state
pr
ob
ab
ili
ty
| i = a0 |0i+ a1 |1i =
✓
a0
a1
◆
1.
0
0.
5 |0ñ |1ñ state
pr
ob
ab
ili
ty
a02 a12
a02
a12
✓
1
2
◆2
=
1
4
p
3
2
!2
=
3
4
a02 + a12 = 1
MULT20015 Elements of Quantum Computing
Lecture 2
Examples – cont.
Y
Measurement
|1ñ
|0ñ
The probability of getting a
“0” outcome is given by:
Prob[“0”] = (0.775)2 = 0.6
The probability of getting a
“1” outcome is given by:
Prob[“1”] = (0.633)2 = 0.4
measurement
? or
|a0|
Complex amplitudes:
Bubble: Brocken commons.wikimedia.org
Bursting bubble: wallpaperswide.com
𝜓 = 0.775𝑒”# 0 + 0.633 𝑒$”#/& 1
𝜃0 |a1| 𝜃1
|a0|2 = (0.775)2 = 0.6
|a0|2 = (0.633)2 = 0.4
MULT20015 Elements of Quantum Computing
Lecture 2
2.3 Basic linear algebra: ket and matrix notation
MULT20015
Lecture 2
MULT20015 Elements of Quantum Computing
Lecture 2
Dirac’s “ket” notation
• A lot of quantum mechanics comes down to linear algebra (matrices and vectors), but uses
a slightly different notation introduced by Dirac:
| i A “ket” is a element of a linear vector spaceover ℂ which represents the state of a qubit.
We write the general state of a qubit in “ket” notation as:
Where the quantum amplitudes a0 and a1 are complex numbers.
| i = a0 |0i+ a1 |1i =
a0
a1
�
The wave-like attributes of quantum systems are encapsulated by
amplitudes represented as complex numbers…
Ignoring subscripts: a = x + i y where x=Re[a] and y=Im[a]
MULT20015 Elements of Quantum Computing
Lecture 2
Linear Algebra and Dirac notation
|0i =
1
0
�
|1i =
0
1
�
Computational basis states
General qubit state
a0 and a1 are “amplitudes”
For qubits we can use column vectors to represent a convenient basis for kets:
| i = a0 |0i+ a1 |1i =
✓
a0
a1
◆
| i = a0 |0i+ a1 |1i =
a0
a1
�| i = a0 |0i+ a1 |1i =
a0
a1
�
a0, a1 2 C
MULT20015 Elements of Quantum Computing
Lecture 2
Dual vectors
A “bra” is a row vector .h |
For a qubit state,
we define the corresponding dual vector
to be:
| i =
a0
a1
�
a0, a1 2 C
| i = a0 |0i+ a1 |1i =
a0
a1
�
a0, a1 2 C
h | = [ a⇤0 a
⇤
1 ]
MULT20015 Elements of Quantum Computing
Lecture 2
Inner Product
A “braket” is an inner product
(analogous to dot product for vectors in 3D)h |�i
We can define an inner product between them
For two quantum states | i =
a
b
�
|�i =
c
d
�
,
h |�i ⌘ h ||�i
=
⇥
a⇤ b⇤
⇤ c
d
�
= a⇤c+ b⇤d
MULT20015 Elements of Quantum Computing
Lecture 2
Orthogonality
Two states are orthogonal if their inner product is zero
h |�i = 0
h0|1i =
⇥
1 0
⇤ 0
1
�
= 0
Computational basis
states are orthogonal
For and |+i =
|0i+ |1i
p
2
|�i =
|0i � |1i
p
2
For
h+|�i =
1
2
⇥
1 1
⇤ 1
�1
�
= 0
These states are also orthogonal
|0i
|1i
“Z-basis” (computational basis) “X-basis” (+/- states)
MULT20015 Elements of Quantum Computing
Lecture 2
Outer Product
is an outer product
We can define an outer (tensor) product between them:
For two quantum states | i =
a
b
�
|�i =
c
d
�
,
| i h�|
| i h�| =
a
b
�
⌦
⇥
c⇤ d⇤
⇤
=
ac⇤ ad⇤
bc⇤ bd⇤
�
…in case we need it later…
MULT20015 Elements of Quantum Computing
Lecture 2
2.4 State representation in the Quantum User Interface (QUI)
MULT20015
Lecture 2
MULT20015 Elements of Quantum Computing
Lecture 2
QUI: registration
The QUI is accessed through a web-based interface.
Step 1: Open a web browser (preferably Google Chrome or
Firefox), and go to QUIspace.org.
Step 2: Click on
Step 3: Sign up. You will need to create an account to
access QUI for the first time.
Follow the steps to create your account (email address and
answering a few simple questions).
Step 4: Once you have signed-up, start the QUI!
The QUI is a quantum computer programming and simulation tool developed at the University
of Melbourne, used in research and teaching.
Prior to practice class 1: register for the QUI as per above (you must use your UoM email)
In class 1: switch on expanded capabilities (number of qubits,…)
MULT20015 Elements of Quantum Computing
Lecture 2
The QUI structure
• you create a quantum program (“circuit”)
• execute (“compute”) on the UoM quantum computer simulator
• the results are sent back to your QUI session to display
Library of logical
operations
Plotting
controls
Compute – runs program
quantum state visualization at slider
qubits, initialised
in the state |0ñ,
with time lines
left to right
Program editor – place logic
operations on the qubits to
create a “circuit”
State information
card (SIC)
showing more detail
from the plot
quantum computer
simulator at UoM
More details: QUIspace.org
MULT20015 Elements of Quantum Computing
Lecture 2
Complex numbers in the QUI
Quantum User Interface (QUI) – UoM programming and simulation environment.
Quantum program in upper panel
Lower panel gives the mathematical representation
of the quantum state – i.e. the complex amplitudes
(at the time-step corresponding to the vertical slider)
a0 a1
𝑎
𝜃
𝑎
0o
90o
180o
270o -90o
-180o
! | i = |a0|ei✓0 |0i+ |a1|ei✓1 |1i
| i = a0 |0i+ a1 |1i =
✓
a0
a1
◆
MULT20015 Elements of Quantum Computing
Lecture 2
“Ket” and “Matrix” representations of quantum states
Consider the following state in the QUI environment:
a0 a1
! | i = |a0|ei✓0 |0i+ |a1|ei✓1 |1i
| i = a0 |0i+ a1 |1i =
✓
a0
a1
◆
𝑎’ = 0.816 × 𝑒$(‘.*+’ ,)
𝑎” = 0.577 × 𝑒$(.’.+” ,)
“ket” notation (amplitudes in QUI polar form)
“matrix” notation (amplitudes in QUI polar form)
𝑎’| ⟩0 + 𝑎”| ⟩1 →
0.816 × 𝑒$(‘.*+’ ,)
0.577 × 𝑒$(.’.+” ,)
𝑎’| ⟩0 + 𝑎”| ⟩1 →
𝑎’
𝑎”
MULT20015 Elements of Quantum Computing
Lecture 2
Amplitudes in the QUI
In the QUI, phase is represented using an angular colour map, and probability by histogram,
e.g. consider two different single-qubit states:
Quantum systems actually have wave-like properties. The complex state
amplitudes a0 and a1 represent the magnitude and phase of this wave.
ei✓ = cos ✓ + i sin ✓
Re
Im
✓
Pr
ob
ab
ili
ty
Recall:
| i = a0 |0i+ a1 |1i =
✓
a0
a1
◆
! | i = |a0|ei✓0 |0i+ |a1|ei✓1 |1i
a = Re[a] + i Im[a] = |a|ei✓ !
|a| =
p
Re[a]2 + Im[a]2
✓ = tan�1 (Im[a]/Re[a])
! | i = |a0|ei✓0 |0i+ |a1|ei✓1 |1i
! | i = |a0|ei✓0 |0i+ |a1|ei✓1 |1i
|a0|2
|a1|2
! | i = |a0|ei✓0 |0i+ |a1|ei✓1 |1i
! | i = |a0|ei✓0 |0i+ |a1|ei✓1 |1i
|a0|2
|a1|2
✓0 = 0 ✓0 = ⇡/2✓1 = ⇡/4 ✓1 = 3⇡/4
state-1 state-2
MULT20015 Elements of Quantum Computing
Lecture 2
QUI: measurement operation
In the QUI the measurement operation looks like this:
By default, measurements are made in the “computational basis” (i.e. 0 or 1).
When you run the circuit, the QUI will randomly select a measurement outcome
based on the amplitudes of the state at that point:
In some circuit diagrams notation is:
Prob =
Prob =
(but we like QUI’s spinning lottery symbol)
| i = a0 |0i+ a1 |1i =
✓
a0
a1
◆ |a0|
2
|a1|2
MULT20015 Elements of Quantum Computing
Lecture 2
Practice classes (aka “tutorials”)
Review and practice lecture concepts/content through QUI exercises.
Practice class sheets -> download from LMS and bring hard copy, and/or access in tutorial
Work through the exercises individually and/or groups
Demonstrator in prac-class there to help -> ask lots of questions!
MULT20015 Elements of Quantum Computing
Lecture 2
Week 1
Lecture 1
1.1 A very brief history of computing
1.2 The quantum world and quantum computing
Lecture 2
2.1 The mathematics of quantum states
2.2 Complex numbers and quantum amplitudes
2.3 Basic linear algebra: ket and matrix notation
2.4 State representation in the QUI
Practice class 1
The Quantum User Interface (QUI), lecture 1 & 2 review exercises
MULT20015 Elements of Quantum Computing
Lecture 2
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