from qiskit import *
from math import pi
from qiskit.visualization import plot_bloch_multivector

# Let's do an X-gate on a |0> qubit
qc = QuantumCircuit(1)
qc.x(0)
qc.draw('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 do an X-gate on a |0> qubit
qc = QuantumCircuit(1)
qc.y(0)
qc.draw('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)
print(out)
result = job.result()

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

qc = QuantumCircuit(1)
qc.z(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)
print(out)
result = job.result()

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

# Let's do an X-gate on a |0> qubit
qc = QuantumCircuit(1)
qc.x(0)
qc.x(0)
qc.y(0)
qc.y(0)
qc.z(0)
qc.z(0)
qc.draw('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 do an X-gate on a |0> qubit
qc = QuantumCircuit(2)
qc.x(0)
qc.y(1)
qc.draw('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 do an X-gate on a |0> qubit
qc = QuantumCircuit(2)
qc.x(0)
qc.y(1)
qc.z(0)
qc.x(1)
qc.draw('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 do an X-gate on a |0> qubit
qc = QuantumCircuit(3)
qc.x(0)
qc.y(1)
qc.z(2)
qc.draw('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))

