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

qc = QuantumCircuit(1)
qc.h(0)
qc.draw(output='mpl')

# Let's see the result
backend = Aer.get_backend('statevector_simulator')
out = execute(qc,backend).result().get_statevector()
print(out)
plot_bloch_multivector(out)

# Run the quantum circuit on a unitary simulator backend
backend = Aer.get_backend('unitary_simulator')
job = execute(qc, backend)
result = job.result()

# Show the results
print(result.get_unitary(qc, decimals=3))

qc = QuantumCircuit(2)
qc.h(0)
qc.x(1)
qc.barrier()
qc.h(1)
qc.draw(output='mpl')

# Let's see the result
backend = Aer.get_backend('statevector_simulator')
out = execute(qc,backend).result().get_statevector()
print(out)
plot_bloch_multivector(out)

# Run the quantum circuit on a unitary simulator backend
backend = Aer.get_backend('unitary_simulator')
job = execute(qc, backend)
result = job.result()

# Show the results
print(result.get_unitary(qc, decimals=3))

qc = QuantumCircuit(3)
qc.h(0)
qc.h(1)
qc.h(2)
qc.barrier()
qc1 = qc.copy()
qc.x(0)
qc.y(1)
qc.z(2)
qc.barrier()
qc2 = qc.copy()
qc.x(0)
qc.y(1)
qc.z(2)
qc.barrier()
qc3 = qc.copy()
qc.h(0)
qc.h(1)
qc.h(2)
qc.draw(output='mpl')

# Let's see the result
backend = Aer.get_backend('statevector_simulator')
out = execute(qc,backend).result().get_statevector()
print(out)
plot_bloch_multivector(out)

# Run the quantum circuit on a unitary simulator backend
backend = Aer.get_backend('unitary_simulator')
job = execute(qc, backend)
result = job.result()

# Show the results
print(result.get_unitary(qc, decimals=3))

# Let's see the result
backend = Aer.get_backend('statevector_simulator')
out = execute(qc1,backend).result().get_statevector()
print(out)
plot_bloch_multivector(out)

# Let's see the result
backend = Aer.get_backend('statevector_simulator')
out = execute(qc2,backend).result().get_statevector()
print(out)
plot_bloch_multivector(out)

# Let's see the result
backend = Aer.get_backend('statevector_simulator')
out = execute(qc3,backend).result().get_statevector()
print(out)
plot_bloch_multivector(out)

qc = QuantumCircuit(1)
qc.s(0)
qc.draw(output='mpl')

qc = QuantumCircuit(1)
qc.sdg(0)
qc.draw(output='mpl')

qc = QuantumCircuit(1)
qc.t(0)
qc.draw(output='mpl')

qc = QuantumCircuit(1)
qc.tdg(0)
qc.draw(output='mpl')

qc = QuantumCircuit(1)
qc.x(0)
qc.barrier()
qc1 = qc.copy()
qc.h(0)
qc.barrier()
qc2 = qc.copy()
qc.s(0)
qc.barrier()
qc3 = qc.copy()
qc.s(0)
qc.barrier()
qc4 = qc.copy()
qc.s(0)
qc.barrier()
qc5 = qc.copy()
qc.sdg(0)
qc.h(0)
qc.barrier()
qc6 = qc.copy()
qc.draw(output='mpl')

# Let's see the result
backend = Aer.get_backend('statevector_simulator')
out = execute(qc,backend).result().get_statevector()
print(out)
plot_bloch_multivector(out)

# Let's see the result
backend = Aer.get_backend('statevector_simulator')
for qc in [qc1,qc2,qc3,qc4,qc5,qc6]:
    out = execute(qc,backend).result().get_statevector()
    print(out)

