from qiskit import *
from math import pi
import numpy as np
from qiskit.visualization import plot_bloch_multivector,plot_state_qsphere
import matplotlib.pyplot as plt

q = np.array([1.+0.j, 0.+0.j])
plot_bloch_multivector(q)

plot_state_qsphere(q)

q = np.array([0.+0.j, 1.+0.j])
plot_bloch_multivector(q)

plot_state_qsphere(q)

qc = QuantumCircuit(1)
qc.barrier()
qc1 = qc.copy()
qc.x(0)
qc.barrier()
qc2 =qc.copy()
qc.draw('mpl')

backend = Aer.get_backend('statevector_simulator')
q1 = execute(qc1,backend).result().get_statevector()
q2 = execute(qc2,backend).result().get_statevector()
print(q1,q2)

q = np.array([1/np.sqrt(2)+0.j, 1/np.sqrt(2)+0.j])
plot_bloch_multivector(q)

plot_state_qsphere(q)

q = np.array([1/np.sqrt(2)+0.j, -(1/np.sqrt(2))+0.j])
plot_bloch_multivector(q)

plot_state_qsphere(q)

qc = QuantumCircuit(1)
qc.barrier()
qc1 = qc.copy()
qc.h(0)
qc.barrier()
qc2 =qc.copy()
qc.draw('mpl')

backend = Aer.get_backend('statevector_simulator')
q1 = execute(qc1,backend).result().get_statevector()
q2 = execute(qc2,backend).result().get_statevector()
print(q1,q2)

qc = QuantumCircuit(1)
qc.barrier()
qc1 = qc.copy()
qc.x(0)
qc.h(0)
qc.barrier()
qc2 =qc.copy()
qc.draw('mpl')

backend = Aer.get_backend('statevector_simulator')
q1 = execute(qc1,backend).result().get_statevector()
q2 = execute(qc2,backend).result().get_statevector()
print(q1,q2)









