       Re: A question of matrix multiply, who can solve it?

• To: mathgroup at smc.vnet.net
• Subject: [mg25725] Re: A question of matrix multiply, who can solve it?
• From: leko at ix.netcom.com (J. Leko)
• Date: Thu, 19 Oct 2000 04:35:55 -0400 (EDT)
• References: <8sjkht\$g2h@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```In article <8sjkht\$g2h at smc.vnet.net>, Chen Jisheng
<chenjs at iopp.ccnu.edu.cn> wrote:

> Dear Sir,
>
> As a beginning user, I find a mistake of Mathematic 4.0(/3.0 for student).
>
> That is about the multipy method of matrix.
>
> For example, as I input the two matrices:
>
> A={a[1, 1], a[1, 2], a[1, 3], a[1, 4], a[1, 5]}
> {a[2, 1], a[2, 2], a[2, 3], a[2, 4], a[2, 5]}
> {a[3, 1], a[3, 2], a[3, 3], a[3, 4], a[3, 5]}
> {a[4, 1], a[4, 2], a[4, 3], a[4, 4], a[4, 5]}
> {a[5, 1], a[5, 2], a[5, 3], a[5, 4], a[5, 5]},
> B={{b[1, 1], b[1, 2], b[1, 3], b[1, 4], b[1, 5]},
>
>  {b[2, 1], b[2, 2], b[2, 3], b[2, 4], b[2, 5]},
>
>  {b[3, 1], b[3, 2], b[3, 3], b[3, 4], b[3, 5]},
>
>  {b[4, 1], b[4, 2], b[4, 3], b[4, 4], b[4, 5]},
>
>  {b[5, 1], b[5, 2], b[5, 3], b[5, 4], b[5, 5]}},
>
> then calculate the result of A B. The mathematics gives the following
> result:
>
> A B={{a[1, 1] b[1, 1], a[1, 2] b[1, 2], a[1, 3] b[1, 3],
>
>   a[1, 4] b[1, 4], a[1, 5] b[1, 5]},
>
>  {a[2, 1] b[2, 1], a[2, 2] b[2, 2], a[2, 3] b[2, 3],
>
>   a[2, 4] b[2, 4], a[2, 5] b[2, 5]},
>
>  {a[3, 1] b[3, 1], a[3, 2] b[3, 2], a[3, 3] b[3, 3],
>
>   a[3, 4] b[3, 4], a[3, 5] b[3, 5]},
>
>  {a[4, 1] b[4, 1], a[4, 2] b[4, 2], a[4, 3] b[4, 3],
>
>   a[4, 4] b[4, 4], a[4, 5] b[4, 5]},
>
>  {a[5, 1] b[5, 1], a[5, 2] b[5, 2], a[5, 3] b[5, 3],
>
>   a[5, 4] b[5, 4], a[5, 5] b[5, 5]}}.
>
> As all knows, this is not correct. I think it is terrible.

Actually, Mathematica seems to be performing correctly. In this case, I
believe that you asked it to calculate the Outer product of A and B. This
is a tensor operation.

> Do you think so? How can improve it?

If you are looking to multiply two matrices togther as you would in
elementary linear algebra (i.e., row x column), then what you want to
perform is an Inner or Dot product. Try the following example:

In:=
a = Array[x, {2, 2}]
b = Array[y, {2, 2}]
a . b

Out=
{{x[1, 1], x[1, 2]}, {x[2, 1], x[2, 2]}}

Out=
{{y[1, 1], y[1, 2]}, {y[2, 1], y[2, 2]}}

Out=
{{x[1, 1] y[1, 1] + x[1, 2] y[2, 1],
x[1, 1] y[1, 2] + x[1, 2] y[2, 2]}, {x[2, 1] y[1, 1] + x[2, 2] y[2, 1],
x[2, 1] y[1, 2] + x[2, 2] y[2, 2]}}

I am sorry that I cannot properly format these expressions in the
newsreader. You can have Mathematica properly format the a.b expression by
appending //MatrixForm to its end, like this:

a . b//MatrixForm

This should be more of what you are accustomed to seeing.

Regards,

J. Leko

Please e-mail replies to leko*j at cspar.uah.edu and remove the *

```

• Prev by Date: Re: A question of matrix multiply, who can solve it?