I am working with commutators like this $$ \left(a \int f \, \mathrm dt\right) * a - a * \left(a \int f \, \mathrm dt\right),$$
comm[A_, B_] := ExpandAll[A ** B - B ** A //. a ** ad :> ad ** a + 1]
comm[-a Integrate[f[1, t], t], a ** a]
where $a$ is a ladder operator, and I would like the integral to be treated like a number and factored out. For some reason, this expression isn't simplifying to zero.
I tried
Integrate /: NumberQ[Integrate[expr_]] = True;
which doesn't seem to help, and also
Integrate /: NumberQ[Integrate[expr__]] = True;
and
Integrate /: NumberQ[Integrate[__]] = True;
seem to be working but both give the error
Integrate called with 1 argument; 2 or more arguments are expected.
What is the correct syntax for this command?
Note that I also use a variety of rules such as
A_ ** (B_ + C_) := A ** B + A ** C
Integrate
andf
anda
... $\endgroup$Sy**a**a-a**a**Sy
evaluates to zero butSy^2**a**a-a**a**Sy^2
does not, for some reason Sy^2 is being treated differenty. I've already usedSy /: NumberQ[Sy] = True;
to set Sy to be commutative but maybe this doesn't work for Sy^2 $\endgroup$a * Integrate[f, t] ** ...
). $\endgroup$comm[-a Integrate[f[1,t],t], a**a]
will be kept and outputted as $a ** a ** (a \int f(1, t) dt) - (a \int f(1, t) dt) ** a ** a$ $\endgroup$