换向器#

换向器: [A,B] =一个 B - B a.

class sympy.physics.quantum.commutator.Commutator(A, B)[源代码]#

处于未估价状态的标准换向器。

参数:

A :表达式

交换子的第一个论点 [A,B] .

B :表达式

换向器的第二个论点 [A,B] .

解释

Evaluating a commutator is defined [R754] as: [A, B] = A*B - B*A. This class returns the commutator in an unevaluated form. To evaluate the commutator, use the .doit() method.

交换子的正则序是 [A, B] 对于 A < B . 用 __cmp__ .如果 B < A 然后 [B, A] 返回为 -[A, B] .

实例

>>> from sympy.physics.quantum import Commutator, Dagger, Operator
>>> from sympy.abc import x, y
>>> A = Operator('A')
>>> B = Operator('B')
>>> C = Operator('C')

创建换向器并使用 .doit() 要评估它:

>>> comm = Commutator(A, B)
>>> comm
[A,B]
>>> comm.doit()
A*B - B*A

换向器按规范顺序排列参数:

>>> comm = Commutator(B, A); comm
-[A,B]

交换常数被考虑在内:

>>> Commutator(3*x*A, x*y*B)
3*x**2*y*[A,B]

使用 .expand(commutator=True) ,可采用标准换向器展开规则:

>>> Commutator(A+B, C).expand(commutator=True)
[A,C] + [B,C]
>>> Commutator(A, B+C).expand(commutator=True)
[A,B] + [A,C]
>>> Commutator(A*B, C).expand(commutator=True)
[A,C]*B + A*[B,C]
>>> Commutator(A, B*C).expand(commutator=True)
[A,B]*C + B*[A,C]

应用于换向器的伴随运算正确地应用于参数:

>>> Dagger(Commutator(A, B))
-[Dagger(A),Dagger(B)]

工具书类

doit(**hints)[源代码]#

评价换向器