### Homework 2

Important: Write Name and Unity ID on every submission file. Name the submission file correctly as asked for.

1. (20 points) Let's create a multiple gate circuit using D-Wave Ocean. We will use NOR gates for this. In this case, we want the output of one of the NOR gates to be one of the inputs for the next NOR gate, whose output will be an input for the next NOR gate, and so on.
• First form the QUBO for the NOR gate.
• Obtain the weights and strengths of all qubits and their connections for two NOR gates using the 5/6 qubit Quantum Apprentice spreadsheet (5 qubit tab).
• Create a function to edit the QUBO by adding a NOR gate.
• Let the default embedding provide an implicit mapping onto the D-Wave architecture in a first attempt. Report QUBO for n = 4 as a comment.
• Then create a version with explicit embedding onto the bi-partite graph coded up and include the QUBO for n=4 as a comment.
• Example QUBO (from a 2 bit adder): {('x0', 'x0'): 1, ('y0', 'y0'): 1, ('s0', 's0'): 1, ('c0', 'c0'): 6, ('x0', 'y0'): 2, ('x0', 's0'): -2, ('x0', 'c0'): -4, ('y0', 's0'): -2, ('y0', 'c0'): -4, ('s0', 'c0'): 4, ('x1', 'x1'): 1, ('y1', 'y1'): 1, ('s1', 's1'): 1, ('s2', 's2'): 6, ('cc0', 'cc0'): 3, ('x1', 'y1'): 2, ('x1', 's1'): -2, ('x1', 's2'): -4, ('y1', 's1'): -2, ('y1', 's2'): -4, ('s1', 's2'): 4, ('x1', 'cc0'): 2, ('y1', 'cc0'): 2, ('cc0', 's1'): -2, ('cc0', 's2'): -4, ('c0', 'cc0'): -4}
• Yours will have different weights and variable names.

Turn in files doubleor.xlsm, doubleor-impl.py, doubleor-expl.py

2. (40 points) Create a chain of 5 NOR gates - creating an XOR gate as shown in This Wikipedia page. You'll need to connect the output of one NOR gate with the input of another.
• Consider your circuit from the previous homework.
• Combine it with itself by creating chains to connect corresponding qubits. Try it out for a 2-circuit chain.
• Re-factor your code to make it an XOR by repeatedly chaining circuits to each other. See the factoring circuit as an example for how this is done in python. But remember, you need to do this with your own circuits.
• Try out the XOR; include results as comments.

Turn in file xor.py

3. (15 points, 3 points each) There are several types of products used in quantum computing math. Show the result of each product below. The answer will either be a scalar, a vector, or a matrix. Do not use bra-ket notation in your answers.
• $$|1><1|$$
• $$<1|0>$$
• $$|0> \otimes \ \ |1>$$
• $$<0|H|1>$$
• $$X \otimes H$$

Submit your answers as $$\textbf{hw2math.pdf}$$.

Note: If you are a LaTeX/Overleaf user, the $$\textbf{braket}$$ package defines $$\verb#\bra{}#, \verb#\ket{}#$$, and $$\verb#\braket{}#$$ macros. You should also check out the $$\textbf{qcircuit}$$ package for drawing quantum circuits.

4. (10 points) Create the NOR gate in Quirk with inputs a and b and output c.
Hints:
• Watch the tutorial.
• Create the circuit by just dropping down X gates (marked as "cross", right below the Y gate) and adding one or two control probes (solid dot) for C-Not and Toffoli gates, respectively.
• Put a Sample box on the inputs (left).
• Test your circuit by verifying that inputs/outputs are correct. You can change inputs by putting one or more X gates on Qubit input lines (very left, left of the sample box), and then watch the output.
• Label inputs and outputs. You can do this by creating a labeled gate for each symbol, i.e., click: make gate, from matrix "{{1,0},{0,1}}" circuit symbol "a", create. Place it on the a input line, etc. for a/b/c.
• Export your solution as a URL (copy clipboard) in the file nor.txt.

Turn in file nor.txt.

5. (15 points) Combine five of those NORs to create an XOR in Quirk, similar to question 2, with inputs a and b, output c, and several ancilla bits. Make sure to label inputs/outputs.

Turn in file xor.txt.