CS计算机代考程序代写 algorithm MULT20015 Lecture 4 2021 FINAL v2

MULT20015 Lecture 4 2021 FINAL v2

MULT20015 Elements of Quantum Computing
Lecture 4

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 4

Week 2

Lecture 3
3.1 The Bloch Sphere representation for qubits
3.2 Quantum operations on qubits
3.3 Qubit gates in matrix form and the Pauli matrices

Lecture 4
4.1 The Pauli gates X, Y and Z and the QUI
4.2 Qubit operations around non-cartesian axes – H and R gates
4.3 Programming sequences over the qubit logic gate library
4.4 Note on the context and use of angles

Practice class 2
Bloch sphere and single qubit logic operations on the QUI

MULT20015 Elements of Quantum Computing
Lecture 4

Lecture 3 recap

| i = a0 |0i+ a1 |a1i ! cos
✓B
2

|0i+ sin
✓B
2
ei�B |1i| i = a0 |0i+ a1 |1i =


a0
a1

| ⟩𝜓 | ⟩𝜓!U

Qubits on the Bloch sphere:

Operations on
qubit states:

a0 |0i+ a1 |1i ! a1 |0i+ a0 |1i
X

!”#
!$#

!”
!$

|&#⟩ = * |&⟩
= 2 x 2matrix

Ket notation:
e.g. X-gate

Operations: matrix notation

Pauli Matrices

|0i

|1i

|0i � i|1i
p
2

|0i+ |1i
p
2

|0i � |1i
p
2

|0i+ i|1i
p
2

| i

!B

“B

!B =#/2, “B=0

!B=#/2, “B=#/2

!B=#/2, “B=#

!B =#/2, “B=3#/2

!B=0, “B=0

!B =#, “B=0

| 0i = U | i
AAACFXicbVDLSsNAFJ34rPUVdSVuBovoqiQi2I1Q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8Y8Fl2fSOAsAkcxxaGbCCChz6Hjj28Lv/MIQrI4elCTBLyQDCMWMEqUlvrmsTsGlbmJZOc5vsEOLmpc1H2zZtWtKfAysUtSQyVaffPHHcQ0DSFSlBMpe7aVKC8jQjHKIa+6qYSE0DEZQk/TiIQgvWz6hRyfaWWAg1joFyk8Vf9OZCSUchL6ujMkaiQXvUL8z+ulKmh4GYuSVEFEZ4uClGMV4yIPPGACqOITTQgVTN+K6YgIQpVObW6LL4jOJte52IspLJP2Zd226vb9Va3ZKBOqoBN0ii6Qja5RE92hFnIQRU/oBb2iN+PZeDc+jM9Z64pRzhyhORhfv/xhnrQ=AAACFXicbVDLSsNAFJ34rPUVdSVuBovoqiQi2I1QcOOygmkLTSiT6U07dPJgZiKUEPwMv8CtfoE7cevaD/A/nLRZ2NYDA+eecy/3zvETzqSyrG9jZXVtfWOzslXd3tnd2zcPDtsyTgUFh8Y8Fl2fSOAsAkcxxaGbCCChz6Hjj28Lv/MIQrI4elCTBLyQDCMWMEqUlvrmsTsGlbmJZOc5vsEOLmpc1H2zZtWtKfAysUtSQyVaffPHHcQ0DSFSlBMpe7aVKC8jQjHKIa+6qYSE0DEZQk/TiIQgvWz6hRyfaWWAg1joFyk8Vf9OZCSUchL6ujMkaiQXvUL8z+ulKmh4GYuSVEFEZ4uClGMV4yIPPGACqOITTQgVTN+K6YgIQpVObW6LL4jOJte52IspLJP2Zd226vb9Va3ZKBOqoBN0ii6Qja5RE92hFnIQRU/oBb2iN+PZeDc+jM9Z64pRzhyhORhfv/xhnrQ=

|0i

|1i

| i

| 0i

“Z” axis

“X” axis

“Y” axis

! = 0 11 0 Y =
0 −’
‘ 0 Z =

