Ask Your Question

Revision history [back]

If FreeAlgebra doesn't provide what you're looking for, note that Maxima also implements noncommutative symbolic algebra, and you can access it from sage with, e.g., the maxima command:

sage: e = maxima('expand((ax . px + ay . py + az . pz)^^2);')
sage: e
(az.pz)^^2+az.pz.ay.py+az.pz.ax.px+(ay.py)^^2+ay.py.az.pz+ay.py.ax.px+(ax.px)^^2+ax.px.az.pz+ax.px.ay.py

Note that this uses Maxima's syntax, which is generally different from Sage's. You can read more about it starting here (SO) or here (Maxima manual).