from qiskit import QuantumCircuit, execute, Aer
from qiskit.visualization import plot_histogram, plot_bloch_vector
from math import sqrt, pi

%config InlineBackend.figure_format = 'svg' # Makes the images look nice


qc = QuantumCircuit(1)

initial_state = [0,1]
qc.initialize(initial_state, 0)
qc.draw()

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

state_vector = result.get_statevector()
print(state_vector)

qc.measure_all()
qc.draw()

result = execute(qc, backend).result()
counts = result.get_counts()
plot_histogram(counts)

initial_state = [1/sqrt(2), complex(0,1/sqrt(2))]
qc  = QuantumCircuit(1)
qc.initialize(initial_state, 0)
qc.draw()

backend = Aer.get_backend('statevector_simulator')
result  = execute(qc, backend).result()
statevector = result.get_statevector()
print(statevector)

counts  =  result.get_counts()
plot_histogram(counts)

initialize_state = [1/sqrt(3), sqrt(2/3)]
qc = QuantumCircuit(1)
qc.initialize(initialize_state, 0)
qc.draw()

result = execute(qc, backend).result()
counts = result.get_counts()
plot_histogram(counts)

