from qiskit import *
from qiskit.visualization import plot_bloch_multivector, visualize_transition, plot_histogram
from math import sqrt

# Create a quantum circuit with a single qubit
# The default initial state of qubit will be |0> or [1,0]
qc = QuantumCircuit(1)

# declare the intial sate as [0,1] or |1>
initial_state = [1/sqrt(2),1j/sqrt(2)]
qc.initialize(initial_state,0)

qc.x(0)

qc.measure_all()

#Draw the circuit
# qc.draw()
qc.draw('mpl')

backend = Aer.get_backend('statevector_simulator')

out = execute(qc,backend).result().get_statevector()

print(out)

plot_bloch_multivector(out)

# visualize the output as an animation
# visualize_transition(qc)

#execute the circuit and get the plain result
out = execute(qc,backend).result()
counts = out.get_counts()
plot_histogram(counts)

