pythonquantum-computingqiskit

ket.draw() not showing |00> : Qiskit


ket.draw() must give |00> as result but I get:

Statevector([1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j],
               dims=(2, 2))

what can I change to get the desired result?

This is my code:

from qiskit import QuantumCircuit
from qiskit.quantum_info import Statevector

qc = QuantumCircuit(2)

# This calculates what the state vector of our qubits would be
# after passing through the circuit 'qc'
ket = Statevector(qc)

# The code below writes down the state vector.
# Since it's the last line in the cell, the cell will display it as output
ket.draw()

Solution

  • You can pass the keyword argument output='latex' to the .draw method.

    from qiskit import QuantumCircuit
    from qiskit.quantum_info import Statevector
    
    qc = QuantumCircuit(2)
    
    # This calculates what the state vector of our qubits would be
    # after passing through the circuit 'qc'
    ket = Statevector(qc)
    
    # The code below writes down the state vector.
    # Since it's the last line in the cell, the cell will display it as output
    ket.draw(output='latex')