为什么状态向量有差异,但可视化没有差异?
是否有任何其他可视化来显示差异?
qiskit:0.23.3
蟒蛇:3.8
circuit-1 + statevector:
q_0:
[1.+0.j 0.+0.j] ==> +1
circuit-2 + statevector
┌───┐┌───┐┌───┐┌───┐┌───┐
q_0: ┤ X ├┤ H ├┤ X ├┤ H ├┤ X ├
└───┘└───┘└───┘└───┘└───┘
[-1.+0.j -0.-0.j] ==> -1
代码示例
import numpy as np
from qiskit import *
import qiskit.tools.visualization as vis
import matplotlib. pyplot as plt
from qiskit import Aer
circ = QuantumCircuit(1)
circ.x(0)
circ.h(0)
circ.x(0)
circ.h(0)
circ.x(0)
backend = Aer.get_backend('statevector_simulator')
result = execute(circ, backend).result()
statevector = result.get_statevector()
vis.plot_bloch_multivector(statevector)
vis.plot_state_city(statevector)
vis.plot_state_qsphere(statevector)
vis.plot_state_paulivec(statevector)
circ.draw(output='mpl')
print(np.around(statevector,5))
plt.show()