I want to work out some commutator manipulations and found this tool in sympy. It appears to work as expected (but the documentation is virtually non-existent or at least I found little, but see the comment by Dalton Bentley below), but I ran into the following problem.
from sympy.physics.quantum import Commutator as Comm
from sympy.physics.quantum import Operator
A = Operator('A')
B = Operator('B')
C = Comm(Comm(Comm(A,B),A),B)
D = Comm(Comm(Comm(A,B),B),A)
E = (C-D).expand(commutator=true)
E
>>> [[[A,B],A],B] - [[[A,B],B],A]
instead of the expected simpler result 0
(since [[[A,B],A],B] = [[[A,B],B],A]). So how can I force the simpler result without evaluating the commutators (i.e. w/o calling the doit()
function)? Note that
simplify(E.doit())
>>> 0
gives the desired result.