1 0
0 −1

hXi

hY i

|0i

|1i

“Z” axis

“X” axis

“Y” axis

|”!⟩

X-gate: rotate around X-axis by !

|”⟩

hXi

hY i

|0i

|1i

“Z” axis

“X” axis

“Y” axis

Z-gate: rotate around Z-axis by !

|”!⟩
|”⟩

hXi

hY i

|0i

|1i

“Z” axis

“X” axis

“Y” axis

Y-gate: rotate around Y-axis by !

|”!⟩

|”⟩

MULT20015 Elements of Quantum Computing
Lecture 4

4.1 The Pauli gates X, Y and Z and the QUI

MULT20015
Lecture 4

MULT20015 Elements of Quantum Computing
Lecture 4

Recap: the “Cartesian” quantum operations: X, Y, Z

| i ! | 0i

We can specify the state moving across the Bloch sphere in many ways, but the “Cartesian”
operations are very simple – a rotation of 𝜋 (180o) about any of X, Y, or Z axes:

The cartesian rotations are usually referred to as the “Pauli” operators X, Y, Z

NB. Perspectives not 100%
accurate! Rotations should
follow right-hand-rule.

hXi

hY i

|0i

|1i

“Z” axis

“X” axis

“Y” axis

|”!⟩

X-gate: rotate around X-axis by !

|”⟩

hXi

hY i

|0i

|1i

“Z” axis

“X” axis

“Y” axis

Z-gate: rotate around Z-axis by !

|”!⟩
|”⟩

hXi

hY i

|0i

|1i

“Z” axis

“X” axis

“Y” axis

Y-gate: rotate around Y-axis by !

|”!⟩

|”⟩

MULT20015 Elements of Quantum Computing
Lecture 4

Recap: the X gate in matrix form

|0i =

1
0


|1i =


0
1


| i = a0 |0i+ a1 |1i =


a0
a1


Recall “matrix”
notation:

| i =

a0
a1

a0, a1 2 C

𝑎” ⟩0 + 𝑎# ⟩1 =
𝑎”
𝑎#

⟶ 𝑎# ⟩0 + 𝑎” ⟩1 =
𝑎#
𝑎”

a0 |0i+ a1 |1i ! a1 |0i+ a0 |1i
X

Action of X-gate in “ket” form:

What is the X-gate in “matrix” form?

𝑎!
𝑎”


𝑎”
𝑎!

X

𝑎!
#

𝑎”
#

𝑎!
𝑎”

| ⟩𝜓! = 𝑈 | ⟩𝜓
= 2 x 2matrix

Operations in matrix representation:

Action of X-gate in matrix form:

i.e.

In matrix notation, in general:

X
𝑎”
𝑎#

= 0 1
1 0

𝑎”
𝑎#

=
𝑎#
𝑎”𝑋 =

0 1
1 0

MULT20015 Elements of Quantum Computing
Lecture 4

Recap: the X gate in matrix form – the Pauli matrices

| ⟩𝜓! = 𝑋 | ⟩𝜓
𝑎!
#

𝑎”
#

𝑎!
𝑎”=

0 1
1 0

𝑋 = 0 1
1 0

This is the so-called
Pauli X matrix…one of
three Pauli matrices
representing X, Y and Z
operations…

Y= 0 −𝑖
𝑖 0

Z= 1 0
0 −1

𝑋 = 0 1
1 0

All cartesian axes – the Pauli matrices for X, Y and Z:

hXi

hY i

|0i

|1i

“Z” axis

“X” axis

“Y” axis

|”!⟩

X-gate: rotate around X-axis by !

|”⟩

hXi

hY i

|0i

|1i

“Z” axis

“X” axis

“Y” axis

Z-gate: rotate around Z-axis by !

|”!⟩
|”⟩

hXi

hY i

|0i

|1i

“Z” axis

“X” axis

“Y” axis

Y-gate: rotate around Y-axis by !

|”!⟩

|”⟩

MULT20015 Elements of Quantum Computing
Lecture 4

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 4

