# [Maxima] What is wrong in multiplication of matrices

Stavros Macrakis macrakis at alum.mit.edu
Tue Jul 20 09:18:21 CDT 2010

```The elements of matrices are added/multiplied using matrix_element_add and
matrix_element_mult, which are by default scalar + and *, but user-settable.

On Tue, Jul 20, 2010 at 10:11, Zbigniew Komarnicki <cblasius at gmail.com>wrote:

> Hello,
>
> I try to multiply matrices by matrix congruence. First introduce the
> following
> matrices A, C, P, Q:
>
> declare([A,C,P,Q], nonscalar);
>
> and the following block matrices:
> m: matrix([P^^(-1), 0, 0], [0,1,0],[0,0,1]);
> M: matrix([-P, transpose(A), transpose(C)], [A, -P^^(-1), 0], [C,
> 0, -Q^^(-1)]);
>
> Then multiply it as follows
> r1: m . M . m;
> and I got wrong result. Why, because on position r1[1,2] is
> (I obtain it by grind(r1[1,1])\$)
> 'transpose(A)*P^^(-1)
>
> but should be
> P^^(-1) . transpose(A)
>
> I see that in the multiplication were used operator * but I declare that
> A,C,P,Q are nonscalars and it should use the . operator. Why it is not
> done?
> Or how I can multiply matrices as block matrices? I want only operate on
> symbolic matrices as A,C,P,Q not as real i.e.
> A: matrix([1,2],[3,4])  <---- not on such matrices, where are values
>
> I want to work on symbolic matrices. Is maybe any chance to introduce in
> future versions of maxima something such as:
>
> declare([A,C,P,Q], symbolic_matrix)
>
> to tell maxima that I operate on matrices in symbolic way?
>
> I also want to ask how to simplify r1[1,1]
> -P*(P^^(-1))^2
>
> it should simplify to
> -P
>
> but there is * not . so it couldn't simplify.
>
> When I write with . it also do not simplify, why?
> -P . (P^^(-1))^2
> I got:
>          <- 1> 2
>  - P . (P     )
>
> But when I write
> -P . P^^(-1);
> then I got correct results:
>  - 1
>