Is it possible to make ncalgebra factorize commutative coefficients to the left?
For example, if I define a non-commutative object
W and a commutative object
and then write
the output is, as expected, just
a W. Same for
However, if I write
instead, for some reason
a[t] lands on the right and the output is
Even if I apply
Simplify to the latter, it still remains the same.
Finally, if I write
a[t] W + a[t] tp[W] // Simplify
then the output looks as I would want it to:
a[t] (W + tp[W])
I found two similar questions on the forum, but the approach with
NCCollect doesn't work here.
By the way, the
LeafCount of the expression factored as I want it to be is one less than the
LeafCount of the output.
P.S. I found the following approach to my real life example: First, it feels more like a kludge than a solution, but it does the job. Secondly, the commutative factor is still not on the left, but at least the formula it's taken out.
Is there a better way to do it?