Assignment_2
Assignment_2
Assignment 2
May 9, 2025
2.1
r · σ := rx σx + ry σy + rz σz ∈ C2×2
(a) Show that r · σ is Hermitian and unitary for all r ∈ R3 such that ∥r∥ = 1.
U = eiα eiθr·σ
(a) We will start by showing that the matrix r · σ is, in fact, hermitian. This can easily be showed,
r · σ = rx · σx + ry · σy + rz · σz ,
(r · σ)(r · σ)† = rx2 · σx2 + ry2 · σy2 + rz2 · σz2 = (rx2 + ry2 + rz2 )I2 ,
Where the crossed terms between Pauli matrices have vanished because of the anticonmutation
property of the Pauli matrices, σi ·σj = −σj ·σi . It also has been used the fact that σi2 = I2 for all
Pauli matrices. Then it is clear that for the unitary condition to be satisfied ((r · σ)(r · σ)† = I2 ),
it is needed ∥r∥2 = 1, this is, ∥r∥ = 1.
(b) We demonstrate that any unitary matrix U ∈ C2×2 can be expressed as:
U = eiα eiθr·σ
where α, θ ∈ R, r ∈ R3 is a unit vector (∥r∥ = 1), σ = (σx , σy , σz ) are the Pauli matrices.
We will start by stating some facts prior to getting into the proof.
1
We know that any unitary matrix U satisfies U † U = I. For 2 × 2 matrices, we can write:
a b
U = eiα , with |a|2 + |b|2 = 1 (1)
−b∗ a∗
where α ∈ R and a, b ∈ C.
Any unit vector r = (rx , ry , rz ) gives:
rz rx − iry
r · σ = rx σx + ry σy + rz σz =
rx + iry −rz
2.2
(a) Write a circuit that implements the CZ gate using only single-qubit unitaries and CNOTs.
(b) Show that the CZ gate with the control in the second qubit and the target in the first qubit is
the same as the CZ gate with the control in the first qubit and the target in the second qubit.
(c) Write a circuit that implements the CNOT gate with the control in the second qubit and the
target in the first qubit using only single-qubit unitaries and CNOTs with the control in the first
qubit and the target in the second qubit.
(a) In order to solve this question we need to find a unitary of the following form,
U = |0⟩⟨0| ⊗ I2 + |1⟩⟨1| ⊗ σz = CZ.
H H
Now, we check if this is correct, the unitary of this two-qubit circuit is,
2
(b) First of all we will define the notation that will be used during this part of the exercise.
CZcontrol=1,target=2 = CZ1,2 .
Now, we can clearly display the expression for each of the gates.
We can easily prove that these two expressions are the same by evaluating the matrices,
1 0 0 0
1 0 1 0 0 0 1 0 0 1 0 0
CZ1,2 = ⊗ + ⊗ =0 0 1 0 .
0 0 0 1 0 1 0 −1
0 0 0 −1
1 0 0 0
1 0 1 0 1 0 0 0 0 1 0 0
CZ2,1 = ⊗ + ⊗ =0 0 1 0 .
0 1 0 0 0 −1 0 1
0 0 0 −1
CZ1,2 |x1 x2 ⟩ = |x1 ⟩σzx1 |x2 ⟩ = (−1)x1 x2 |x1 x2 ⟩ = σzx2 |x1 ⟩ ⊗ |x2 ⟩ = CZ2,1 |x1 x2 ⟩.
(c) The circuit that satisfies the requirements from the exercise is the following,
H H
H H
After having this, we just have to prove that this circuit’s unitary operator coincides with the
one from a CNOT gate with the control in the second qubit and the target in the first one.
The unitary from the above circuit is the following,
U = (H ⊗ H) · CN OT1,2 · (H ⊗ H),
where CN OT1,2 is the CN OT gate with the control on the first qubit and the target on the
second qubit.
3
2.3
(a) What are the probability distributions on measurement outcomes if we input to this circuit the
elements of the computational basis and we measure each qubit at the end in the computational
basis?
(b) Write down a circuit using only single-qubit unitaries and CNOTs that implements the inverse
of U .
(a) In this exercise, we are given a two-qubit quantum circuit and asked to compute the output
probability distributions for all computational basis inputs |00⟩ , |01⟩ , |10⟩ , |11⟩ after applying
the circuit and measuring both qubits in the computational basis. The circuit is as follows:
Z H
We solve this by analysing the evolution of each computational basis input step by step through
the sequence of gates.
We begin by analysing the evolution of the input state |00⟩ through the circuit. The first gate
is a CNOT with qubit 0 as control and qubit 1 as target. Since the control qubit is in state |0⟩,
the target qubit remains unchanged, and the state remains |00⟩.
Next, a Z gate is applied to qubit 0. As Z |0⟩ = |0⟩, the state is again unchanged, and we still
have |00⟩.
Following this, a Hadamard gate is applied to qubit 1. The transformation H |0⟩ = √1 (|0⟩ + |1⟩)
2
yields the intermediate state:
1 1
|0⟩ ⊗ √ (|0⟩ + |1⟩) = √ (|00⟩ + |01⟩).
2 2
The next gate is a CNOT with qubit 1 as control and qubit 0 as target. This gate flips the target
qubit (qubit 0) when the control (qubit 1) is |1⟩. The term |00⟩ remains unchanged, while |01⟩
becomes |11⟩. Thus, the state becomes:
1
√ (|00⟩ + |11⟩).
2
Finally, we apply a Hadamard gate to qubit 0. Recall that H |0⟩ = √1 (|0⟩ + |1⟩) and H |1⟩ =
2
√1 (|0⟩ − |1⟩). Applying H to qubit 0 in each term, we obtain:
2
1 1 1
√ √ (|0⟩ + |1⟩) |0⟩ + √ (|0⟩ − |1⟩) |1⟩ ,
2 2 2
which simplifies to:
1
(|00⟩ + |10⟩ + |01⟩ − |11⟩).
2
This is the final state before measurement. Since the amplitude of each computational basis state
has magnitude 21 , the probability of measuring any basis state is 14 . Therefore, the measurement
outcome is uniformly distributed over all four basis states.
Measuring this state in the computational basis yields equal probabilities for each outcome:
1
P (00) = P (01) = P (10) = P (11) = .
4
4
We now consider the input state |01⟩. The first gate in the circuit is a CNOT with qubit 0 as
control and qubit 1 as target. Since the control qubit is in state |0⟩, the target qubit remains
unchanged, and the state is still |01⟩.
Next, we apply a Z gate to qubit 0. As before, since Z |0⟩ = |0⟩, the state remains |01⟩.
We then apply a Hadamard gate to qubit 1. The transformation H |1⟩ = √1 (|0⟩ − |1⟩) gives the
2
intermediate state:
1 1
|0⟩ ⊗ √ (|0⟩ − |1⟩) = √ (|00⟩ − |01⟩).
2 2
The next gate is a CNOT with qubit 1 as control and qubit 0 as target. This flips the target
qubit when the control qubit is |1⟩. In our case, |00⟩ remains unchanged and |01⟩ becomes |11⟩,
so the state becomes:
1
√ (|00⟩ − |11⟩).
2
Finally, a Hadamard gate is applied to qubit 0. Applying H |0⟩ = √1 (|0⟩ + |1⟩) and H |1⟩ =
2
√1 (|0⟩ − |1⟩), we obtain:
2
1 1 1
√ √ (|0⟩ + |1⟩) |0⟩ − √ (|0⟩ − |1⟩) |1⟩ ,
2 2 2
which simplifies to:
1
(|00⟩ + |10⟩ − |01⟩ + |11⟩).
2
As in the previous case, each computational basis state appears with amplitude ± 12 , and hence
all measurement outcomes occur with equal probability:
1
P (00) = P (01) = P (10) = P (11) = .
4
We now do the same with the input state |10⟩. The first gate is a CNOT with control qubit 0
and target qubit 1. Since the control is |1⟩, the target flips, and the state becomes |11⟩.
Next, a Z gate is applied to qubit 0. Because Z |1⟩ = − |1⟩, we obtain the state − |11⟩.
Applying a Hadamard gate to qubit 1, and using H |1⟩ = √1 (|0⟩ − |1⟩), we get:
2
1 1
− |1⟩ ⊗ √ (|0⟩ − |1⟩) = − √ (|10⟩ − |11⟩).
2 2
The subsequent CNOT gate has qubit 1 as control and qubit 0 as target. This flips the target
qubit in the |11⟩ term, changing it to |01⟩, while |10⟩ remains unchanged. The state becomes:
1
− √ (|10⟩ − |01⟩).
2
A final Hadamard is applied to qubit 0. Using the same Hadamard action as before, the state
transforms as follows:
1 1 1
−√ √ (|0⟩ + |1⟩) |0⟩ − √ (|0⟩ − |1⟩) |1⟩ ,
2 2 2
which simplifies to:
1
− (|00⟩ − |10⟩ + |01⟩ + |11⟩).
2
Again, all computational basis states appear with equal amplitude in magnitude, implying a
uniform probability distribution on measurement:
1
P (00) = P (01) = P (10) = P (11) = .
4
5
Again, we analyse the circuit, this time acting on the input state |11⟩. The first CNOT gate flips
the target qubit (qubit 1), because the control is |1⟩. The state becomes |10⟩.
Next, the Z gate is applied to qubit 0. Since Z |1⟩ = − |1⟩, the state becomes − |10⟩.
Applying a Hadamard gate to qubit 1, with H |0⟩ = √1 (|0⟩ + |1⟩), gives:
2
1 1
− |1⟩ ⊗ √ (|0⟩ + |1⟩) = − √ (|10⟩ + |11⟩).
2 2
The next gate is a CNOT with control qubit 1 and target qubit 0. This flips the target qubit in
the |11⟩ term, which becomes |01⟩, while |10⟩ remains the same. The state is now:
1
− √ (|10⟩ + |01⟩).
2
From the analysis above, we observe that for every computational basis input, the output state is a
superposition of all four computational basis states with equal amplitude magnitude (but possibly
differing in sign). As a result, the probability of measuring any of the four basis states is always
1
4 , regardless of the input. The circuit effectively scrambles the input state into a uniformly
distributed output over the computational basis. This illustrates a key feature of quantum
circuits: while the final measurement statistics may be the same, the underlying quantum states
can differ significantly in their internal phase structure.
(b) We are asked to construct a quantum circuit consisting only of single-qubit unitaries and CNOT
gates that implements the inverse U † of the unitary U defined by the following circuit:
Z H
To obtain the inverse of this unitary, we follow a standard procedure in quantum circuit theory:
the inverse of a quantum circuit is obtained by applying the inverses of all individual gates in
reverse order. In this particular case, we benefit from the fact that all gates in the circuit are
self-inverse:
H † = H, Z † = Z, CNOT† = CNOT.
Thus, the inverse circuit U † is constructed by applying the same gates in reverse order, from
right to left.
The original circuit (from left to right) applies the following gates:
6
3. Hadamard H on qubit 1,
4. CNOT with control qubit 1, target qubit 0,
5. Hadamard H on qubit 0.
1. H on qubit 0,
2. CNOT with control qubit 1, target qubit 0,
3. H on qubit 1,
4. Z on qubit 0,
5. CNOT with control qubit 0, target qubit 1.
Therefore, we can represent the final circuit implementing U † in circuit form as:
H Z
This circuit uses only single-qubit unitaries and CNOT gates and implements the inverse of U as
required. Since all operations are unitary and self-inverse, correctness is ensured by construction.
When applied to the output of U , this circuit returns the original input state, verifying that
U † U = I.