The 2nd lecture of the mini course. The quantum primitives Swap Test and Hadamard Test are covered in this lecture.
Corresponding HW Assignment
Code the algorithm of the Hadamard test that we covered in class using the Python SDK (Attached is a print screen of the Qmod for your convenience). Execute it from the SDK using 1,000 , 2,000 , 4,000 , 8,000 and 16,000 shots, and for each job calculate the (real part of the) expectation value using the formula Re{0|UQFT|0} = 2P0-1. Plot a graph of the expectation value as a function of the number of shots. Add to the graph the theoretical value. Explain the results.
Deliverable: The Jupyter notebook used for the assignment, including the required graph and explanations of it.
Recommended Exercises
1. Use the pre-built example of the SWAP Test from the IDE, and adapt the two states to be 2-qubit states with 0 overlap (i.e. orthogonal states). You can use the prepare_state function for this (use a standard error bound of 0.01). Synthesize and execute the algorithm using Classiq’s simulator. What was the probability of measuring 0 in the test qubit? Is it as you expected?
2. Repeat exercise 1 but now adapt the two states to be 2-qubit states with perfect overlap (i.e. to be identical states).
3. Repeat exercise 1 but now adapt the two states to be 2-qubit states with 0.5 fidelity overlap
4. Follow the implementation in class and code in the IDE the Hadamard test for calculating the (real part of the) expectation value of the QFT unitary at the state |0} with 4 qubits. Execute the algorithm from the IDE with 1,000 shots, and calculate the (real part of the) expectation value using the formula Re{0|UQFT|0} = 2P0-1. Is it what you expected it to be?
5. Repeat exercise 4 but now execute the algorithm with 2,000 shots. Is the result better? I.e. closer to the theoretical value..
6. Repeat exercise 4 but now execute the algorithm with 5,000 shots. Is the result better? I.e. closer to the theoretical value..