0
$\begingroup$

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
$\endgroup$
7
  • $\begingroup$ Welcome to Mathematica StackExchange! Can you please include Mathematica code of your commutator in the question? $\endgroup$
    – Domen
    Commented Oct 29, 2023 at 13:41
  • $\begingroup$ I meant the exact expression with Integrate and f and a ... $\endgroup$
    – Domen
    Commented Oct 29, 2023 at 14:05
  • $\begingroup$ I am not sure what you mean, the exact expression is at the top of my post and it isn't simplifying. I've figured out a related problem is that Sy**a**a-a**a**Sy evaluates to zero but Sy^2**a**a-a**a**Sy^2 does not, for some reason Sy^2 is being treated differenty. I've already used Sy /: NumberQ[Sy] = True; to set Sy to be commutative but maybe this doesn't work for Sy^2 $\endgroup$
    – Luca
    Commented Oct 29, 2023 at 14:21
  • $\begingroup$ Yes, but the expression at the top is in $\LaTeX$ form. Please include Mathematica version of this expression (e.g. a * Integrate[f, t] ** ...). $\endgroup$
    – Domen
    Commented Oct 29, 2023 at 14:30
  • $\begingroup$ For example 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$
    – Luca
    Commented Oct 29, 2023 at 14:35

1 Answer 1

1
$\begingroup$

Suppress evaluation at all instances

  SetAttributes[comm, HoldAll];
  comm[A_, B_] := A ** B - B ** A -> 
    ReleaseHold[ExpandAll[Hold[A ** B - B ** A] /. {HoldPattern[a ** ad_] :> ad ** a + 1}]]


    comm[-a Integrate[f[1, t], t], a ** a]

$$(-a \int f(1,t) \, dt)\text{**}a\text{**}a-a\text{**}a\text{**}(-a \int f(1,t) \, dt)\to (-a \int f(1,t) \, dt)\text{**}(a\text{**}a+1)-(a\text{**}a+1)\text{**}(-a \int f(1,t) \, dt)$$

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.