In [1]:
from IPython.display import Image
Image("images/F2.png",width=300)
Out[1]:
In [2]:
Image("images/dieti.png",width=200)
Out[2]:

Department of Electrical Engineering and Information Technology, Via Claudio 21, Naples, Italy

Introduction to Quantum Circuits

Bell state generation

In [1]:
from qiskit import *
from qiskit.visualization import plot_histogram, plot_bloch_vector, plot_bloch_multivector, circuit_drawer
from qiskit_textbook.widgets import plot_bloch_vector_spherical
from math import sqrt, pi
from IPython.display import display, Math, Latex
In [2]:
# Use Aer's qasm_simulator
#simulator = Aer.get_backend('qasm_simulator')
backend = Aer.get_backend('statevector_simulator') # Tell Qiskit how to simulate our circuit

# Create a Quantum Circuit acting on the q register
qc = QuantumCircuit(2, 2)

# Add a H gate on qubit 0
qc.h(0)

# Add a CX (CNOT) gate on control qubit 0 and target qubit 1
qc.cx(0, 1)

# Draw the circuit
qc.draw(output='mpl') # Draw the corresponding circuit
Out[2]:
In [5]:
result = execute(qc,backend).result() # Do the simulation, returning the result
out_state = result.get_statevector() # Get the final statevector of an experiment.
In [4]:
print(out_state)
[0.70710678+0.j 0.        +0.j 0.        +0.j 0.70710678+0.j]