Y Gate (the Y operator ): 𝜋 around Y-axis

Circuit symbol:

Matrix representation:

Action on ket states:

x

z

y

Y =


0 �i
i 0

Y (a0 |0i+ a1 |1i) =

0 �i
i 0

� 
a0
a1


=


�ia1
ia0

i.e. Y (a0 |0i+ a1 |1i) = �ia1 |0i+ ia0 |1i

a0 |0i+ a1 |1i ! �ia1 |0i+ ia0 |1i

Y (a0 |0i+ a1 |1i) =

0 �i
i 0

� 
a0
a1


=


�ia1
ia0

i.e. Y (a0 |0i+ a1 |1i) = �ia1 |0i+ ia0 |1i

a0 |0i+ a1 |1i ! �ia1 |0i+ ia0 |1i

QUI example:

Re

Im

i

-i

-1 +1p
3

2
|0i+

�i
2

|1i complexamplitudes

↵|0i+ �|1i ! ↵|1i+ �|0i↵|0i+ �|1i ! ↵|1i+ �|0i↵|0i+ �|1i ! ↵|1i+ �|0i↵|0i+ �|1i ! ↵|1i+ �|0i

�1
2

|0i+
i
p
3

2
|1i

MULT20015 Elements of Quantum Computing
Lecture 4

Z Gate (the Z operator): 𝜋 around Z-axis

Circuit symbol:

Matrix representation:

Action on ket states:

Z =


1 0
0 �1

� x

z

y

QUI example:

Re

Im

i

-i

-1 +1p
3

2
|0i+

�i
2

|1i complexamplitudes

Z (a0 |0i+ a1 |1i) =

1 0
0 �1

� 
a0
a1


=


a0
�a1

i.e. Z (a0 |0i+ a1 |1i) = a0 |0i � a1 |1i

a0 |0i+ a1 |1i ! a0 |0i � a1 |1i

↵|0i+ �|1i ! ↵|1i+ �|0i↵|0i+ �|1i ! ↵|1i+ �|0i↵|0i+ �|1i ! ↵|1i+ �|0i↵|0i+ �|1i ! ↵|1i+ �|0i

Z (a0 |0i+ a1 |1i) =

1 0
0 �1

� 
a0
a1


=


a0
�a1

i.e. Z (a0 |0i+ a1 |1i) = a0 |0i � a1 |1i

a0 |0i+ a1 |1i ! a0 |0i � a1 |1i

p
3

2
|0i+

i

2
|1i

MULT20015 Elements of Quantum Computing
Lecture 4 The Paulis and their action on computational states

(useful results for later on…)

𝑋 = 0 1
1 0

Y = 0 −𝑖
𝑖 0

Z = 1 0
0 −1

⟩𝑋|0 = 0 1
1 0

1
0
= 0

1
= ⟩|1

|0i =

1
0


|1i =


0
1

⟩𝑋|1 = 0 1
1 0

0
1
= 1

0
= ⟩|0

⟩𝑌|0 = 0 −𝑖
𝑖 0

1
0
= 𝑖 0

1
= ⟩𝑖|1

⟩𝑌|1 = 0 −𝑖
𝑖 0

0
1
= −𝑖 1

0
= −𝑖 ⟩|0

⟩𝑍|0 = 1 0
0 −1

1
0
= 1

0
= ⟩|0

⟩𝑍|1 = 1 0
0 −1

0
1
= − 0

1
= − ⟩|1

Computational basis states: ket <-> matrix conversion:

⟩𝑍|0 = ⟩|0

⟩𝑍|1 = ⟩−|1

⟩𝑌|0 = 𝑖 ⟩|1

⟩𝑌|1 = ⟩−𝑖|0

⟩𝑋|0 = ⟩|1

⟩𝑋|1 = ⟩|0

x

z

y

MULT20015 Elements of Quantum Computing
Lecture 4

The QUI gate library

So far we have covered the Pauli operations X, Y, Z…but there are other single qubit
gates in the QUI library related to Z – the so-called S and T operations…

