from qiskit import *
from math import pi

import numpy as np
from qiskit.visualization import plot_bloch_multivector,plot_histogram
from qiskit_textbook.tools import array_to_latex

backend_s = Aer.get_backend('statevector_simulator')
backend_u = Aer.get_backend('unitary_simulator')

qc = QuantumCircuit(2)
qc.h(0)
qc.x(1)
# Add Controlled-T
qc.cp(pi/4, 0, 1) # alternatively: qc.cu1(pi/4,0,1)
display(qc.draw('mpl'))
# See Results:
final_state = execute(qc,backend_s).result().get_statevector()
plot_bloch_multivector(final_state)

qc = QuantumCircuit(2)
qc.h(0)
# Add Controlled-T
qc.cp(pi/4, 0, 1) # Alternatively qc.cu1(pi/4,0,1)
display(qc.draw('mpl'))
# See Results:
final_state = execute(qc,backend_s).result().get_statevector()
plot_bloch_multivector(final_state)

qc = QuantumCircuit(2)
qc.h(0)
qc.x(1)
# Add Controlled-T
qc.cp(-pi/2, 0, 1)  #Alternatively qc.cu1(-pi/2,0,1)
display(qc.draw('mpl'))
# See Results:
final_state = execute(qc,backend_s).result().get_statevector()
plot_bloch_multivector(final_state)

qc = QuantumCircuit(2)
qc.x(0)
qc.x(1)
# Add Controlled-T
qc.cp(pi/4, 0, 1) # Alternatively, qc.cu1(pi/4,0,1)
display(qc.draw('mpl'))
# See Results:
final_state = execute(qc,backend_s).result().get_statevector()
plot_bloch_multivector(final_state)

import qiskit
qiskit.__qiskit_version__

