[Maxima] calculations involving matrices of matrices

Barton Willis willisb at unk.edu
Tue Sep 16 05:19:30 CDT 2008


-----maxima-bounces at math.utexas.edu wrote: -----

>1. How can I tell maxima that an atom (not sure it is the correct term,
>let say a non-initialized variable) is a matrix?

Maxima doesn't have a built-in way to declare an atom to be
a matrix. You could do this by defining 'symbolic_matrix' to
be a feature; for example

 (%i1) declare(symbolic_matrix, feature)$
 (%i2) declare(a, symbolic_matrix)$
 (%i3) featurep(a,symbolic_matrix);
 (%o3) true

>2. If variables 'a', 'b', ... 'h' are matrices and
>
>    [a  b]       [e  f]
>A = [    ] , B = [    ]
>    [c  d]       [g  h]
>
>then A . B is calculated in maxima as
>
>        [a*e+b*g a*f+b*h]
>A . B = [               ]
>        [c*e+d*g c*f+d*h]
>
>(where the multiplications denoted by '*' are by element)
>
>I would like to do it rather as
>
>        [a.e+b.g a.f+b.h]
>A . B = [               ]
>        [c.e+d.g c.f+d.h]
>
>(where the multiplications are in matrix sense).
>
>Can I achieve this somehow?

Yes, Maxima can do this.

 (%i5) matrix_element_mult : "."$

 (%i6) matrix([a,b],[c,d]) . matrix([e,f],[g,h]);
 (%o6) matrix([b.g+a.e,b.h+a.f],[d.g+c.e,d.h+c.f])

And

 (%i7) matrix_element_mult : lambda([a,b], min(a,b))$
 (%i8) matrix([a,b],[c,d]) . matrix([e,f],[g,h]);
 (%o8) matrix([min(b,g)+min(a,e),min(b,h)+min(a,f)],[min(d,g)+min(c,e),min
 (d,h)+min(c,f)])

You can also redefine matrix_element_add.

Barton




More information about the Maxima mailing list