The Pauli
gates X, Y, Z

The S and T
gates are

related to Z

i.e. rotations
about the Z-axis
but by different

angles.

MULT20015 Elements of Quantum Computing
Lecture 4

S Gate (the S operator ): Z-axs, 𝜋/2 rotation

Circuit symbol:

Matrix representation:

Action on ket states:

S =


1 0
0 i

� x

z

y

QUI example:

Re

Im

i

-i

-1 +1p
3

2
|0i+

�i
2

|1i complexamplitudes

↵|0i+ �|1i ! ↵|1i+ �|0i↵|0i+ �|1i ! ↵|1i+ �|0i↵|0i+ �|1i ! ↵|1i+ �|0i↵|0i+ �|1i ! ↵|1i+ �|0i

p
3

2
|0i+

1

2
|1i

S(a0 |0i+ a1 |1i) =

1 0
0 i

◆✓
a0
a1


=


a0
ia1


= a0 |0i+ ia1 |1i

a0 |0i+ a1 |1i ! a0 |0i+ ia1 |1i

S (a0 |0i+ a1 |1i) =

1 0
0 i

� 
a0
a1


=


a0
ia1

i.e. S (a0 |0i+ a1 |1i) = a0 |0i+ ia1 |1i

a0 |0i+ a1 |1i ! a0 |0i+ ia1 |1i

MULT20015 Elements of Quantum Computing
Lecture 4

T Gate (the T operator ): Z-axis, 𝜋/4 rotation

Circuit symbol:

Matrix representation:

Action on ket states:

T =


1 0
0 ei⇡/4

� x

z

y

QUI example:

Re

Im

i

-i

-1 +1p
3

2
|0i+

�i
2

|1i complexamplitudes

T (a0 |0i+ a1 |1i) =

1 0
0 ei⇡/4

� 
a0
a1


=


a0

ei⇡/4a1

i.e. T (a0 |0i+ a1 |1i) = a0 |0i+ ei⇡/4a1 |1i

a0 |0i+ a1 |1i ! a0 |0i+ ei⇡/4a1 |1i

↵|0i+ �|1i ! ↵|1i+ �|0i↵|0i+ �|1i ! ↵|1i+ �|0i↵|0i+ �|1i ! ↵|1i+ �|0i↵|0i+ �|1i ! ↵|1i+ �|0i

T (a0 |0i+ a1 |1i) =

1 0
0 ei⇡/4

� 
a0
a1


=


a0

ei⇡/4a1

i.e. T (a0 |0i+ a1 |1i) = a0 |0i+ ei⇡/4a1 |1i

a0 |0i+ a1 |1i ! a0 |0i+ ei⇡/4a1 |1i

p
3

2
|0i+

�iei⇡/4

2
|1i

MULT20015 Elements of Quantum Computing
Lecture 4

4.2 Qubit operations around non-cartesian axes – H and R gates

MULT20015
Lecture 4

MULT20015 Elements of Quantum Computing
Lecture 4

The Hadamard gate H

Rotation about “X+Z” axis,
given by 𝒏 = (1,0,1)/ 2

The Hadamard gate H is one of the most important – it generates superposition states.

Unlike the X, Y and Z gates which rotate about one of the cartesian axes, the H-gate
rotates about the X+Z axis (or unit vector) by an angle 𝜋.

hXi

hY i

|0i

|1i

| i

| 0i
!R = ”

“Z” axis

“X” axis

“Y” axis

|0i

|0i+ |1i
p
2

X+Z

X+Z

|0i � |1i
p
2

|1i

⟩|0 ⟶
⟩0 + ⟩1
2

⟩|1 ⟶
⟩0 − ⟩1
2

MULT20015 Elements of Quantum Computing
Lecture 4

The Hadamard gate H

H-gate on a general superposition state:

|0i

|0i+ |1i
p
2

X+Z X+Z

|0i � |1i
p
2

|1i

⟩|0 ⟶
⟩0 + ⟩1
2

⟩|1 ⟶
⟩0 − ⟩1
2

