Ask Your Question
3

Symbolic simplificaction without commutativity

asked 2014-01-08 23:37:57 -0600

akels gravatar image

updated 2014-01-09 01:30:25 -0600

I would like to expand the expression:

$$(a_x p_x + a_y p_y + a_z p_z + b m)^2$$

where:

$a_x a_y \neq a_y a_z$

Or generally speaking the objects $a_x,a_y,a_z,b$ are non-commutative for multiplication.

edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted
3

answered 2014-01-09 01:43:30 -0600

niles gravatar image

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
edit flag offensive delete link more

Comments

The $p_x,p_y,p_z$ needs to be commutative.

akels gravatar imageakels ( 2014-01-09 19:07:24 -0600 )edit
1

answered 2014-01-10 00:45:57 -0600

mmarco gravatar image

In your particular example, you are doing the computation on the free algebra on ax,ay,az,b over the polynomial ring on px,py,pz,m.

sage: R.<px,py,pz,m>=QQ[]
sage: F.<ax,ay,az,b>=FreeAlgebra(R)
sage: (ax*px+ay*py+az*pz+m*b)^2
px^2*ax^2 + px*py*ax*ay + px*pz*ax*az + px*m*ax*b + px*py*ay*ax + py^2*ay^2 + py*pz*ay*az + py*m*ay*b + px*pz*az*ax + py*pz*az*ay + pz^2*az^2 + pz*m*az*b + px*m*b*ax + py*m*b*ay + pz*m*b*az + m^2*b^2
edit flag offensive delete link more
1

answered 2014-01-09 01:43:55 -0600

niles gravatar image

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).

edit flag offensive delete link more

Comments

Nice work, Niles.

kcrisman gravatar imagekcrisman ( 2014-01-09 04:03:19 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2014-01-08 23:37:57 -0600

Seen: 299 times

Last updated: Jan 10 '14