Try Your Hand

Solutions to these exercises are given in Where to Go from Here Solutions.

  1. Consider the images/_pragprog/svg-451.png block used in Deutsch’s circuit shown in the following circuit:

    images/summary/Deutsch_Function_F.png

    Suppose the function images/_pragprog/svg-475.png is constant that always returns a images/_pragprog/svg-18.png.

    1. Write the truth table for images/_pragprog/svg-451.png.

    2. Draw Deutsch’s circuit with gates that represent images/_pragprog/svg-451.png.

    3. Write a Qiskit program to simulate this circuit using a single shot. What state is recorded by the Measure gate that collapses the images/_pragprog/svg-27.png qubit?

    4. Write a Cirq program to simulate this circuit using a single shot. Place the qubits diagonally across.

    5. Does the quantum circuit simulated on IBM’s Quantum Computer behave as the one simulated on Google’s Quantum Computer?

  2. This exercise is similar to the previous one but uses a balanced function, images/_pragprog/svg-475.png, defined as follows:

    images/_pragprog/svg-block-430.png
    1. Write the truth table for images/_pragprog/svg-451.png.

    2. Draw Deutsch’s circuit with gates that represent images/_pragprog/svg-451.png. (Hint: use a combination of CNOT and X gates.)

    3. Write a Qiskit program to simulate this circuit using a single shot. What state is recorded by the Measure gate that collapses the images/_pragprog/svg-27.png qubit?

    4. Write a Cirq program to simulate this circuit using a single shot. Place the qubits 2 units apart one below the other.

    5. Does the quantum circuit simulated on IBM’s Quantum Computer behave as the one simulated on Google’s Quantum Computer?

  3. In this exercise you’ll write a Qiskit program to implement Deutsch-Jozsa’s algorithm for a two-qubit function, images/_pragprog/svg-476.png, defined as follows:

    images/_pragprog/svg-419.png

    images/_pragprog/svg-420.png

    images/_pragprog/svg-476.png

    images/_pragprog/svg-17.png

    images/_pragprog/svg-17.png

    images/_pragprog/svg-17.png

    images/_pragprog/svg-17.png

    images/_pragprog/svg-18.png

    images/_pragprog/svg-17.png

    images/_pragprog/svg-18.png

    images/_pragprog/svg-17.png

    images/_pragprog/svg-18.png

    images/_pragprog/svg-18.png

    images/_pragprog/svg-18.png

    images/_pragprog/svg-18.png

    1. Function images/_pragprog/svg-441.png is what type: constant or balanced? Using a classical algorithm, how many samples of images/_pragprog/svg-441.png do you need to classify its type?

    2. Draw the images/_pragprog/svg-451.png block that is embedded in the Deutsch-Jozsa algorithm.

    3. Write the truth table for images/_pragprog/svg-451.png.

    4. Draw the quantum circuit for the Deutsch-Jozsa algorithm, embedding the images/_pragprog/svg-451.png block from the previous part.

    5. Calculate the matrix images/_pragprog/svg-462.png for the images/_pragprog/svg-451.png block, corresponding to the truth table you computed in the previous part. Use the IBM convention to write the matrix.

    6. Write a quantum program for this circuit using Qiskit. Use the Operator method to specify the matrix for the images/_pragprog/svg-451.png block. Set the program to run just one shot. Report the result as an array.

    7. Does the output match the type of the function you deduced in the first part?

  4. In each of the cases below, identify the correct Qiskit statements to set up the respective gates:

    1. images/summary/Multi_H_Gates_Using_Slash.png
      1.  circuit = QuantumCircuit(3,3)
         circuit.h(range(3))
      2.  circuit = QuantumCircuit(3,3)
         circuit.h(3)
      3.  circuit = QuantumCircuit(3,3)
         circuit.h(0,1,2)
      4.  circuit = QuantumCircuit(3,3)
         circuit.h(range(2))
    2. images/summary/2_H_2_Measure_Gates.png
      1.  circuit = QuantumCircuit(2,2)
         circuit.h(range(2))
         circuit.measure(range(2),range(2))
      2.  circuit = QuantumCircuit(2,2)
         circuit.h(2)
         circuit.measure(2,2)
      3.  circuit = QuantumCircuit(2,2)
         circuit.h(range(2))
         circuit.measure(1,0)
      4.  circuit = QuantumCircuit(2,2)
         circuit.h(range(2))
         circuit.measure(range(2),[1,0])
  5. Consider a quantum gate images/_pragprog/svg-221.png that acts on the images/_pragprog/svg-17.png and images/_pragprog/svg-18.png qubits as follows:

    images/_pragprog/svg-block-431.png
    1. Which description best fits this gate?

      1. Splitter.

      2. Rotates pentagon images/_pragprog/svg-17.png qubelets.

      3. Rotates triangle images/_pragprog/svg-18.png qubelets.

      4. Toggles qubelets. That is, a pentagon images/_pragprog/svg-17.png qubelet is switched to a triangle images/_pragprog/svg-18.png qubelet, and vice versa.

      5. Only splits a qubit when it acts on the images/_pragprog/svg-18.png state.

      6. Splitter and rotates triangle images/_pragprog/svg-18.png qubelets.

    2. When this gate acts on a images/_pragprog/svg-17.png qubit, are the triangle images/_pragprog/svg-18.png qubelets rotated? If so, by how much? What’s the probability that the images/_pragprog/svg-18.png qubit collapses to images/_pragprog/svg-18.png?

    3. When this gate acts on a images/_pragprog/svg-18.png qubit, are the triangle images/_pragprog/svg-18.png qubelets rotated? If so, by how much? What’s the probability that the images/_pragprog/svg-18.png qubit collapses to images/_pragprog/svg-18.png?

    4. Write a matrix images/_pragprog/svg-207.png that describes the behavior of this gate.

    5. Is this matrix unitary? Use Qiskit’s Operator class’s is_unitary to check.

      Use Qiskit’s Operator class to convert this matrix into a gate you can use in a circuit.

    6. Write a Qiskit program to insert this gate in the following circuit:

      images/summary/Qiskit_Custom_Gate_Entanglement.png
    7. Run this circuit on the simulator and write the output states as an array.

    8. Other than using Qiskit’s Operator class to define this gate, is there any other way you could have defined this gate?

  6. Consider the following circuit in which the first two qubits are initialized to the quantum state images/_pragprog/svg-470.png:

    images/summary/Qiskit_Arbitrary_Initial_State_Circuit.png

    The quantum state images/_pragprog/svg-470.png is:

    images/_pragprog/svg-block-432.png
    1. Is images/_pragprog/svg-470.png a valid quantum state? If not, how can you make it valid?

    2. Write a Qiskit program that initializes the circuit with the quantum state you determined in the previous part.

    3. How many independent sets of qubits does this circuit have?

    4. Run this quantum circuit on the simulator. Write the output as an array.

  7. List the quantum effects you’ve learned in this book.

