# Which CAS can do basic non-commutative differential algebra?

This is a repost of my question at MSE from 7 months ago, to which I haven't been able to find an answer yet.

I am looking for a CAS (possibly incl. additional packages/libraries) that can compute generic non-commutative differential expressions. Let me illustrate what I mean by two examples.

Let $$(R,\partial)$$ be a generic non-commutative differential ring (i.e. $$\partial$$ is a derivation on $$R$$), say of characteristic 0 for simplicity. Let $$f \in R$$ be an abstract (or generic if you prefer) element. Then it should be able to express $$\partial^2(1+f)^2$$ as $$2 \partial^2(f) + \partial^2(f) f + 2 \partial(f)^2 + f \partial^2(f)$$ and $$(f\partial)^2 f$$ as $$f \partial(f)^2 + f^2 \partial^2 (f),$$ where the elements $$f$$ and $$\partial^k(f)$$ are treated as black boxes. In particular, the elements $$\partial^k(f)$$ are not assumed to commute with each other in any way for differing values of $$k \geq 0$$.

• I have added an answer mentioning Cadabra to your post on MSE. Commented Jun 20 at 14:48
• @KasperPeeters: Thank you! This is exactly what I was looking for! Feel free to post an answer here as well!
– M.G.
Commented Jun 20 at 14:50

Does this fit your desires? This is Mathematica code:

D[(1 + f[t]) ** (1 + f[t]), {t, 2}]

Out:=(1 + f[t]) ** f''[t] + 2 f'[t] ** f'[t] + f''[t] ** (1 + f[t])


Operation ** is non-commutative multiplication.

• Yes, this seems to work as desired! Thank you! I was not aware of the non-commutative multiplication option in Mathematica! Quick question, though. Is there a way for Mathematica to better group the terms as in my answer for improved overview of the terms?
– M.G.
Commented Jun 20 at 16:48
• Also, can Mathematica compute explicitly the operator $(f\partial)^3$? This is equally important for me.
– M.G.
Commented Jun 20 at 16:53
• @M.G. You can install the package NCAlgebra mathweb.ucsd.edu/~ncalg and then use NCExpand Commented Jun 20 at 16:58
• @M.G. You can also use dot product: D[(1 + f[t]) . (1 + f[t]), {t, 2}]. As long as the objects are not matrices or lists, it will behave like **. Commented Jun 20 at 17:16
• @M.G. In any case you can use the Nest function to repeat an operation n times. Commented Jun 20 at 18:41