from qiskit import *

circuito = QuantumCircuit(2,2)
circuito.draw(output =  'mpl')

from qiskit.tools.visualization import plot_bloch_multivector

simulator = Aer.get_backend('statevector_simulator')
result = execute(circuito, backend = simulator).result()

statevector = result.get_statevector()

plot_bloch_multivector(statevector)

# Primeiramente o qiskit inicializa os qubits nos estados 0 e 1

circuito = QuantumCircuit(2,2)
circuito.x(0)
circuito.draw(output =  'mpl')

from qiskit.tools.visualization import plot_bloch_multivector

simulator = Aer.get_backend('statevector_simulator')
result = execute(circuito, backend = simulator).result()

statevector = result.get_statevector()
plot_bloch_multivector(statevector)

circuito.y(0)
circuito.draw(output =  'mpl')

from qiskit.tools.visualization import plot_bloch_multivector

simulator = Aer.get_backend('statevector_simulator')
result = execute(circuito, backend = simulator).result()

statevector = result.get_statevector()
plot_bloch_multivector(statevector)

# No tutorial sobre as portas Rx, Ry e Rz vimos que usando a porta Ry para rotacionar o qubit em pi/2 conseguimos
# o estado |+>
import math

circuito.ry(math.pi/2,1)
circuito.draw(output =  'mpl')

from qiskit.tools.visualization import plot_bloch_multivector

simulator = Aer.get_backend('statevector_simulator')
result = execute(circuito, backend = simulator).result()

statevector = result.get_statevector()
plot_bloch_multivector(statevector)

# Agora aplicando a porta Z

circuito.z(1)
circuito.draw(output =  'mpl')

from qiskit.tools.visualization import plot_bloch_multivector

simulator = Aer.get_backend('statevector_simulator')
result = execute(circuito, backend = simulator).result()

statevector = result.get_statevector()
plot_bloch_multivector(statevector)

circuito.id(1)
circuito.draw(output = 'mpl')

from qiskit.tools.visualization import plot_bloch_multivector

simulator = Aer.get_backend('statevector_simulator')
result = execute(circuito, backend = simulator).result()

statevector = result.get_statevector()
plot_bloch_multivector(statevector)