So a little bit of background I'm using this modules because I could not figure out how to asign a value to a commutator using sympy.physics.quantum, and all I want is to use known commutators to calculate more complicated ones, so my code goes as
from sympy import * from sympy.physics.secondquant import * comm1=simplify(Commutator(B(0),Bd(0)).doit()) comm1 which outputs one and should be enough to simplify this next commutator w1,w2,g=symbols('w1 w1 g') H=w1*B(0)*Bd(0)+w2*B(1)*Bd(1)+g*Bd(0)*B(1)+conjugate(g)*Bd(1)*B(0) comm2=simplify(Commutator(H,B(0))) print(comm2) However as output I get g*(-AnnihilateBoson(0)*CreateBoson(0)*AnnihilateBoson(1) + CreateBoson(0)*AnnihilateBoson(1)*AnnihilateBoson(0)) + w1*(-AnnihilateBoson(0)*AnnihilateBoson(1)*CreateBoson(1) + AnnihilateBoson(1)*CreateBoson(1)*AnnihilateBoson(0)) + w1*(AnnihilateBoson(0)*CreateBoson(0)*AnnihilateBoson(0) - AnnihilateBoson(0)**2*CreateBoson(0)) + conjugate(g)*(-AnnihilateBoson(0)*CreateBoson(1)*AnnihilateBoson(0) + CreateBoson(1)*AnnihilateBoson(0)**2) and can't figure out how to tell sympy to use the first commutator to simplify this expression, I know it can be done in Cadabra as some answered me in github a few days ago. https://stackoverflow.com/questions/62254012/sympy-how-to-get-simplified-commutators-using-the-second-quantization-module -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/11d3cfeb-8bfb-4b67-af7b-ff0d2914a1feo%40googlegroups.com.