# [Maxima] ratmx + matrix_element_mult + ...

Barton Willis willisb at unk.edu
Wed Nov 4 11:21:43 CST 2009

```Thanks. Also, dotscrules needs to be true (nondefault value):

(%i14) declare([a, b,c,d], scalar)\$
(%i15) matrix_element_mult : "."\$

(%i16) dotscrules : true\$

(%i17) s.s;
(%o17) matrix([b*c+a^2+7,b*d+a*b+10],[c*d+a*c+15,d^2+b*c+22])

The ratmx : true case is still trouble:

(%i18) ratmx : true\$

(%i19) s.s;
(%o19) matrix([1,2],[3,4])^2+matrix([a,b],[c,d])^2

(%i20) expand(%);
(%o20) matrix([a^2+1,b^2+4],[c^2+9,d^2+16])

Barton

macrakis at gmail.com wrote on 11/04/2009 07:34:55 AM:

> [image removed]
>
> Re: [Maxima] ratmx + matrix_element_mult + ...
>
> Stavros Macrakis
>
> to:
>
> Barton Willis, maxima
>
> 11/04/2009 07:34 AM
>
> Sent by:
>
> macrakis at gmail.com
>
> Barton,
>
> If you declare the matrix elements scalar, the non-commutative ops
> will simplify to commutative.
>
>           -s
>
> On 11/4/09, Barton Willis <willisb at unk.edu> wrote:
> >
> > Consider a list of matrices
> >
> >  (%i2)  s : [matrix([1,2],[3,4]), matrix([a,b],[c,d])]\$
> >
> > OK
> >
> >  (%i3)  first(s).first(s) + second(s).second(s);
> >  (%o3) matrix([b*c+a^2+7,b*d+a*b+10],[c*d+a*c+15,d^2+b*c+22])
> >
> > Can we do this with s.s? No, to get the dot product to work, we need
> > to set matrix_element_mult to noncummuative multiplication, but then
> > the matrix products are done with noncommuative multiplication too.
> >
> >  (%i4)  matrix_element_mult : "."\$
> >
> >  (%i5) s.s;
> >  (%o5) matrix([b . c+a^^2+7,b . d+a . b+10],[d . c+c . a+15,d^^2+c .
b+22])
> >
> > When ratmx is true (often a good choice), it's worse
> >
> >  (%i6) ratmx : true\$
> >  (%i7) s.s;
> >
> > Unsimplified:
> >
> >  (%o7) matrix([1,2],[3,4])^2+matrix([a,b],[c,d])^2
> >  (%i8) expand(%,0,0);
> >  (%o8) matrix([a^2+1,b^2+4],[c^2+9,d^2+16])
> >
> > Barton
> >
> > Barton
> >
> > _______________________________________________
> > Maxima mailing list
> > Maxima at math.utexas.edu
> > http://www.math.utexas.edu/mailman/listinfo/maxima
> >

```