H-gate on the computational states:

𝑎! ⟩0 + 𝑎” ⟩1 =
𝑎!
𝑎”

⟶ 𝑎!
⟩0 + ⟩1
2

+ 𝑎”
⟩0 − ⟩1
2

=
𝑎! + 𝑎”

2
⟩|0 +

𝑎! − 𝑎”
2

⟩|1 ⟶
1
2
𝑎! + 𝑎”
𝑎! − 𝑎”

𝑎!
#

𝑎”
#

𝑎!
𝑎”

| ⟩𝜓! = 𝐻 | ⟩𝜓
= 2 x 2matrix

H =
1
p
2


1 1
1 �1

(Ex. check it)

MULT20015 Elements of Quantum Computing
Lecture 4

H Gate (the H operator ): 𝜋 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 4

Rotations about arbitrary axes – R-gate

The R-gate will allow you to perform a rotation around an arbitrary axis 𝒏 by angle 𝜃R :

Exercise 3.3 To construct our example state, start from a blank 1-qubit circuit
and choose the R-gate from the gate library (for now, don’t worry about what it
is or how it works). Click the R-gate into the first time block. Once placed in the
circuit right click on the R-gate in the circuit to bring up the editable gate menu:

Edit Parameters -> set axis to X, rotation angle to !” = p$, and global phase to
zero.

Hit compute and the QUI output will look like the following (bottom right):

X axis, i.e. 𝒏 = (1,0,0)
Rotation angle set to 𝜃$ =

p
%

|0i !
p
3

2
|0i+

�i
2

|1i = |0i+ |1i

| ⟩𝜓 =| ⟩0 | ⟩𝜓! =
3
2
| ⟩0 +

−𝑖
2
| ⟩1

hXi

hY i

|0i

|1i

| i
| 0i

Rotation
axis n

!R

“Z” axis

“X” axis

“Y” axis

You have done this in Prac Class 1

𝑅𝒏 𝜃$ → 𝑅(𝟏,𝟎,𝟎)
p
3

or 𝑅𝑿
p
%

𝑅𝒏(𝜃$)

p/3
0o

90o

180o

270o -90o

-180o

MULT20015 Elements of Quantum Computing
Lecture 4

Arbitrary axis rotation – coding in QUI

Coding an arbitrary rotation gate in QUI – R-gate

The “parameters” menu allows you to specify axis and angle:

Cartesian cords for
axis of rotation n

Angle of rotation
𝜃R about n

Global phase 𝜃g :
generally

set this to zero unless
otherwise directed!

NB. QUI normalises axis for you:
e.g. X axis, i.e. 𝒏 = (1,0,0) -> enter (1,0,0)

hXi

|0i

|1i

| i
| 0i

Rotation
axis n

!R

“Z” axis

“X” axis

“Y” axis

e.g. X+Z axis, i.e. 𝒏 = (1,0,1)/ 2 -> enter (1,0,1)

(entries can be decimals)

MULT20015 Elements of Quantum Computing
Lecture 4

4.3 Programming sequences over the qubit logic gate library

MULT20015
Lecture 4

MULT20015 Elements of Quantum Computing
Lecture 4

The QUI gate library

Now we have covered the entire QUI library of single qubit logic operations…

The QUI gate
library for

single qubit
logic operations
& measurement

2 & 3 qubit
logic gates

-> allows us
to process
“quantum”
information

MULT20015 Elements of Quantum Computing
Lecture 4

Recall: Paulis and their action on computational states

𝑋 = 0 1
1 0

Y = 0 −𝑖
𝑖 0

Z = 1 0
0 −1

⟩𝑋|0 = 0 1
1 0

1
0
= 0

1
= ⟩|1

|0i =

1
0


|1i =


0
1

⟩𝑋|1 = 0 1
1 0

0
1
= 1

0
= ⟩|0

⟩𝑌|0 = 0 −𝑖
𝑖 0

1
0
= 𝑖 0

1
= ⟩𝑖|1

