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

COMP SCI 4413, 4813, 7413

Introduction to Quantum Computing

Assignment 2

Instructions

。Attempt all sections. If necessary, refer to Rieffel and Polak [RP] for more information. 。The deliverable is a program for Section 1to be submitted via MyUni.

1    Quantum circuit simulator

In Python, implement a simple quantum simulator. Write your program in the file quantum.py. Your program must be able to be compiled and run as follows:

$  python  quantum.py   [circuit]

Make sure that your Python program is compatible with Python v3.6.9.

The input to your program is a text file specified by the path [circuit]. Take note that 。I do not have a Windows machine and it will be difficult for me to locate one; thus

。I will be running your program on a Unix-like environment (e.g., Linux, Mac OS X) and the path [circuit] will follow the Unix convention.

If you do not have a Unix-like machine, consider dual booting your machine with Linux or use a simulation environment such as Cygwinfor Windows.

In this assignment, we will only consider two-qubit systems.  The input text file pointed to

by  [circuit] contains the design of a quantum circuit and desired input quantum states. The specific formatting of the file is as follows:

T  M

L11  L12   ...  L1T

L21  L22   ...  L2T

Q11  Q12  Q13  Q14

Q21  Q22  Q23  Q24

.       .       .       .

.       .       .       .

.       .       .       .

QM1  QM2  QM3  QM4

More details:

。The first line contains the number T of quantum transformations performed by the circuit (T is the number of “columns" or steps in the circuit), and the number M of input quantum states to process.

。The subsequent two lines correspond to the two “wires" in the circuit. Each character Lnt (e.g.,

L25 is the character at the 2nd wire and 5th quantum transformation) can be one of the following symbols:

- Identity (single qubit).

X Not (single qubit).

Z Phase shift (single qubit).

Y Negation and phase shift (single qubit).

H Hadamard (single qubit).

. Control bit.

+ Target bit.

。The subsequent M lines define the input quantum states in linear algebra (vector) form, where

Qm1  Qm2  Qm3  Qm4

are the coefficients of the m-th (1 < m < M) input quantum state

Qm1 I00) + Qm2 I01) + Qm3 I10) + Qm4 I11) .

Example:    For the quantum circuit below,

(1)

X

Z

where we wish to evaluate the following input states,

。  Iv) = I11)

。  Iv) =  (I00) + I10)

  Iv) = 0.7555 I00) + 0.3065 I01) + 0.4257 I10) + 0.3925 I11)

the corresponding input text file contains

6  3

H.X+H.

-+-.YZ

0  0  0  1

0.7071  0  0.7071  0

0.7555  0.3065  0.4257  0.3925 

Given the path  [circuit] to an input text file in the correct format, your program should print to standard output (i.e., the command line) the output quantum states obtained by processing the input states using the given quantum circuit. Specifically, for the input file that contains

T  M

L11  L12   ...  L1T

L21  L22   ...  L2T

Q11  Q12  Q13  Q14

Q21  Q22  Q23  Q24

.       .       .       .

.       .       .       .

.       .       .       .

QM1  QM2  QM3  QM4

your program should print

S11  S12  S13  S14

S21  S22  S23  S24

.       .       .       .

.       .       .       .

.       .       .       .

SM1  SM2  SM3  sM4

to the standard output, where

Sm1  Sm2  Sm3  Sm4

are the coefficients of the output quantum state

Sm1 I00) + Sm2 I01) + Sm3 I10) + Sm4 I11)

corresponding to the m-th input quantum state.

(2)

You are allowed to use standard Python libraries to write your pathfinding program (see https: //docs.python.org/3/library/for the components that make up the Python v3.6.9 stan- dard libraries).  In addition to the standard libraries, you are allowed to use NumPy.  No other external libraries are allowed.

1.2    Submission

Submit your program les in a zip package named assignment2.zip on MyUni.

1.3    Evaluation

I will be testing your program using several quantum circuits to verify its correctness.  If your program gives the correct output to all tests, you will receive all the marks.

2    Self-testing

To help you verify the correctness of your program, answer the following questions. You do not need to submit your answers to the questions.

Question 1 Equivalent gate

What do the following circuits do? Check using your quantum simulator.

 

H

 

H

 



 

 

 

 


Question 2 Inverting control bit

The following circuit applies transformation U on the second qubit if the first qubit is in state 1.

U

Design a circuit that applies transformation U on the second qubit if the first qubit is in state 0. Verify using your quantum simulator.

Question 3 Generating EPR pairs

Define a circuit that can create EPR pairs. This circuit takes as input I00) and produces  (I00) + I11)). Verify the correctness of your circuit using your simulator.

。What happens if the input is not I00)? Is the output state of your circuit still entangled?

Question 4 Dense coding

Using your simulator, implement a circuit to perform dense coding as described in the lectures. The circuit takes I00) as input, creates an entangled pair (Question 1) and then perform encoding. The second part of the circuit decodes the incoming bits to extract two classical bits.

。How critical is the choice of input to this circuit? Does the scheme fail if the input changes to, say, I11)?

4= End of file =÷