Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

CS 239 Quantum Programming

Winter 2022

Final Exam

1.  Consider N = 4 and a = 3.  Define ZN   = {0.1.....N − 1}  and define the unitary operation Ma :

Ma |z⟩    =   |az (mod N)⟩

where z ∈ ZN . Show a matrix that represents Ma  and show a quantum circuit that represents Ma .

2. Consider the following formula with two variables z0.z1  and two clauses: (z0 ) ∧ (z1 )

Specifically, the rst clause is  (z0 ) and the second clause is  (z1 ).   Consider the QAOA separator matrix for a reasonable representation of the above formula.  What is the result (written in Dirac notation) of applying this separator matrix to a state that is in a uniform superposition of basis states? Show a circuit that implements this separator matrix with the help of a single additional qubit.

3. The following diagram shows how to implement the bit ip code using parity checks.

The diagram is vague about how to take corrective action after the two measurements in the middle. Show QASM code for the corrective actions.

4. Consider a quantum simulator for programs that operate on 30 qubits. The simulator represents a quantum state as list of weighted basis states, where the weight is the amplitude of the basis state and the basis state is represented as a single integer.  In a programming language of your choice or in readable pseudo-code, sketch how to implement CNOT on this representation of a quantum state.

5.  Suppose we have a source language that supports a controlled s gate that we will write as CS. We define the matrix for CS as follows:

 

CS   =    .(.)   0   0   1   0   .(.)

( 0   0   0   i 

Our target language supports {Rx.Rz.CNOT} . Show a rule that translates CS to pseudo-code in our target language and that is correct up to a global phase.

6. Consider the following circuit with four qubits called A,B,C,D:

Suppose we want to implement the above circuit on a quantum computer with four qubit registers called 0,1,2,3 that are connected as follows:

Give a register allocation for the circuit that minimizes the number of swaps.  State the number of swaps separately and justify why the number of swaps is minimal.

7. Consider the following snippet of QASM code:

h  q[1];  s  q[0];  cx  q[0],q[1];  s  q[0];  cx  q[0],q[1];  z  q[0];  h  q[1]

Use peephole-optimization rules to simplify the code as much as possible.  Show your sim- plification step-by-step and mention briefly which rules you use.

8. Suppose we run Phase Estimation on the Pauli Z gate and |1⟩ . Which output are we hoping for and what is a reasonable lower bound on the probability that we will get it?