Re: Matrix Multiplication...
- To: mathgroup at smc.vnet.net
- Subject: [mg23572] Re: [mg23551] Matrix Multiplication...
- From: BobHanlon at aol.com
- Date: Sat, 20 May 2000 17:44:29 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
In a message dated 5/20/2000 3:36:50 AM, jrchaff at nwlink.com writes:
>New to Mathematica, and to exotic matrix techniques.
>
>Apparently Mathematica does "ordinary" matrix multiplication
>via the "dot" product symbol, "."; but when one uses the
>asterisk, one gets "squaring" of two matrices:
>
>If m1 = {{a,b},{c,d}}; and m2={{e,f},{g,h}}; then
>
>m1*m2 = {{ae, bf},{cg,dh}}, and
>
>m1*m1 = {{a^2, b^2},{c^2, d^2}};
>
>while m1.m2 gives normal matrix multiplication.
>
>What is going on here? What kind of matrix multiplication is
>this "*" giving? Why does it match up with the casual appearance
>of 'squaring' if m1 = m2? I tried the Mathematica function
>"Outer", i.e. "Outer[Times,m1,m2]", and this is NOT the same
>as the result with "*". I don't understand outer products anyway,
>but apparently that is not this, whatever it is.
>
>Can someone give me a short explanation?
>
m1 = {{a, b}, {c, d}};
m2 = {{e, f}, {g, h}};
m1*m2
{{a*e, b*f}, {c*g, d*h}}
(m1*m2) operates in the same manner as (m1+m2) or (m1-m2) or (m1/m2); i.e.,
they all involve pairwise operations on the corresponding elements.
m1 + m2
{{a + e, b + f}, {c + g, d + h}}
m1 - m2
{{a - e, b - f}, {c - g, d - h}}
m1/m2
{{a/e, b/f}, {c/g, d/h}}
These pairwise operations are consistent with the behavior expected for basic
operations
And @@ Table[Sum[m1, {k, 1, n}] == n*m1, {n, 1, 10}]
True
Sum[m1, {k, 1, n}] == n*m1
True
m1 - m1 == 0*IdentityMatrix[Length[m1]]
True
(m1 + m2) - m2 == m1 + (m2 - m2) == m1
True
And @@ Table[Product[m1, {k, 1, n}] == m1^n, {n, 1, 10}]
True
Product[m1, {k, 1, n}] == m1^n
True
m2*(m1/m2) == (m1*m2)/m2 == m1*(m2/m2) == m1
True
To understand what Outer does, just use a generic function, say f,
Outer[f, m1, m2 ]
{{{{f[a, e], f[a, f]}, {f[a, g], f[a, h]}},
{{f[b, e], f[b, f]}, {f[b, g], f[b, h]}}},
{{{f[c, e], f[c, f]}, {f[c, g], f[c, h]}},
{{f[d, e], f[d, f]}, {f[d, g], f[d, h]}}}}
Which for f replaced by Times is
Outer[Times, m1, m2 ]
{{{{a*e, a*f}, {a*g, a*h}}, {{b*e, b*f}, {b*g, b*h}}},
{{{c*e, c*f}, {c*g, c*h}}, {{d*e, d*f}, {d*g, d*h}}}}
m3 = Outer[Times, m2, m1]/m2;
m3[[1, 1]] == m3[[1, 2]] == m3[[2, 1]] == m3[[2, 2]] == m1
True
Bob
BobHanlon at aol.com