Introduction to uantum Computing (IN2381) – W2023/2024 Exercise 4.
1 solution
Christian B. Mendl, Wang Yu, Keefe Huang
Exercise 4.1 (Basic quantum circuits)
(a) Find the matrix representation (with respect to the computational basis states |00i, |01i, |10i, |11i) of the
swap-gate |a, bi 7→ |b, ai, which is written in circuit form as
|ai |bi
|bi |ai
Also show that the swap operation is equivalent to the following sequence of three CNOT gates:
CNOT
Hint: You can either work directly with basis states, e.g. |a, bi 7→ |a, a ⊕ bi, or use matrix representations. In the latter case,
note that a sequence of gates like
A B C
(with A, B, C unitary 4 × 4 matrices) corresponds to the matrix product CBA since the circuit is read from left to right, but the
input vector in the matrix representation is multiplied from the right.
(b) Compute the output |ψi of the following “entanglement circuit” applied to the input |00i:
|0i H
|ψi
|0i
√1 1 1
with H = 2 1 −1 denoting the Hadamard gate.
(c) Build the CNOT gate from the controlled-Z gate and two Hadamard gates, and verify your construction.
Solution
(a) The swap gate interchanges |01i ↔ |10i, thus
1 0 0 0
0 0 1 0
Uswap =
0
.
1 0 0
0 0 0 1
Concerning the sequence of three CNOT-gates:
CNOT flipped CNOT CNOT
|a, bi 7→ |a, a ⊕ bi 7→ |a ⊕ (a ⊕ b), a ⊕ bi = |b, a ⊕ bi 7→ |b, (a ⊕ b) ⊕ bi = |b, ai .
Here we have used that a ⊕ a = 0 for a ∈ {0, 1}.
Alternative solution using matrix representations:
1 0 0 0 1 0 0 0
0 1 0 0 0 0 0 1
UCNOT = 0 0 0 1 ,
Uflipped CNOT =
0
,
0 1 0
0 0 1 0 0 1 0 0
1
which gives as matrix representation of the three CNOT-gates:
1 0 0 0
0 0 1 0
UCNOT · Uflipped CNOT · UCNOT =
0
= Uswap .
1 0 0
0 0 0 1
(b)
H⊗I |0i + |1i 1 CNOT 1
|00i 7→ √ |0i = √ (|00i + |10i) 7→ √ (|00i + |11i) = |ψi
2 2 2
(c) Based on the matrix representation of the Hadamard gate and Pauli matrices, one directly verifies that HZH =
X and H 2 = I (identity operation). Expressed in circuit form:
H Z H = X
and
H H = I
These properties lead to the following identity:
=
H Z H
The circuit on the right is the requested construction.