⟩𝑌|1 = 0 −𝑖
𝑖 0

0
1
= −𝑖 1

0
= −𝑖 ⟩|0

⟩𝑍|0 = 1 0
0 −1

1
0
= 1

0
= ⟩|0

⟩𝑍|1 = 1 0
0 −1

0
1
= − 0

1
= − ⟩|1

Computational basis states: ket <-> matrix conversion:

⟩𝑍|0 = ⟩|0

⟩𝑍|1 = ⟩−|1

⟩𝑌|0 = 𝑖 ⟩|1

⟩𝑌|1 = ⟩−𝑖|0

⟩𝑋|0 = ⟩|1

⟩𝑋|1 = ⟩|0

MULT20015 Elements of Quantum Computing
Lecture 4

Programming sequences of qubit logic operations

Let’s look at a simple quantum program.

You are asked to code the following sequence of operations in QUI:

How does this look mathematically, in say “ket” notation?

You are tempted to write | ⟩𝜓 𝑡 = 3 = 𝑋 𝑌 𝑍 ⟩|0 -> this is not correct!

In QUI (or any quantum circuit), time naturally goes from left to right, but in maths the
operations are in the order they are applied:

Time step (t) Operation | ⟩𝜓(𝒕)

0 – ⟩|0

1 X X ⟩|0 = ⟩|1

2 Y Y ⟩|1 = – i ⟩|0
3 Z Z(- i ⟩|0 ) = – i ⟩|0

| ⟩𝜓 𝑡 = 3 = 𝑍 ⟩|𝜓 𝑡 = 2 = 𝑍 𝑌 ⟩|𝜓 𝑡 = 1 = 𝑍 (𝑌(𝑋 ⟩|0 ))

| ⟩𝜓 𝑡 = 3 = 𝑍 𝑌𝑋 ⟩|0
i.e. exactly the opposite sequence
to what you program in the QUIi.e. in ket form the program is:

MULT20015 Elements of Quantum Computing
Lecture 4

Operations and operators – fun facts

In quantum mechanics, unitary operators acting on quantum states produce new
quantum states. These operators can be described by unitary matrices.

The operator U is a unitary operator (reversible), i.e. we have: U†U = I
AAACC3icbVDLSsNAFJ34rPXRqEs3g0VwVRIR7EYouNFdBdMW2lgmk5t26GQSZiZCCf0Ev8CtfoE7cetH+AH+h9M2C9t64MLhnHs5lxOknCntON/W2vrG5tZ2aae8u7d/ULEPj1oqySQFjyY8kZ2AKOBMgKeZ5tBJJZA44NAORjdTv/0EUrFEPOhxCn5MBoJFjBJtpL5d8R57IRkMQGIPX+O7vl11as4MeJW4BamiAs2+/dMLE5rFIDTlRKmu66Taz4nUjHKYlHuZgpTQERlA11BBYlB+Pnt8gs+MEuIokWaExjP170VOYqXGcWA2Y6KHatmbiv953UxHdT9nIs00CDoPijKOdYKnLeCQSaCajw0hV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s3g0VwVRIR7EYouNFdBdMW2lgmk5t26GQSZiZCCf0Ev8CtfoE7cetH+AH+h9M2C9t64MLhnHs5lxOknCntON/W2vrG5tZ2aae8u7d/ULEPj1oqySQFjyY8kZ2AKOBMgKeZ5tBJJZA44NAORjdTv/0EUrFEPOhxCn5MBoJFjBJtpL5d8R57IRkMQGIPX+O7vl11as4MeJW4BamiAs2+/dMLE5rFIDTlRKmu66Taz4nUjHKYlHuZgpTQERlA11BBYlB+Pnt8gs+MEuIokWaExjP170VOYqXGcWA2Y6KHatmbiv953UxHdT9nIs00CDoPijKOdYKnLeCQSaCajw0hVDLzK6ZDIgnVpquFlECSEeiJ6cVdbmGVtC5qrlNz7y+rjXrRUAmdoFN0jlx0hRroFjWRhyjK0At6RW/Ws/VufVif89U1q7g5Rguwvn4B0EGaQw==

