Beruflich Dokumente
Kultur Dokumente
Matrices multiplication
Multiplication of matrices
We know how to multiply a matrix and a vector (of the right size!). Now we want to define how to
multiply matrices by matrices.
Definition. Let A be an m n-matrix and let B be an n p-matrix. We define
AB := [Ab1 Ab2 Abp ]
Example 1. Compute AB where
4
A= 3
0
2
2
5 and B =
6
1
3
7
Solution.
4
2
8
12
4
Ab1 = 2 3 + 6 5 = 6 + 30 = 24
1
0
6
6
0
4
2
12
14
2
Ab2 = 3 3 7 5 = 9 + 35 = 26
0
1
0
7
7
Therefore
AB = [Ab1
4
Ab2 ] = 24
6
2
26
7
Remark. Note that Ab1 is a linear combination of the columns of A and Ab2 is a linear combination of the columns of A. Each column of AB is a linear combination of the columns of A
using weights from the corresponding columns of B.
1
Composition vs multiplication
During the last lecture, we learnt that we can think of matrices as machines.
Let B be n p: input x Rp , output c = Bx Rn .
Let A be m n: input y Rn , output b = Ay Rm .
We already saw that these machines can be composed.
x
Bx
A(Bx)
A
(AB)x
AB
Example 3. Consider
2
A=
1
0
,
1
1
B=
0
2
,
1
x
x= 1
x2
ai1
ai2
ain
b1j
b2j
..
.
bnj
(AB)ij
If you know about dot products you see that every entry in the product AB is the dot product of a
row vector (of A) and a column vector (of B).
2 3
2 3 6
1 . Compute AB, if it is defined.
Example 4. A =
,B= 0
1 0 1
4 7
Solution.
AB =
22+30+64
1 2 + 0 0 + 1 4
2 (3) + 3 1 + 6 (7)
28
=
1 (3) + 0 1 + 1 (7)
2
45
4
1 0 ... 0
0 1 . . . 0
where In = . . .
is the identity matrix af size n.
. . ...
.. ..
...
Remark. WARNING! Properties above are analogous to properties of real numbers. But NOT
ALL properties of real number also hold for matrices.
1 1
1 0
Example 5. Let A =
, B =
. Determine AB and BA. Are these matrices the
0 1
1 1
same?
3
Solution.
2
AB =
1
1
BA =
1
1
1
1
2
No. These matrices are not the same: AB 6= BA. Matrix multiplication is not commutative.
Transpose
Definition. If A is m n, the transpose of A is the n m matrix, denoted by AT , whose columns
are formed from the corresponding rows of A. In terms of matrix elements: (AT )ij = Aji .
1 2 3 4 5
Example 6. Let A = 6 7 8 9 8 . What is AT ?
7 6 5 4 3
Solution.
The transpose of A is the matrix whose columns are the rows of A. Thus
1 6 7
2 7 6
AT =
3 8 5
4 9 4
5 8 3
Example 7. Let A =
1
3
2
0
0
1
,B=
1
0
2
2
1 . Compute AB, (AB)T , AT B T and B T AT .
4
Solution.
1
3
1
4
AB =
2
0
0
1
1
0
2
2
1
1
=
1
4
4
10
1
10
1 3
7 3
1
0
2
AT B T = 2 0
= 2 0
2 1 4
0 1
2 1
1 3
1 0 2
1 1
2 0 =
B T AT =
2 1 4
4 10
0 1
T
(AB) =
10
4
4
Example 8. Let A =
2
3
3
0
and B =
1
2
3
. Which of these matrices are symmetric?
0
Solution.
AT =
2
3
3
1
T
BT =
0
2
3
0
T
2
3
3
= A.
1
0
3
2
6 B.
=
0
So A is symmetric.
Theorem 4. Let A and B denote matrices whose sizes are appropriate for the following sums and
products.
(a) AT
T
= A,
T
(b) (A + B) = AT + B T
T
(d) (AB) = B T AT
T
Powers of A
Definition. We write Ak for A A, k-times; that is Ak is obtained by multiplying A k-times with
itself.
Question. For which matrices A does Ak make sense? If A is m n what can m and n be?
Solution.
Let A be an m n-matrix. To be able to multiply A with itself, we need that m = n.
1
3
3
0
.
2
Solution.
1
3
0
2
3
1
3
0
2
1
3
0
2
1
9
0
4
1
3
0
2
1 0
21 8
=
=
=
1
3
0
2
Remark. In general, calculating high powers of large matrix in this way is very hard. We will later
learn a clever way to do this efficiently.
An application
Example 11. The processors of a supercomputer are inspected weekly in order to determine their
condition. The condition of a processor can either be perfect, good or bad. A perfect processor is still
perfect after one week with probability 0.7, with probability 0.2 the state is good and with probability
0.1 it is bad. A processor in good condition is still good after one week with probability 0.6 and bad
with probability 0.4. A bad processor stays bad.
(a) What is the probability that a processor in perfect condition is in bad condition after two weeks?
(b) Let us see how this connects to matrix multiplication. Write down the matrix
(a) There are three possible paths for the processor to go from good to bad in three weeks. Either
it goes perfectperfectbad, perfectgoodbad, or perfectbadbad. The probability of
the first is (.7)(.1) = .07, the probability of the second is (.2)(.4) = .08, and the probability of
the third is .1. Thus adding these up we see the total probability is .25.
(b) We get that
.7
T = .2
.1
0
.6
.4
0
0
1
(c) Then
.49 0
T = .26 .36
.25 .64
2
0
0
1
If we use the row column rule for multiplying matrices, we see that the bottom left entry comes
from using the bottom row and left column of T . Thus the bottom left entry is Tp,p Tp,b +
Tp,g Tg,b + Tp,b Tb,b . Each of these corresponds to one of the three paths from [(a)].
(d) This will be the bottom left entry of T n .