<jupyter_start><jupyter_text>Building the CNOT Identity  Quick Exercises 1  1. What would be the resulting state of the control qubit (q0) if the target qubit (q1) was in the state |0⟩? (as shown in the circuit below)? Use Qiskit to check your answer.<jupyter_code>qCirc11 = QuantumCircuit(2, 2)
qCirc11.h(0)
qCirc11.cp(pi/4, 0, 1)
qCirc11.draw("mpl")
from qiskit_textbook.tools import array_to_latex
statevectorSim = Aer.get_backend('statevector_simulator')
job11 = execute(qCirc11, backend = statevectorSim).result()
state11 = job11.get_statevector()
array_to_latex(state11, pretext="\\text{Statevector} = ", precision=1)<jupyter_output><empty_output><jupyter_text>As obvious from the result above, the Control-T gate does not affect the $ |+ \rangle $ state.<jupyter_code>plot_bloch_multivector(state11)
qCirc11.measure([0, 1], [0, 1])
simulator = Aer.get_backend('qasm_simulator')
counts11 = execute(qCirc11, backend = statevectorSim).result().get_counts()
plot_histogram(counts11)<jupyter_output><empty_output><jupyter_text>2. What would happen to the control qubit (q0) if the target qubit (q1) was in the state |1⟩, and the circuit used a controlled-Sdg gate instead of the controlled-T (as shown in the circuit below)?<jupyter_code>qCirc12 = QuantumCircuit(2, 2)
qCirc12.h(0)
qCirc12.x(1)
qCirc12.cp(-pi/2, 0, 1)
qCirc12.draw("mpl")
job12 = execute(qCirc12, backend = statevectorSim).result()
state12 = job12.get_statevector()
array_to_latex(state12, pretext="\\text{Statevector} = ", precision=1)<jupyter_output><empty_output><jupyter_text>From this result, we can see that that the $q_0$ state is rotated by $ -\pi / 2 $ about the Z-axis and now faces the negative-Y axis.<jupyter_code>plot_bloch_multivector(state12)<jupyter_output>C:\Users\lenovo\anaconda3\lib\site-packages\qiskit\visualization\bloch.py:69: MatplotlibDeprecationWarning: 
The M attribute was deprecated in Matplotlib 3.4 and will be removed two minor releases later. Use self.axes.M instead.
  x_s, y_s, _ = proj3d.proj_transform(xs3d, ys3d, zs3d, renderer.M)<jupyter_text>3. What would happen to the control qubit (q0) if it was in the state |1⟩ instead of the state |+⟩ before application of the controlled-T (as shown in the circuit below)?<jupyter_code>qCirc13 = QuantumCircuit(2, 2)
qCirc13.x([0,1])
qCirc13.cp(pi/4, 0, 1)
qCirc13.draw('mpl')
job13 = execute(qCirc13, backend = statevectorSim).result()
state13 = job13.get_statevector()
array_to_latex(state13, pretext="\\text{Statevector} = ", precision=1)
plot_bloch_multivector(state13)<jupyter_output>C:\Users\lenovo\anaconda3\lib\site-packages\qiskit\visualization\bloch.py:69: MatplotlibDeprecationWarning: 
The M attribute was deprecated in Matplotlib 3.4 and will be removed two minor releases later. Use self.axes.M instead.
  x_s, y_s, _ = proj3d.proj_transform(xs3d, ys3d, zs3d, renderer.M)
{'fraction_non_alphanumeric': 0.11636107193229901, 'fraction_numerical': 0.04548660084626234, 'mean_word_length': 6.349740932642487, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '347388', 'license': 'MIT', 'n_tokens_mistral': 1125, 'n_tokens_neox': 1026, 'n_words': 264, 'path': 'Qiskit Textbook Solutions/Chapter 2/2.3 - Phase Kickback.ipynb', 'repo_name': 'kj3moraes/MyQiskitProgramming', 'size': '2836'}