0

为什么状态向量有差异,但可视化没有差异?
是否有任何其他可视化来显示差异?

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()

两个状态向量的可视化是相等的!! 示例 1 示例 2

4

1 回答 1

0

对我来说这似乎是一个错误(我在这里报告过)

无论如何,我建议您使用万花筒来可视化状态。它有交互式图表。这是您的示例(为简短而重构):

from qiskit import QuantumCircuit
from qiskit.quantum_info import Statevector
from kaleidoscope import qsphere

circ = QuantumCircuit(1)

circ.x(0)
circ.h(0)
circ.x(0)
circ.h(0)
circ.x(0)

state = Statevector.from_instruction(circ)
qsphere(state)

在此处输入图像描述

将颜色与另一个示例进行比较:

circ = QuantumCircuit(1)

state = Statevector.from_instruction(circ)
qsphere(state)

在此处输入图像描述

颜色的不同是相位。在第一种情况下是 π。

于 2021-02-14T08:40:17.430 回答