MULT20015 Prac Class 3 2020 FINAL
MULT20015 Practice Class-3, Ó L. Hollenberg et al 2020-2021 1
MULT20015 Elements of Quantum Computing
Practice Class 3
Welcome to Practice Class-3 of MULT20015 Elements of Quantum Computing, covering
exercises relevant to the material presented in lectures in Week 3.
The purpose of this week’s exercises is to:
• implement two-qubit circuits, and understand the binary state representation
• investigate 1 and 2 qubit operations, and measurement on these systems
• investigate and understand the generation of entanglement
The exercises in these notes are to assist your understanding of the subject and may
require time outside of the practice class to complete.
1. Single qubit gates and measurement on two-qubit Systems
In quantum computing we need to become familiar with the binary representation of
information encoded on qubit systems, and the effect of logic operations and measurement
on these “binary” states.
Exercise 1.1 Set up a two-qubit system in the QUI, place a Hadamard in the first slot for
each qubit, and hit compute (see below):
Mathematically, the circuit has performed the operation:
We will often use the more convenient shorthand notation :
Based on this two-qubit state answer the following (renormalise the state where required):
What’s the probability of measuring any of the four basis states in the final state? _____
What’s the probability of measuring |0⟩ in the first qubit? _____
What’s the probability of measuring |0⟩ in the second qubit? _____
|0i ⌦ |0i ! (H ⌦H) |0i ⌦ |0i =
|0i+ |1i
p
2
⌦
|0i+ |1i
p
2
|00i ! H1H2 |00i =
(|0i+ |1i)
p
2
(|0i+ |1i)
p
2
=
1
2
(|00i+ |01i+ |10i+ |11i)
MULT20015 Practice Class-3, Ó L. Hollenberg et al 2020-2021 2
If you measure |0⟩ in qubit-1, what does the state collapse to? ________________________
If you measure |1⟩ in qubit-1, what does the state collapse to? ________________________
If you measure |0⟩ in qubit-2, what does the state collapse to? ________________________
If you measure |1⟩ in qubit-2, what does the state collapse to? ________________________
Add a measurement gate for qubit-1 after the Hadamard and investigate what happens (hit
compute a number of times), consulting the State Info Cards (SICs) for each basis state.
Delete the measurement gate on qubit-1 and add a measurement gate to qubit-2, repeat.
Exercise 1.2 Now we will repeat, but create a more general two-qubit state. Consider the
following operation:
Implementing the 𝑅!(𝜃”) operator on qubit-1 on the QUI as an R-gate with global phase
set to zero will transform the state as:
Before you program the QUI, we will do the maths to understand what is going on. Express
the final state of the following independent operations on qubit-1 and qubit-2 in the ket
basis {|00⟩, |01⟩, |10⟩, |11⟩} that QUI uses:
____________________________________________________________
Just to be sure you understand the QUI output with respect to the state above, fill in the
following tables (keeping rotation angle unspecified):
Binary
State index: (i,j) 𝑎#$ |𝑎#$| 𝜃#$ Prob(i,j)
00
01
10
11
Decimal
State index: (i) 𝑎# |𝑎#| 𝜃# Prob(i)
0
1
2
3
|00i ! | i = RX(✓R)1 H2 |00i =
RX(✓R)1 |0i = cos
✓R
2
|0i � i sin
✓R
2
|1i
|00i ! | i = RX(✓R)1 H2 |00i =
MULT20015 Practice Class-3, Ó L. Hollenberg et al 2020-2021 3
Based on this two-qubit state answer the following (don’t forget to renormalise as required):
What’s the probability of measuring any of the four basis states in the final state? _____
What’s the probability of measuring |0⟩ in the first qubit? _____
What’s the probability of measuring |0⟩ in the second qubit? _____
If you measure |0⟩ in qubit-1, what does the state collapse to? ________________________
If you measure |1⟩ in qubit-1, what does the state collapse to? ________________________
If you measure |0⟩ in qubit-2, what does the state collapse to? ________________________
If you measure |1⟩ in qubit-2, what does the state collapse to? ________________________
You are able to write the state in separable form as a product state (because there have
been no two-qubit gates linking the qubits yet). Verify your answers above by examining
this state in its separable form:
Program the corresponding circuit in the QUI (R-gate: X-axis, global phase zero) and
examine the output state probability distribution and SICs for various choices of 𝜃” . Perform
measurements on qubit-1 and qubit-2 (as per questions above) and make sure you
understand the outputs by moving the time slider through the circuit.
2. Two-qubit gates
A two-qubit gate acts on two qubits and performs a certain operation either on both
qubits, or on one of the qubits conditioned with the state of the other qubit.
CNOT Gate: Target qubit flips when control qubit is in “1” state. The circuit element
symbol and truth-table for the CNOT operation is:
On a general superposition (assuming qubit-1 is the control) we have:
| i =
✓
cos
✓R
2
|0i � i sin
✓R
2
|1i
◆ ✓
1
p
2
|0i+
1
p
2
|1i
◆
Input state: |#$%&’$(⟩|&*’+,&⟩ Output state: |#$%&’$(⟩|&*’+,&⟩
|0⟩|0⟩ |0⟩|0⟩
|0⟩|1⟩ |0⟩|1⟩
|1⟩|0⟩ |1⟩|1⟩
|1⟩|1⟩ |1⟩|0⟩
control
target
CNOT(a |00i+ b |01i+ c |10i+ d |11i) ! a |00i+ b |01i+ c |11i+ d |10i
MULT20015 Practice Class-3, Ó L. Hollenberg et al 2020-2021 4
NB. Another way to view CNOT in this example is that the amplitudes (c, d) of the |10⟩
and |11⟩ states have been switched.
SWAP Gate: States of qubit-1 and qubit-2 are interchanged. The circuit element symbol
and truth-table for the SWAP operation is:
On a general superposition we have:
NB. Equivalently, the amplitudes (b, c) of the |01⟩ and |10⟩ states have been switched.
Controlled Rotations: Perform given rotation R on target qubit if control/s is/are in the
“1” state (or you can specify control on “0” state – open circle).
QUI: right click on any single qubit gate and add (multiple) controls on “0” or “1”.
Exercise 2.1 Program each of the above gates in the QUI, using a non-trivial input state
(e.g. constructed as per Ex 1.2). Examine the outputs carefully and make sure you
understand how the states have been transformed.
Exercise 2.2 A SWAP gate can be constructed from 3 CNOTs as:
Show this is true for a completely general two-qubit state, 𝑎|00⟩ + 𝑏|00⟩ + 𝑐|00⟩ + 𝑑|00⟩. Now
verify on the QUI by creating a non-trivial state and experimenting – i.e. move the time
slider through the circuit to see and understand how the state changes.
Input state: |#$%&’ (⟩|#$%&’ *⟩ Output state: |#$%&’ (⟩|#$%&’ *⟩
|0⟩|0⟩ |0⟩|0⟩
|0⟩|1⟩ |1⟩|0⟩
|1⟩|0⟩ |0⟩|1⟩
|1⟩|1⟩ |1⟩|1⟩
qubit 1
qubit 2
SWAP(a |00i+ b |01i+ c |10i+ d |11i) ! a |00i+ b |10i+ c |01i+ d |11i
control
target
control
target
Logic: if control in “1” do R operation on target,
otherwise do nothing
Logic: if control in “0” do R operation on target,
otherwise do nothing
MULT20015 Practice Class-3, Ó L. Hollenberg et al 2020-2021 5
3. Entanglement generation
A key aspect of quantum behaviour exploited in a quantum computer is entanglement. In
the QUI we indicate the level of entanglement in the overall state at any given time point
by plotting the “bi-partite” entanglement entropy (i.e. between qubits above and below)
vertically on the time slider bar itself (white = no entanglement, red = max entanglement).
Exercise 3.1 Program a circuit to create a Bell-State:
Note that final state has maximal entanglement, as indicated by the scale shown in the
Control panel. Hover the mouse over the time slider between the top and bottom qubits
to see the actual entanglement entropy. What is the significance of the value for the Bell
state? If you move the time-slider back one time step to just after the qubit-1 Hadamard
you will see the time-slider indicates zero entanglement (since the state is separable at
this point).
NB for later: In general, (for more than 2 qubits) hover over the time-slider at a given
point to bring up the quantitative value of the entanglement between the upper and lower
groups at that point.
Exercise 3.2 Replace the Hadamard on qubit-1 in the above circuit with a RX (𝜃”) gate
from Ex. 1.2 (with zero phase) and examine the change in entanglement as a function of
𝜃” and fill in the table.
Rotation angle, qR (multiples of p) Prob[|00>] Prob[|11>] Entanglement
level
0
1/4
1/2
3/4
1
Optional: Add an overall global phase of 𝜋/2 to the R-gate and repeat. How does the
addition of the global phase in the R-gate affect the entanglement measure?
Exercise 3.3 Using one R-gate and one CNOT, program the QUI to produce the following
state: |𝜓⟩ = (|00⟩ + 𝑖|11⟩)/√2.
| i =
|00i+ |11i
p
2