Matrix Multiplication

advertisement
Contents









Introduction
Matrix Multiplication
Partitioned Matrices
Powers of a Matrix
Transpose of a Matrix
Theorems and Proofs
Application of Matrix Multiplication
Questions
Links
The Matrix…
What is a matrix?
A matrix is a rectangular array of numeric or algebraic quantities subject to
mathematical operations, or a grid of numbers.
Row → 2
1
4
-3
↑
Column
7
6
The size of this matrix is m × n, where m represents the number of rows and n
represents the number of columns. For example, the matrix shown above is a 2×3
matrix.
Matrix Multiplication
Scalar Multiplication
Consider the following
If s is a scalar and A is a matrix
1
s = 2, and A = 4
2
1
sA = 2 * 4
2
5
3
1
5
3
1
=
2(1)
2(4)
2(2)
2(5)
2(3)
2(1)
2
= 8
4
10
6
2
Rule: if s is a scalar and A is a matrix, then the scalar multiple sA is the matrix
whose columns are s times the corresponding entries in A. In other words,
you take the scalar and multiply it with every number in the matrix.
Theorem: If r and s are scalars, then (r + s)A = rA + sA and r(sA) = (rs)A.
Matrix Multiplication
Before you multiply a matrix by another matrix, you need to check the compatibility of
the two matrices. The number of columns (n) in A must equal the number of
rows (m) in B in order to carry out the matrix multiplication.
Example 1
A= 2
1
5
3
B= 3
8
m×n
2×2
1
2
7
4
m×n
2×3
You can see that the number of columns of A matches the number of rows of B.
(Later on, you will see that the size of matrix AB will be m of A × n of B).
Example 2
A=2
1
5
3
2×2
B=3
8
4
1
2
1
7
4
2
3×3
Obviously, n of A ≠ m of B and thus they are not compatible for multiplication.
Example 3
Find the product AB from the following matrices
A= 1
5
0
3
B= 6
4
-7
3
-3
2
-2
-1
A is a 2×3 matrix and B is a 3×2 matrix, and they are compatible.
To get the final product, we will be sequentially multiplying each row in one matrix by
the corresponding column in another matrix. In this example, we take the first row of A
and first column of B, multiply the first entries together, second entries together, and
third entries together, and then add the three products.
1
0
-2
*
6
4
-7
= 1(6) + 0(4) + (-2)(-7) = 20
Example 3 cont.
This sum is one of the entries in the product matrix AB; in fact, being the product of
row 1 of A and column 1 of B, it is the (1,1)-entry in AB.
Column 1
↓
Row 1 → 20
#
#
#
Then we continue in like manner; we multiply row 1 of A by column 2 of B.
1
0
-2
*
3
-3
2
= 1(3) + 0(-3) + (-2)(2) = -1
And its position in matrix AB is
Column 2
↓
20
-1 ← Row 1
#
#
Example 3 cont.
Multiplying row 2 of A by column 1 of B gives
5
3
1
*
6
4
-7
= 5(6)+3(4)+(1)(-7) = 35
And its position in matrix AB is at row 2 and column 1.
You can do the last multiplication of row 2 of A by column 2 of B by yourself.
So the final answer is
AB = 1
5
0
3
-2
1
*
6
4
-7
3
-3
2
= 20
35
-1
8
Handy trick: As we mentioned before, the size of matrix AB is 2×2 (A is a 2×3 matrix and
B is a 3×2 matrix).
AB ≠ BA (Can you see why?)
Partitioned Matrices
Matrices can be written as partitioned matrices.
Example
3
A = -6
2
0
-4
-5
-1
0
4
-2
3
8
9
1
0
5
7
1
Can also be written as a 2×3 partitioned matrix
A = A11
A21
A12
A22
A13
A23
A11 = 3
-6
0
-4
-1
0
A12 =
-2
3
9
1
A13 = 5
7
A21 = 2
-5
4
A22 =
8
0
A23 = 1
Multiplication of Partitioned Matrices
Example
5
A= 3
0
1
2
-3
-4
1
7
2
4
1
A = A11
A21
A12
A22
B=
B1
B2
AB = A11 A12 * B1
A21 A22
B2
-2
0
1
B=
= A11B1+ A12B2 = 15
A21B1+ A22B2 25
19
-56
5
63
4
1
3
2
-1
-6
-2
7
5
3
Powers of a Matrix
If A is a n×n matrix and if K is a positive integer, then K can be raised to the power of
A, as in AK and means that you can have K copies of A.
Example A3 = A*A*A
If we have A being nonzero, and X is in the set of real numbers, then AKX is like
multiplying X by A repeatedly K times. However, if K = 0, then A0X should be X itself
as A would be interpreted as the identity matrix. In this way, matrix powers end up
being very useful in both theoretical and applied means.
Transpose of a Matrix
If we have a given matrix, A that is if the size mxn, then the transpose of it would be
an nxm matrix and is denoted by AT. In other words, you take an initial row in the
original matrix and make it a column in the transposed matrix, and vice versa with the
rows. Let’s look at an example,
A=
5 2
1 3
0
4
, and if we follow the rules then AT =
5 1 0
2 3 4
Theorems and Proofs
All right people, I know this is the part where it gets really technical, but in the true
sense of achievement and comprehension of the concepts here, we believe this too is
necessary.
Theorem 1
Let A, B and C be matrices of the same size, and let p and q be scalars.
a.
b.
c.
d.
e.
f.
A+B = B+A
(A+B) + C = A + (B + C)
A+0=A
p(A + B) = pA + pB
(p+q)A = pA + qA
p(q A) = (pq) A
The proof of all these equalities lies in showing that each of the matrices of the left
hand side are equal in size to the matrix on the right hand side, and also by showing
that entries in corresponding columns are equal. We already assumed that the
matrices are of equal size at the start, so that is taken care of. As for the other
condition, that seems to be satisfied with if we follow the analogous properties of
vectors. For those of you who are not aware of these, here’s an example.
If the jth column of A, B, and C are aj, bj, and cj, respectively, then the jth
columns of (A+B)+C and A+(B+C) are (aj + bj) + cj and aj + (bj + cj)
respectively. Since the two vector sums are equal for each j, property (b) is
verified. Moreover, because of the associative property of addition, we can say
that A+B+C = (A+B)+C or A+ (B+C), and the same can be applied to the sum of
four or more matrices.
Theorem 2
If A is an p x q matrix, and of B and C have sizes for which the indicated sums and
products are defined, then using some basic laws of arithmetic and some others
we can also verify the following statements:
a.
b.
c.
d.
e.
A (BC) = (AB) C
A (B + C) = AB + AC
(B+C)A = BA+ CA
r(AB) = (rA) B = A(rB)
ImA = A = AIn
(associative law of multiplication)
(left distributive law)
(right distributive law)
for any scalar r
(identity for matrix multiplication)
Proof
Statements a to d are self explanatory and the basic laws of arithmetic stated are what
verify them as well. As for statement e, the identity matrix is just 1 0 and that
0 1
multiplied by any matrix is the matrix itself.
Example
2 2
2 2
Theorem
3