Matrix rep: 𝑈- <-> taking the transpose (t) and complex conjugate (*): U † = U t⇤
AAACDnicbVDLSsNAFJ34rPUV69LNYBHERUlEsBuh4MZlBdMW2rRMprft0MmDmRuxhP6DX+BWv8CduPUX/AD/w6TNwrYeuHA4517O5XiRFBot69tYW9/Y3Nou7BR39/YPDs2jUkOHseLg8FCGquUxDVIE4KBACa1IAfM9CU1vfJv5zUdQWoTBA04icH02DMRAcIap1DNLTrfTZ8MhKHpDnW6CF9OeWbYq1gx0ldg5KZMc9Z750+mHPPYhQC6Z1m3bitBNmELBJUyLnVhDxPiYDaGd0oD5oN1k9vuUnqVKnw5ClU6AdKb+vUiYr/XE99JNn+FIL3uZ+J/XjnFQdRMRRDFCwOdBg1hSDGlWBO0LBRzlJCWMK5H+SvmIKcYxrWshxVNsDJj1Yi+3sEoalxXbqtj3V+VaNW+oQE7IKTknNrkmNXJH6sQhnDyRF/JK3oxn4934MD7nq2tGfnNMFmB8/QLEk5vsAAACDnicbVDLSsNAFJ34rPUV69LNYBHERUlEsBuh4MZlBdMW2rRMprft0MmDmRuxhP6DX+BWv8CduPUX/AD/w6TNwrYeuHA4517O5XiRFBot69tYW9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ja5RE92hFnIQRU/oBb2iN+PZeDc+jM9Z64pRzhyhORhfv/xhnrQ=

The new state is given by:

𝑋 = 0 1
1 0

Y = 0 −𝑖
𝑖 0

Z = 1 0
0 −1

e.g. consider the Pauli operations in matrix representation:
Ex.

Show that 𝑈- = 𝑈 for X, Y and Z
and

Show that 𝑈-𝑈 = 𝐼 for X, Y and Z
(𝐼 is the 2×2 identity)

Also, operators generally don’t commute – i.e. for two operators acting sequentially, in general
the order matters:

⟩𝑈=𝑈>|𝜓 ≠ ⟩𝑈>𝑈=|𝜓

MULT20015 Elements of Quantum Computing
Lecture 4

Operations don’t commute – order matters!

Time step
(t)

Operatio
n

| ⟩𝜓(𝒕)

0 – ⟩|0

1 X X ⟩|0 = ⟩|1

2 Y Y ⟩|1 = – i ⟩|0

⟩|𝜓 𝑡 = 2 = 𝑌𝑋 ⟩|0 = − i ⟩|0

Time step
(t)

Operatio
n

| ⟩𝜓(𝒕)

0 – ⟩|0

1 Y Y ⟩|0 = i ⟩|1
2 X X(i ⟩|1 ) = i ⟩|0

⟩|𝜓 𝑡 = 2 = 𝑋𝑌 ⟩|0 = i ⟩|0

Same |a0|2 (same probability), but different phase -> different states

MULT20015 Elements of Quantum Computing
Lecture 4

Follow the evolution on the Bloch sphere…

etc…

MULT20015 Elements of Quantum Computing
Lecture 4

4.4 Note on the context and use of angles

MULT20015
Lecture 4

MULT20015 Elements of Quantum Computing
Lecture 4

Note 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 4

Week 2

Lecture 3
3.1 The Bloch Sphere representation for qubits
3.2 Quantum operations on qubits
3.3 Qubit gates in matrix form and the Pauli matrices

Lecture 4
4.1 The Pauli gates X, Y and Z and the QUI
4.2 Qubit operations around non-cartesian axes – H and R gates
4.3 Programming sequences over the qubit logic gate library
4.4 Note on the context and use of angles

Practice class 2
Bloch sphere and single qubit logic operations on the QUI

MULT20015 Elements of Quantum Computing
Lecture 4

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