I did not know about this "FreeAlgebra".
Thank you for the example you included.  I think this should work!
-Elizabeth

On Apr 22, 12:41 am, Mike Hansen <mhan...@gmail.com> wrote:
> On Wed, Apr 21, 2010 at 8:06 PM, Elizabeth <papag...@earthlink.net> wrote:
> > I'd like to know if there is a way to define a variable in Sage as non-
> > commuting.
> > I am trying to multiply a few matrices together and take the trace,
> > *but* the matrix entries are non-commuting elements.  So, I need Sage
> > to leave a term like  a*x*a as-is and not change it to x*a^2.
>
> You could work over the FreeAlgebra:
>
> sage: R.<a,b> = FreeAlgebra(QQ, 2)
> sage: a*b + b*a
> a*b + b*a
> sage: s = matrix(R)
> sage: s = matrix(R, [[a,b],[b,a]]); s
> [a b]
> [b a]
> sage: s*s
> [a^2 + b^2 a*b + b*a]
> [a*b + b*a a^2 + b^2]
> sage: b*s*s
> [  b*a^2 + b^3 b*a*b + b^2*a]
> [b*a*b + b^2*a   b*a^2 + b^3]
>
> --Mike
>
> --
> To post to this group, send email to sage-support@googlegroups.com
> To unsubscribe from this group, send email to 
> sage-support+unsubscr...@googlegroups.com
> For more options, visit this group 
> athttp://groups.google.com/group/sage-support
> URL:http://www.sagemath.org

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to