Footnotes

[68]

https://www.jstor.org/stable/52182?seq=1

[69]

https://en.wikipedia.org/wiki/Deutsch%E2%80%93Jozsa_algorithm

[70]

https://arxiv.org/abs/quant-ph/9708016

[71]

https://ai.googleblog.com/2019/10/quantum-supremacy-using-programmable.html

[72]

https://www.nature.com/articles/s41586-019-1666-5

[73]

https://en.wikipedia.org/wiki/IEEE_754

[74]

https://www.olcf.ornl.gov/summit/

[75]

https://www.nytimes.com/2019/10/30/opinion/google-quantum-computer-sycamore.html

[76]

https://qiskit.org/

[77]

https://pragprog.com/book/gwpy3/practical-programming-third-edition

[78]

https://pragprog.com/book/dzpyds/data-science-essentials-in-python

[79]

https://jupyter.org/try

[80]

https://developer.ibm.com/technologies/quantum-computing/videos/programming-on-quantum-computers-pt-2/

[81]

https://qiskit.org/documentation/install.html

[82]

https://qiskit.org/aer/

[83]

https://qiskit.org/documentation/install.html#access-ibm-quantum-systems

[84]

https://quantum-computing.ibm.com/jupyter/tutorial/fundamentals/3_the_ibmq_account.ipynb (You’ll need to log in to the IBM Quantum Experience.)

[85]

https://qiskit.org/documentation/tutorials/circuits_advanced/1_advanced_circuits.html#Composite-Gates

[86]

https://qiskit.org/documentation/tutorials/circuits/3_summary_of_quantum_operations.html#Arbitrary-initialization

[87]

https://qiskit.org/documentation/tutorials/circuits_advanced/2_operators_overview.html#Combining-Operators

[88]

https://qiskit.org/documentation/apidoc/circuit.html?highlight=quantum%20circuit%20depth#supplementary-information

[89]

https://qiskit.org/documentation/tutorials/circuits/2_plotting_data_in_qiskit.html#Options-when-plotting-a-histogram

[90]

https://qiskit.org/documentation/tutorials/circuits/2_plotting_data_in_qiskit.html#Plot-Bloch-Vector

[91]

https://qiskit.org/documentation/tutorials/circuits/2_plotting_data_in_qiskit.html#Plot-State

[92]

https://qiskit.org/documentation/tutorials/simulators/3_building_noise_models.html

[93]

https://aws.amazon.com/braket/

[94]

https://aws.amazon.com/blogs/aws/amazon-braket-get-started-with-quantum-computing/

[95]

https://aws.amazon.com/braket/hardware-providers/

[96]

https://cirq.readthedocs.io/

[97]

https://cirq.readthedocs.io/en/latest/circuits.html

[98]

https://cirq.readthedocs.io/en/latest/install.html

[99]

https://cirq.readthedocs.io/en/stable/circuits.html#insertstrategies

[100]

https://cirq.readthedocs.io/en/stable/circuits.html#importing-cirq-circuit-from-qasm-format

[101]

https://www.dabeaz.com/ply/

[102]

https://www.microsoft.com/en-us/quantum/

[103]

https://azure.microsoft.com/en-us/services/quantum/

[104]

https://www.microsoft.com/en-us/quantum/development-kit

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

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