I want to use the NCAlgebra package to do some simplification on non commutative expressions involving integrals. For example, one such expression would be

$$ I=\left(\int f(x)g(x) dx\right) * h $$

where $*$ denotes non-commutative multiplication. Let's say that I know that $g(x)*h=1$ for all $x$. Then, simplifying the above expression yields

$$ I=\int f(x)dx $$

So far, I have tried the following to implement this in Mathematica:

<< NC`
<< NCAlgebra`

NCReplaceRepeated[(A b[X] F[X]) ** (G h J), b[X_] ** h -> 1]

which results in

A G J F[X]

as expected. However, this does not work for

NCReplaceRepeated[(Integrate[A b[X] F[X], X]) ** (G h J), b[X_] ** h -> 1]

which results in

A G J (Integrate[b[X] F[X], X]) ** h

which does not respect this simplification.

Of course, there need to be several assumptions about the integral regarding e.g. convergence. But I want to assume that "everything works out nicely" and that this type of simplification is OK. Additionally, instead of Integrate, Sum might be used. This simplification does not work either.

How can I properly perform this simplification?


1 Answer 1


The problem here is with Integrate. The evaluation

expr = Integrate[f[X] ** g[X], X] ** h
NCReplaceRepeated[expr, g[X_] ** h -> 1]

does not simplify as you expect because expr is


and Integrate is not associative. Check that Attributes[Integrate] does not include Flat. Therefore, if you want it to associate with your product you have to define a rule for that. For example:

expr = Integrate[f[X] ** g[X], X] ** h
NCReplaceRepeated[expr, {Integrate[x_, y_] ** z_ :> Integrate[x ** z, y], g[X_] ** h -> 1}]

will evaluate to


as you want. Note the delayed rule to prevent the simplification of the right-hand side of the rule.

Also be careful with how you operate with ** with NCAlgebra. The product is non-commutative only if the symbols which it operates on are declared as noncommutative. The above manipulations work because I am using lower cap single letters that are defined to be noncommutative by default. Check out the NCAlgebra documentation for more details.


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.