Try Your Hand

Solutions to these exercises are given in Quantum Search 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. As you start designing your own quantum algorithms, you’ll need to figure out what gates to use and where to place them in your circuit. To this end, understanding how gates manipulate quantum states is crucial. To strengthen your intuition when handling quantum gates, fluently rotating the pentagon images/_pragprog/svg-17.png and triangle images/_pragprog/svg-18.png qubelets is helpful. The following exercises relate mega-qubits with rotated qubelets and their corresponding quantum states.

    Write each of the following mega-qubits in terms of the idealized states. In each case, identify the tagged qubelet combination, if any, and its corresponding quantum state:

    1. images/quantum_search/8x3_Mega_Qubit_Tagged.png
    2. images/quantum_search/2x2_Mega_Qubit_Tagged.png
    3. images/quantum_search/2x2_Mega_Qubit_Rotated_Qubelets_None_Tagged.png
    4. images/quantum_search/2x2_Mega_Qubit_Rotated_Qubelets_Tag_00.png
  2. In this problem, you’ll see the perils of rushing to conclusions. Rotating and toggling qubelets do matter. A gate that rotates the triangle images/_pragprog/svg-18.png qubelets by a quarter turn instead of switching it with the other type can affect the behavior of a circuit even if the other gates in the circuit are unchanged.

    To illustrate the importance of carefully working out the precise quantum effects you need to incorporate in your quantum program, you’ll analyze a circuit to identify the missing quantum gate to tag the images/_pragprog/svg-74.png quantum state.

    To this end, look at the following circuit:

    images/quantum_search/Grover_Tagging_0_1_Using_SDag_Gates_Incomplete.png

    The mega-qubit after each qubit is acted on by the H gate is shown in the following figure:

    images/quantum_search/Grover_2_Qubits_All_Combinations_Mega_Qubit.png
    1. What’s the difference between the X, images/_pragprog/svg-438.png, and images/_pragprog/svg-227.png gates?

    2. Draw the mega-qubit after the images/_pragprog/svg-227.png gate acts on the bottom qubit. Write the mega-qubit’s quantum state in terms of the idealized states.

    3. Draw the mega-qubit after the CZ gate acts on the qubits. Write the mega-qubit’s quantum state in terms of the idealized states.

    4. What operations must be applied to the qubelets so that the images/_pragprog/svg-74.png quantum state is tagged?

    5. Using the Canceling Circuit, write a quantum program using your design in the previous part to eliminate the non-tagged quantum states. Examine the output to confirm that your program works correctly.

    6. Alluding back to the introduction to this exercise, what are two morals you can draw?

  3. As you saw in Finding Asymmetry, finding a column in the images/_pragprog/svg-364.png matrix for two stacked gates was crucial to building the Canceling Circuit when working with two qubits. With three qubits and three stacked H gates, as shown in the following circuit, what column in this circuit’s matrix, images/_pragprog/svg-439.png, is symmetric?

    images/quantum_search/Three_Stacked_H_Gates.png
  4. In this exercise, you’ll start with the following Tagging Circuit:

    images/quantum_search/Grover_Tagging_0_1.png
    1. Which quantum state is tagged? Confirm your answer by looking at the Statevector on the IBM Quantum Computer.

    2. Write the tagged state as a vector.

    3. Feed your quantum state obtained in the previous part to the Canceling Circuit. Using its matrix images/_pragprog/svg-413.png, show that the non-tagged states are eliminated. For your reference, images/_pragprog/svg-413.png is:

      images/_pragprog/svg-block-399.png
    4. Append the Canceling Circuit, to this Tagging Circuit and write a program for the whole circuit. Remember to include Measure gates to collapse the qubits and record their states in the classical register.

    5. Run your program and confirm that only the tagged state is recorded in the classical registers.

  5. Explain what’s wrong with each of the following circuit block’s depiction of Grover’s algorithm:

    1. images/quantum_search/Grover_Tagging_Canceling_Canceling_Block_Diagram.png
    2. images/quantum_search/Grover_Tagging_Canceling_Canceling_Tagging_Block_Diagram.png
    3. images/quantum_search/Grover_Multiple_All_Tagging_Canceling_Block_Diagram.png
  6. Following the Fundamental Circuit Pattern for Searching, the circuit shown in the following figure tags two qubits:

    images/quantum_search/Grover_Fundamental_Pattern_for_Search_2_Qubits.png
    1. Identify the All Combinations, Tagging Circuit, and Canceling Circuit sections of the circuit.

    2. Which state is tagged?

    3. Write a program for this circuit.

    4. Run your program and confirm that the state recorded in the final register matches the one you identified as being tagged. (Since this program has several qubits and gates, run your code on a simulator, as you may find that running on today’s real quantum computers leads to incorrect results.)

  7. Consider the following circuit that’s modeled after the Fundamental Circuit Pattern for Searching:

    images/quantum_search/Grover_Fundamental_Pattern_for_Search_4_Qubits_Incomplete.png
    1. Identify where you need to insert X gates so that this circuit tags images/_pragprog/svg-440.png and eliminates the other states.

    2. Write a program for your modified circuit.

    3. Run your program on the IBM Quantum Computer simulator and confirm that only the tagged state images/_pragprog/svg-440.png survives and the others are eliminated.

    4. What can you do to improve the odds of getting the qubits to collapse to the tagged state?

    5. Revise your program accordingly.

    6. Run your revised program on the IBM Quantum Computer simulator and see whether your suggestion does indeed improve the odds of retaining the images/_pragprog/svg-440.png tagged state.

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

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