from qiskit import QuantumCircuit,Aer,transpile,execute
from qiskit.quantum_info import *
from qiskit.visualization import *

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

backend=Aer.get_backend('statevector_simulator')

job=execute(qc,backend)

result=job.result()
sv=result.get_statevector()

sv

sv.data

array_to_latex(sv.data)

sv.draw("latex")

sv.draw("qsphere")


qc_transpile=transpile(qc,backend)

job=backend.run(qc_transpile)
result=job.result()

sv=result.get_statevector()

sv

sv.data

array_to_latex(sv.data)

sv.draw("latex")

sv_label=Statevector.from_label('++')

sv_label.data

qc=QuantumCircuit(2)
sv=Statevector.from_label('++')
sv_evolve=sv.evolve(qc)
sv_evolve

sv_evolve.data

sv

sv_evolve.draw(output="latex")

qc.draw(output="mpl")

qc.initialize(sv_evolve)

qc.draw(output="mpl")

qc=QuantumCircuit(2)
qc.initialize([0.5,0.5,0.5,0.5],[0,1])
sv_evolve=sv.evolve(qc)
sv_evolve

sv_evolve.draw("latex")

array_to_latex(sv_evolve.data)

qc.draw(output="mpl")

from qiskit import BasicAer

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

backend=BasicAer.get_backend('statevector_simulator')

qc_transpile=transpile(qc,backend)

job=backend.run(qc_transpile)
result=job.result()

sv=result.get_statevector()

sv

array_to_latex(sv.data)

# basis |0> and dim= 2^1=2
sv_label_0=Statevector.from_int(0,2**1)
sv_label_0.data

sv_label_0.draw("latex")

# basis 1(|01>) and dim= 2^2=4
sv_label=Statevector.from_int(1,2**2)
sv_label.data

sv_label.draw("latex")

# basis |0> and dim= 2^2=4
sv_label=Statevector.from_int(0,2**2)
sv_label.data

sv_label.draw("latex")

qc=QuantumCircuit(2)
qc.h(0)
qc.h(1)
sv_evolve=sv_label.evolve(qc)
sv_evolve

sv_evolve.draw("latex")

array_to_latex(sv_evolve.data)

