Sympy.physics.quantum.gate中的Z-GATE如何激发工作?
如果我运行以下python脚本:
from sympy.physics.quantum import qapply
from sympy.physics.quantum.qubit import Qubit
from sympy.physics.quantum.gate import X, Z, ZGate
print("1a) Z(0)*Qubit('0')={0}".format(qapply(Z(0)*Qubit('0'))))
print("1b) Z(0)*Qubit('1')={0}\n".format(qapply(Z(0)*Qubit('1'))))
print("2a) Z(0)*Qubit('00')={0}".format(qapply(Z(0)*Qubit('00'))))
print("2b) Z(0)*Qubit('01')={0}".format(qapply(Z(0)*Qubit('01'))))
print("2c) Z(0)*Qubit('10')={0}".format(qapply(Z(0)*Qubit('10'))))
print("2d) Z(0)*Qubit('11')={0}".format(qapply(Z(0)*Qubit('11'))))
print("2e) Z(1)*Qubit('00')={0}".format(qapply(Z(1)*Qubit('00'))))
print("2f) Z(1)*Qubit('01')={0}".format(qapply(Z(1)*Qubit('01'))))
print("2g) Z(1)*Qubit('10')={0}".format(qapply(Z(1)*Qubit('10'))))
print("2h) Z(1)*Qubit('11')={0}".format(qapply(Z(1)*Qubit('11'))))
我会收到以下输出:
1a) Z(0)*Qubit('0')=|0>
1b) Z(0)*Qubit('1')=-|1>
2a) Z(0)*Qubit('00')=|00>
2b) Z(0)*Qubit('01')=-|01>
2c) Z(0)*Qubit('10')=|10>
2d) Z(0)*Qubit('11')=-|11>
2e) Z(1)*Qubit('00')=|00>
2f) Z(1)*Qubit('01')=|01>
2g) Z(1)*Qubit('10')=-|10>
2h) Z(1)*Qubit('11')=-|11>
第1A行中的ouput和1b)是正确的,因为我的意见很关注,但是第2b行),2c),2f),2f),2F)是错误的。 问题在哪里?
欢迎任何帮助。
善良的态度是
克劳斯
If I run the following Python script:
from sympy.physics.quantum import qapply
from sympy.physics.quantum.qubit import Qubit
from sympy.physics.quantum.gate import X, Z, ZGate
print("1a) Z(0)*Qubit('0')={0}".format(qapply(Z(0)*Qubit('0'))))
print("1b) Z(0)*Qubit('1')={0}\n".format(qapply(Z(0)*Qubit('1'))))
print("2a) Z(0)*Qubit('00')={0}".format(qapply(Z(0)*Qubit('00'))))
print("2b) Z(0)*Qubit('01')={0}".format(qapply(Z(0)*Qubit('01'))))
print("2c) Z(0)*Qubit('10')={0}".format(qapply(Z(0)*Qubit('10'))))
print("2d) Z(0)*Qubit('11')={0}".format(qapply(Z(0)*Qubit('11'))))
print("2e) Z(1)*Qubit('00')={0}".format(qapply(Z(1)*Qubit('00'))))
print("2f) Z(1)*Qubit('01')={0}".format(qapply(Z(1)*Qubit('01'))))
print("2g) Z(1)*Qubit('10')={0}".format(qapply(Z(1)*Qubit('10'))))
print("2h) Z(1)*Qubit('11')={0}".format(qapply(Z(1)*Qubit('11'))))
I get the following output:
1a) Z(0)*Qubit('0')=|0>
1b) Z(0)*Qubit('1')=-|1>
2a) Z(0)*Qubit('00')=|00>
2b) Z(0)*Qubit('01')=-|01>
2c) Z(0)*Qubit('10')=|10>
2d) Z(0)*Qubit('11')=-|11>
2e) Z(1)*Qubit('00')=|00>
2f) Z(1)*Qubit('01')=|01>
2g) Z(1)*Qubit('10')=-|10>
2h) Z(1)*Qubit('11')=-|11>
The ouput in line 1a) and 1b) are correct as my opinion is concerned but line 2b), 2c), 2f) and 2g) are wrong.
Where is the problem?
Any help is welcome.
Kind regards
Klaus
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的输出是正确的,这确实就是Z门的工作方式。
我相信您的担忧是由于误解而引起的。例如,在2b中:
'01'在qubit('01')中表示这些是Qubits的状态。 (在开始时,您有2 Q量的寄存器,其中Qubit Number 0处于状态| 1>,而Qubit Number 1处于状态| 0>)。
您也可以以:
此“零”这不是量子的状态,它是应用z门的数字(索引)。
因此,将两者结合在一起:
您将Z Gate应用于Qubit编号0(最右边的量子,与状态| 1>)相同。
z门在一个量子位上运行(因此量号1保持不变,而Qubit号码0的门翻转相位仅保持0)。您可以将其表示为:
..哪种与输出相同。
Your output is correct, that is indeed how Z gate works.
I believe that your concerns are caused by notation misunderstanding. For example, in 2b:
'01' in Qubit('01') means these are states of the qubits. (At the beginning you have 2-qubit register where qubit number 0 is in state |1> and qubit number 1 is in state |0>).
You can write this also in a form of:
This "zero" here is not a state of a qubit, it is a number (index) of a qubit on which Z gate is applied.
So, after combining the two:
You apply Z gate on qubit number 0 (rightmost qubit, the same which was in state |1>).
Z gate operates on one qubit (so qubit number 1 remains unchanged, and the gate flips phase of qubit number 0 only). You can denote this as:
..which is the same as shown by your output.