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
2
2 nm Tri-Gate Transistor
MULT20015 Elements of Quantum Computing Lecture 2
Lecture 1 recap
Intel.com
Gates Fins
|1i |0i
quantum superposition
8
|1ñ Y |0ñ |0ñ “and” |1ñ
measurement/observation
|0ñ
state collapse ® random outcome
Bubble: Brocken commons.wikimedia.org Bursting bubble: wallpaperswide.com
on “1” off “0”
Only “0” or “1” at a time in any given physical representation (transistor)
Notation for bits: Classical ® 0 and 1 Quantum ® |0ñ and |1ñ
One electron in quantum superposition.
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
Prepare
A qubit in a particular quantum superposition,
say with more 0 than 1 (as many times as we like)
|0ñY and |1ñ
Measure
quantum superposition
collapse
|0ñ ? or
|1ñ measurement
repeat the process…
Results
Analyse all outcomes
“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
Quantum systems are stochastic
Bubble: Brocken commons.wikimedia.org Bursting bubble: wallpaperswide.com
MULT20015 Elements of Quantum Computing
Lecture 2
Qubits – how we describe them mathematically
A qubit, e.g. an electron in an atom
|1ñ |0ñ
The qubit can be in |0ñ or |1ñ or both at the same time. The overall quantum state is denoted by |𝜓ñ
First let’s look at the case of no quantum superposition: | i = |0i or | i = |1i i.e. definitive scenarios, one state or the other (no surprises)
| i = |0i The electron is in the ground state
| i = |1i
| i=|1i Outcome always “1” ® probability: Prob[“1”] = 1.0
Before: measurement
Collapsesto:
Outcome always “0” ® probability: Prob[“0”] = 1.0
| i=|0i
The electron is in the excited state
Before: | i=|1i measurement
| i=|0i
Collapsesto:
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ñ
Maths: we describe |𝜓ñ as a linear combination of basis states over the linear space {|0ñ,|1ñ}: | i=a0|0i+a1|1i=✓ a0 ◆
a1
• a0 and a1 are the “quantum state amplitudes” (over C -> 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
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
a0
| i=a0|0i+a1|1i=wherea0anda1arecomplexnumbers.
a1 Complex numbers recap:
Im[z] 2
1 -2 -1 -1
𝑧 = 1 + 2𝑖
Re[z] 12
𝑧 = 1 − 2𝑖
𝑧 = −2 + 𝑖
𝑧 = 𝑥 + 𝑖𝑦
“Real” part is denoted by Re[𝑧] = 𝑥 “Imaginary” part is denoted by Im[𝑧] = 𝑦
𝑧 = −2 − 2𝑖 -2 𝑧” +𝑧! =(𝑥”+𝑖𝑦”)+(𝑥!+𝑖𝑦!)= 𝑥” +𝑥! +𝑖 𝑦” +𝑦!
Addition:
Multiplication: 𝑧”𝑧! = (𝑥”+𝑖𝑦”) 𝑥! + 𝑖𝑦! = 𝑥”𝑥! − 𝑦”𝑦! + 𝑖(𝑥”𝑦! + 𝑦”𝑥!)
Conjugate: 𝑧=𝑥+𝑖𝑦→𝑧∗ =𝑥−𝑖𝑦
𝑧𝑧∗ = 𝑥+𝑖𝑦 𝑥−𝑖𝑦 =𝑥! −𝑖𝑥𝑦+𝑖𝑦𝑥+𝑦! =𝑥! +𝑦! i.e.𝑧𝑧∗ =𝑥! +𝑦! =|𝑧|! i.e. 𝑧 = 𝑥! +𝑦!
Im[z] 𝑦
𝑧 = 𝑥 + 𝑖𝑦
Re[z]
|z| is referred to as the “modulus” or “magnitude”
𝑥
i= −1 ,andso𝑖! =−1
𝑧= 𝑥!+𝑦!
MULT20015 Elements of Quantum Computing Lecture 2
Complex numbers: polar notation
Im[z] 𝑦
z = 𝑥 + 𝑖𝑦 𝑧 sin𝜃
Cartesian: z = x + iy in terms of x=Re[z] and y=Im[z] Polar: z = 𝑟 (cos 𝜃 + 𝑖 sin 𝜃) = 𝑟 𝑒$%
NB:𝑒$% =cos𝜃+𝑖sin𝜃,𝑟= 𝑧 = 𝑥!+𝑦!
In the QUI, we use “polar notation”. e.g. for amplitudes in the state: | i = a0 |0i + a1 |1i = ✓ a0
Ignoring subscripts, consider a complex amplitude a
“phase” 𝜃 angle
Re[z] 𝑧cos𝜃 𝑥
a1 Im
|a| = pRe[a]2 + Im[a]2 ✓ = tan 1 (Im[a]/Re[a])
|a| ✓
Re
a=Re[a]+iIm[a]=|a|ei✓ !
For each complex amplitude we have a magnitude and phase angle:
| i=a |0i+a |1i=✓ a0 ◆
i✓ i✓
01
!| i=|a0|e 0 |0i+|a1|e 1 |1i a1
◆
𝑧= 𝑥!+𝑦!
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ñ
Maths: we describe |𝜓ñ as an “addition” of states over a linear space {|0ñ,|1ñ}: | i=a0|0i+a1|1i=✓ a0 ◆
• a0 and a1 are the “quantum state amplitudes” (complex numbers in general) ® tell us how much of |0ñ and |1ñ are in the superposition |𝜓ñ
a1
• 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
Back to qubit superposition and measurement. Amplitudes and probability:
Measurement
Prepared state |𝜓ñ
| i=a0|0i+a1|1i=✓ ◆
Outcome
“0”
|𝜓ñ “collapsed” to: | i!|0i
Outcome probability Prob[“0”]=|a0|2
a0 ?
a1
or
“1”
| i!|1i
Prob[“1”]=|a1|2
MULT20015 Elements of Quantum Computing Lecture 2
Examples
Assume for now the amplitudes are real:
Let’s prepare a qubit in that particular “60:40” superposition
Y
|𝜓ñ = (0.775) |0ñ + (0.633) |1ñ a0 a1
Measurement
|0ñ ? or
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
|1ñ
Bubble: Brocken commons.wikimedia.org Bursting bubble: wallpaperswide.com
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ñ
MULT20015 Elements of Quantum Computing Lecture 2
Examples
Assume the amplitudes a0 and a1 are real.
Quantum state (before)
| i=a0|0i+a1|1i=
Probability measuring 0
Probability measuring 1
a12
Histogram (many shots)
✓ a0 ◆
a1 a02
a02 + a12 = 1
1. a02
0 a12 0.
5 |0ñ |1ñ
state
11 ✓1◆21 ✓1◆21 1. | i=p2|0i+p2|1i p2 =2 p2 =2 0.
5
|0ñ |1ñ
state
| i=1|0i+p3|1i ✓1◆2 1 p3!2 3 1. 222=4=0
|0ñ |1ñ
24 0. 5
state
probability probability probability
MULT20015 Elements of Quantum Computing Lecture 2
Examples – cont.
Complex amplitudes:
Y
𝜓 = 0.775𝑒”# 0 + 0.633 𝑒$”#/& 1 |a0| 𝜃0 |a1| 𝜃1
Bubble: Brocken commons.wikimedia.org Bursting bubble: wallpaperswide.com
Measurement
|0ñ ? or
The probability of getting a
“0” outcome is given by:
|a0|2 = (0.775)2 = 0.6 Prob[“0”] = (0.775)2 = 0.6
The probability of getting a
“1” outcome is given by:
|a0|2 = (0.633)2 = 0.4 Prob[“1”] = (0.633)2 = 0.4
measurement
|1ñ
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 space over C which represents the state of a qubit.
We write the general state of a qubit in “ket” notation as: a0 | i=a0|0i+a1|1i= a1
Where the quantum amplitudes a0 and a1 are complex numbers.
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
| i=a0|0i+a1|1i=✓ a0 ◆ a1
For qubits we can use column vectors to represent a convenient basis for kets:
1
|0i= | i=a0|0i+a1|1i= a
a0
| 1 i = 01 Computational basis states
| i=a |0i+a |1i= a 0 , a 1 2 C
General qubit state
a0 and a1 are “amplitudes”
a0 0 0 11a1
MULT20015 Elements of Quantum Computing Lecture 2
Dual vectors
h|
A “bra” is a row vector .
| i=a0|0i+a1|1i= a0 For a qubit state, a1
| i = a0 a1
a0,a1 2C we define the corresponding dual vector
to be:
a0,a1 2C h|=[a⇤0 a⇤1]
MULT20015 Elements of Quantum Computing Lecture 2
Inner Product
h | i
A “braket” is an inner product
(analogous to dot product for vectors in 3D)
For two quantum states
We can define an inner product between them
h | i⌘h || i = ⇥ a ⇤ b ⇤ ⇤ dc
= a⇤c + b⇤d
|i=ab , | i=dc
MULT20015 Elements of Quantum Computing Lecture 2
Orthogonality
Two states are orthogonal if their inner product is zero h | i=0
“Z-basis” (computational basis) For |0iand |1i
“X-basis” (+/- states)
|0i + |1i For |+i= p2
|0i |1i | i= p2
h+| i=1⇥1 1⇤ 1 2 1
=0
These states are also orthogonal
⇥ ⇤
h0|1i= 1 0 01 =0
Computational basis states are orthogonal
MULT20015 Elements of Quantum Computing Lecture 2
Outer Product
| ih |
is an outer product
|i=ab , | i=dc |ih |=ab ⌦⇥c⇤ d⇤⇤
For two quantum states
We can define an outer (tensor) product between them:
=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 a quantum computer programming and simulation tool developed at the University of Melbourne, used in research and teaching.
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!
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
• youcreateaquantumprogram(“circuit”)
• execute(“compute”)ontheUoMquantumcomputersimulator • theresultsaresentbacktoyourQUIsessiontodisplay
qubits, initialised in the state |0ñ, with time lines left to right
State information card (SIC) showing more detail from the plot
More details: QUIspace.org
quantum state visualization at slider
Program editor – place logic operations on the qubits to create a “circuit”
Library of logical operations
Compute – runs program
Plotting controls
quantum computer simulator at UoM
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
| i=a0|0i+a1|1i=✓ a0 ◆ a1
! | i = |a0|ei✓0 |0i + |a1|ei✓1 |1i
90o
𝑎
0o
180o
𝑎 𝜃
-180o
270o -90o
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 𝑎’ = 0.816 × 𝑒$(‘.*+’ ,)
𝑎” = 0.577 × 𝑒$(.’.+” ,)
“matrix” notation (amplitudes in QUI polar form)
𝑎’ 𝑎”
0.816 × 𝑒$(‘.*+’ ,) 0.577 × 𝑒$(.’.+” ,)
“ket” notation (amplitudes in QUI polar form)
| i=a0|0i+a1|1i=✓ a0 ◆ a1
𝑎’|0⟩ + 𝑎”|1⟩ →
𝑎’|0⟩ + 𝑎”|1⟩ →
MULT20015 Elements of Quantum Computing Lecture 2
Amplitudes in the QUI
Quantum systems actually have wave-like properties. The complex state amplitudes a0 and a1 represent the magnitude and phase of this wave.
Im
✓
Re
✓a◆ i✓p i✓ 001
| i=a0|0i+a1|1i= !| i=|a0|e |0i+|a1|e |1i a1
Recall:
a = Re[a] + i Im[a] = |a|ei✓ ! |a| = Re[a]2 + Im[a]2 ✓ = tan 1 (Im[a]/Re[a])
ei✓ = cos ✓ + i sin ✓ In the QUI, phase is represented using an angular colour map, and probability by histogram,
e.g. consider two different single-qubit states:
state-1 state-2
! | i = |a0|ei✓0 |0i + |a1|ei✓1 |1i
|a0 |2
! | i = |a0|ei✓0 |0i + |a1|ei✓1 |1i |a1 |2
✓0 =⇡/2
✓1 =3⇡/4
! | i = |a0|ei✓0 |0i + |a1|ei✓1 |1i |a1 |2
| i = |a0|ei✓0 |0i + |a1|ei✓1 |1i |a0 |2
✓0 = 0
✓1 = ⇡/4
!
Probability
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:
| i=a0|0i+a1|1i=✓ a0 ◆ a1
In some circuit diagrams notation is:
Prob = |a0|2
Prob = |a1|2 (but we like QUI’s spinning lottery symbol)
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