Here is my basic code

from qiskit import QuantumCircuit, execute, Aer, transpile, assemble
from qiskit.visualization import plot_histogram, plot_bloch_multivector, array_to_latex
from numpy.random import randint
import numpy as np
print("Imports Successful")

def create_Entangled(qc):
    qc.h(0) #H-gate to the first
    qc.cx(0,1) #CNOT to the second
    #Doublecheck that the bits are entangled through statevector
    backend = Aer.get_backend('statevector_simulator')
    job = execute(qc, backend=backend, shots=1, memory=True)
    job_result = job.result()
    final_state = job_result.get_statevector()
    array_to_latex(final_state, prefix="\\text{Statevector = }")
qc = QuantumCircuit(2)

I get the circuit drawn and I can see the "print" of the Statevector, but array_to_latex does not seem to produce anything!


1 Answer 1



from IPython.display import display


array_to_latex doesn't print anything. It creates a data structure, which, if displayed, gives you nice output. By default, Jupyter only shows you the last output. If you want to see other outputs, you need to print (for normal Python stuff) or display them.

  • $\begingroup$ You actually don't need to import display in a Jupyter notebook, should be available immediately. $\endgroup$
    – Frank
    Nov 21, 2022 at 10:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.