Try Your Hand

Solutions to these exercises are given in Quantum Logic Gates Solutions.

For any code listing in the exercises, assume the following header lines:

 OPENQASM 2.0;
 include ​"qelib1.inc"​;

If you want to run any exercise, you must include them in the code you’d like to execute.

  1. Write the code for the following circuit:

    images/quantum_logic_gates/Measuring_Two_Qubits_on_a_Real_Computer.png
    1. Write the binary states recorded by the Measure gates. Write your answer as a concatenated string of the elements in the classical register.

    2. Run your code on a simulator.

    3. Run your code on a real quantum computer. Did you get the output you expected?

  2. Consider the quantum circuit shown here:

    images/quantum_logic_gates/NOT_NOT_Measure.png
    1. Write a quantum program for this circuit.
    2. Is the state at point A blended?
    3. Write the state at point A.
    4. Can you observe the state at point A?
    5. What is the value recorded by the Measure gate?
    6. Which of the following figures matches the output for the quantum circuit?
      • images/quantum_logic_gates/Output_A.png

        Figure 1. Output A
      • images/quantum_logic_gates/Output_B.png

        Figure 2. Output B
  3. Draw the circuit for the following code:

     qreg q[1];
     creg c[1];
     
     x q[0];
     measure q[0] -> c[0];
     x q[0];
  4. Draw the circuit diagram and write the code for initializing a qubit in the quantum register q[0] to images/_pragprog/svg-18.png.

  5. Write the code for the circuit shown here:

    images/quantum_logic_gates/Upside_Down_Measure.png
  6. In the standard configuration of the CNOT gate, the target qubit’s state is switched only when the control qubit is images/_pragprog/svg-18.png.

    1. Draw a quantum circuit to show how to control the switching of the target qubit’s state when the control qubit is images/_pragprog/svg-17.png. (To test your circuit, set the target qubit to images/_pragprog/svg-18.png and declare Measure gates to record the results.)

    2. Write the quantum program for the circuit you designed.

    3. Write down the values in each of the classical registers when the program terminates.

  7. Consider the following quantum circuit:

    images/quantum_logic_gates/CNOT_Control_on_1.png
    1. Write a quantum program for this circuit.
    2. At termination, what are the values in the classical registers?
  8. The following quantum circuit made up of three CNOT gates is used to SWAP qubits from one quantum register to another:

    images/quantum_logic_gates/SWAP_Gate_Annotated.png
    1. Work out the quantum states images/_pragprog/svg-21.png, images/_pragprog/svg-31.png, images/_pragprog/svg-32.png, images/_pragprog/svg-47.png, images/_pragprog/svg-48.png, and images/_pragprog/svg-49.png for the following values of images/_pragprog/svg-27.png and images/_pragprog/svg-28.png:

      1. images/_pragprog/svg-27.png is images/_pragprog/svg-17.png and images/_pragprog/svg-28.png is images/_pragprog/svg-17.png.
      2. images/_pragprog/svg-27.png is images/_pragprog/svg-17.png and images/_pragprog/svg-28.png is images/_pragprog/svg-18.png.
      3. images/_pragprog/svg-27.png is images/_pragprog/svg-18.png and images/_pragprog/svg-28.png is images/_pragprog/svg-17.png.
      4. images/_pragprog/svg-27.png is images/_pragprog/svg-18.png and images/_pragprog/svg-28.png is images/_pragprog/svg-18.png.
    2. Write a quantum program to implement the SWAP gate when images/_pragprog/svg-27.png is images/_pragprog/svg-18.png and images/_pragprog/svg-28.png is images/_pragprog/svg-17.png. Measure the value of the top qubit in the first cell of the classical register and the bottom qubit in the second cell.

      1. Write the classical register as a concatenated string when the program terminates.

  9. The following circuit represents a FAN-OUT gate that makes a copy of a qubit:

    images/quantum_logic_gates/FAN_OUT_Gate.png
    1. Using this gate, design a quantum circuit that copies a images/_pragprog/svg-18.png qubit, that is, images/_pragprog/svg-50.png. Add Measure gates as appropriate to confirm that the qubit has been copied.

    2. Write a quantum program for your circuit.

  10. You’ll need to become proficient in manipulating Boolean logic expressions if you want to design your own quantum programs. This exercise will give you an opportunity to sharpen your skills.

    In OR Gate, we argued that the CCNOT configuration mimics an OR gate. Using Boolean algebra, explain why this is so. (Refer to Boolean Logic Expressions, to brush up on frequently used expressions.)

  11. In Writing a System of Boolean Logic Expressions, the restrictions on the days each artist can perform at the hotels is listed. In this problem, you’ll work with the following subset of the constraints related to the artists, Kimmel and Maher, performing at the Bellagio:

    • Bellagio on Day 1: images/_pragprog/svg-51.png
    • Bellagio on Day 2: images/_pragprog/svg-52.png

    The qubits images/_pragprog/svg-33.png and images/_pragprog/svg-34.png stand for the artists Kimmel and Maher, respectively.

    1. Draw a quantum circuit for the Bellagio Constraints with the following initial states:

      images/_pragprog/svg-block-029.png
    2. Write a quantum program for the circuit you created.

    3. Execute your program and measure the values of the images/_pragprog/svg-36.png and images/_pragprog/svg-37.png qubits as well as the Bellagio Constraints.

    4. What can you say about this set of initial conditions?

  12. In Writing a System of Boolean Logic Expressions, the restrictions on the days each artist can perform at the hotels is listed. In this problem, you’ll work with the following subset of the constraints related to the artists, Kimmel and Noah, performing at the Aladdin:

    • Aladdin on Day 1: images/_pragprog/svg-53.png

    • Aladdin on Day 2: images/_pragprog/svg-54.png

    The qubits images/_pragprog/svg-33.png and images/_pragprog/svg-55.png stand for the artists Kimmel and Noah, respectively.

    1. Write the logic expression that prevents scheduling conflicts for the artists performing at Aladdin, the Aladdin Constraints.

    2. Draw a quantum circuit for the performance schedule for Jimmy Kimmel and Trevor Noah at Aladdin. The circuit should include the following:

      • Initialize the quantum variables for Kimmel and Noah to images/_pragprog/svg-18.png and images/_pragprog/svg-18.png, respectively.

      • Insert a Measure gate to record the truth value of the constraint that determines whether the schedule is valid.

      • Insert Measure gates to record the states for the variables representing Kimmel and Noah.

    3. Write a quantum program for your circuit.

    4. Does this initial set of quantum variables correspond to a valid schedule? If so, what days do Kimmel and Noah perform at Aladdin.

  13. In Writing a System of Boolean Logic Expressions, the restrictions on the days each artist can perform at the hotels is listed. In this problem, you’ll work with the following subset of the constraints related to the artists Maher and Noah performing at Caesars:

    • Caesars on Day 1: images/_pragprog/svg-56.png

    • Caesars on Day 2: images/_pragprog/svg-57.png

    The qubits images/_pragprog/svg-34.png and images/_pragprog/svg-55.png stand for the artists Maher and Noah, respectively.

    1. Write the logic expression that prevents scheduling conflicts for the artists performing at Caesars, the Caesars Constraints.

    2. Draw a quantum circuit for the performance schedule for Maher and Noah at Caesars. The circuit should include the following:

      • Initialize the quantum variables for Maher and Noah to images/_pragprog/svg-18.png and images/_pragprog/svg-18.png, respectively.

      • Insert a Measure gate to record the truth value of the constraint that determines whether the schedule is valid.

      • Insert Measure gates to record the states for the variables representing Maher and Noah.

    3. Write a quantum program for your circuit.

    4. Does this initial set of quantum variables correspond to a valid schedule?

    5. By experimenting with different quantum states for the variables for Maher and Noah, determine a feasible schedule for them.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.2.184