1 0
0 1
=
2 2
2 2
(You should be able to see why that is correct)

Let A and B denote matrices whose sizes are compatible enough for the following sums
and products.
a.
b.
c.
d.
(AT )T = A
( A+B)T = AT + BT
For any scalar p, (p A)T = p AT
( AB )T = BT AT
Proof
Proofs of A to C are straight forward and thus omitted. For d, let’s look at this
example.
Let
A=
5 2
1 3
0

,B=
4

Whereas, BT =
1 1 1 1
3 5 2 7
1 3
1 5
1 2
1
7
, then (AB) =
and AT =
5 1 0
2 3 4

11 10 12
5 14 20 .
9
7
8
9 20 28
and
Moreover,
(AB)T
=
11 5 9 9
10 14 7 20
12
20
8
 11 10 12
BT AT = 15 14 20
9
7
8
9 20 28
 hand side of the
Thus, as both the answersto the left hand side and the right
equation are the same, then the statement is proved.
28
.
Theorem 4
Column - row expansion of AB
If A is an mxn matrix and B is an nxp, then,
AB = [col1 (A)
col2 (A) … coln(A)]
Proof
row1(B)
row2(B)
.
.
.
rowN(B)
= col1(A) row1(B) + … + coln (A)rown(B)

For each row index i and column index j, the (i, j)- entry in colk (A) rowk (B) is the
product of aik from colk(A) and bkj from rowk (B). Hence the (i,j)-entry in the sum
shown in (1) is
ai1 b1j
(k=1)
+
ai2 b2j
(k=2)
+ … + ain bnj
(k=n)
This sum is also the (i, j)-entry in AB, by the row-column rule.
Row - Column rule for Computing AB:
If the product AB is defined, then the entry in row i and column j of AB is the sum of
the products of corresponding entries from row i of A and column j of B. If (AB)ij
denotes the (i, j)-entry in AB, and if A is an m x n matrix, then
(AB)ij = ai1 b1j + ai2 b2j + … + ainbnj
Warnings:
Finally, there are a few things that we would like you to keep in mind.
1.
2.
3.
In general, AB does not equal BA.
The cancellation laws do not hold for matrix multiplication. That is, if AB = AC.
The it is not true in general that B = C.
If a product AB is the zero matrix, you cannot conclude in general that either
A = 0 or B = 0.
Application of Matrix Multiplication
Now, We are sure you must all be aware that matrix multiplication is not just a random
concept that we learn in mathematics. It has many useful applications in everyday life
and also in other branches of math. So now, we will spend some time looking over and
trying to understand what exactly it is and where it is that matrix multiplication is
applicable.
The Matrix Application Ax = b
As stated before, one of the most useful applications of matrix multiplication in math is
in the matrix equation.
The fundamental idea behind this equation is that in Linear Algebra we can view a linear
combination of vectors as the product of a matrix and vector (a quantity specified by a
magnitude and a direction). And it is in this fundamental concept that lies the existence
of matrix multiplication. This is because a vector can be written in matrix notation and
then multiplied to the other matrix to obtain one side of the equation and then carry out
the appropriate operations and functions from there on end.
A formal definition stating this relationship is given below.
Definition
If A is a m x n matrix, with columns a(1),…,a(n), and if x is in the collection of all the
lists of real numbers, then the product of Ax, is the linear combination of the columns
of A using the corresponding entries in x as weights; that is,
Ax = [ a1
x1
a2 … a(n)] * x2 = x1a1
x(n)
+
x2a2
+ … + x(n)a(n)
Note that Ax is defined only if the number of columns of A equals the number of
entries in x.
Example
For a given set of vectors, v1,v2,and v3 in the real set of number R, and the weights 3,
-5, and 7, write up a linear combination by combining a matrix and a vector.
Step 1 Write out the vector in matrix notation,
v1, v2, v3 =
[ v1
v2
v3]
Step 2 Write out the weights as a column matrix as well,
3, -5 and 7 in a column matrix would equal
3
-5
7
Step 3 Write them out side by side and multiply,
3
[v1 v2 v3] -5 = 3v1 – 5v2 +7v3
7
We can only multiply two matrices together when the columns of the first matrix equal
the rows of the second.
Matrix Multiplication in Economics
We gave you an example of how matrix multiplication could be used in math itself, but
how about in real life, what benefit can it provide to us? Well, one of the major benefits
is seen when scalar multiples and linear combinations can arise when a quantity such as
'cost; is broken down into several categories. The basic principle for the example
concerns the cost of producing several units of an item when the cost per unit is known.
{Number of units} * {Cost per unit} = {Total cost}
Example
A company manufactures two products. For $ 1.00 worth of product A, the company
spends $ .40 on labor, $.20 on labor, and $.10 on overhead. For $1.00 worth of product
B, the company spends $.30 on materials, $.25 on labor, and $.35 on overhead.
Suppose the company wishes to manufacture x1 dollars worth of product A and B. Give
a vector that describes the various costs the company will have to endure?
Step 1
.40
A = .20
.10
.30
and B = .25
.35
Step 2
The cost of manufacturing x1 dollars worth of A are given by x1*A and the costs of
manufacturing x2 dollars worth of B are given by x2.B. Hence the total costs for both
products are simply given by their products once again,
.40
.30
[ x1 ].20 + [ x2 ] .25 = x1*A + x2*B.
.10
.35
Questions
Here are some matrix multiplication problems you can practice with. And of course, you can
check your answers in the end.
Test 1
1.
-2 -1 0
4 4 1
4 -4 4
2.
3.
4.
-1 0
2 -2
0
1
3 4
4 3
0 -4
1 1
4
-4
-4
-2
-4
1
-4
4
4
-1
1
4
-2
-3
-1
-4
-4
1
-1
1
1
1
4
Test 2
5. 2 -3
-4 1
-4 -3
-4
1
1
-1
6. -1 3 4
4 -2 3
2 -3 2
0
-4
-3
-3
1
-1
7. -1 2 4
-3 -3 4
-1 -1 1
4
2
1
3
-3
-1
8. -1
-1
-2
3
2
4
-4
2
2
0
-3
0
As promised, here are all the answers.
1.
5.
-11
17
13
-4
10
6.
-24
2
- 1 17
6 -11
3.
4 -19
11 -19
7.
4 -13
-14
-4
-5
-1
4.
-4
-3
8.
1 -12
1 -12
-6 -8
2.
-4
-4
16
8
-23
12
4
-16
-4
0
-3
12
16
5
-5
-1
-16
12
12
Links
http://mathworld.wolfram.com/MatrixMultiplication.html
http://www.mai.liu.se/~halun/matrix/matrix.html
http://www.cs.sunysb.edu/~algorith/files/matrix-multiplication.shtml
http://www.purplemath.com/modules/mtrxmult.htm
http://www-math.mit.edu/18.013A/HTML/chapter03/section04.html
Download