1 | initial version |
It sounds like you're looking for FreeAlgebra.
sage: R.<ax,ay,az,px,py,pz> = FreeAlgebra(QQ)
sage: R
Free Algebra on 6 generators (ax, ay, az, px, py, pz) over Rational Field
sage: (ax*px + ay*py + az*pz)^2
ax*px*ax*px + ax*px*ay*py + ax*px*az*pz + ay*py*ax*px + ay*py*ay*py + ay*py*az*pz + az*pz*ax*px + az*pz*ay*py + az*pz*az*pz