Matrix Multiplication
Given two vectors
~a
= [
a
1
, . . . , a
k
] and
~
b
= [
b
1
, . . . , b
k
],
their
inner product
(or
dot product
) is
~a
·
~
b
=
k
X
i
=1
a
i
b
i
•
[1
,
2
,
3]
·
[

2
,
4
,
6] = (1
×
2) + (2
×
4) + (3
×
6) = 24.
We can multiply an
n
×
m
matrix
A
= [
a
ij
] by an
m
×
k
matrix
B
= [
b
ij
], to get an
n
×
k
matrix
C
= [
c
ij
]:
•
c
ij
=
∑
m
r
=1
a
ir
b
rj
•
this is the inner product of the
i
th row of
A
with the
j
th column of
B
1
•
2 3 1
5 7 4
×
3
7
4
2

1

2
=
17 18
39 41
17 = (2
×
3) + (3
×
4) + (1
× 
1)
= (2
,
3
,
1)
·
(3
,
4
,

1)
18 = (2
×
7) + (3
×
2) + (1
× 
2)
= (2
,
3
,
1)
·
(7
,
2
,

2)
39 = (5
×
3) + (7
×
4) + (4
× 
1)
= (5
,
7
,
4)
·
(3
,
4
,

1)
41 = (5
×
7) + (7
×
2) + (4
× 
2)
= (5
,
7
,
4)
·
(7
,
2
,

2)
2
Why is multiplication deFned in this strange way?
•
Because it’s useful!
Suppose
z
1
= 2
y
1
+ 3
y
2
+
y
3
y
1
= 3
x
1
+ 7
x
2
z
2
= 5
y
1
+ 7
y
2
+ 4
y
3
y
2
= 4
x
1
+ 2
x
2
y
3
=

x
1

2
x
2
Thus,
z
1
z
2
=
2 3 1
5 7 4
·
y
1
y
2
y
3
and
y
1
y
2
y
3
=
3
7
4
2

1

2
·
x
1
x
2
.
Suppose we want to express the
z
’s in terms of the
x
’s:
z
1
= 2
y
1
+ 3
y
2
+
y
3
= 2(3
x
1
+ 7
x
2
) + 3(4
x
1
+ 2
x
2
) + (

x
1

2
x
2
)
= (2
×
3 + 3
×
4 + (

1))
x
1
+ (2
×
7 + 3
×
2 + (

2))
x
2
= 17
x
1
+ 18
x
2
Similarly,
z
2
= 39
x
1
+ 41
x
2
.
z
1
z
2
=
2 3 1
5 7 4
·
3
7
4
2

1

2
·
x
1
x
2
.
3
Algorithms
An
algorithm
is a recipe for solving a problem.
In the book, a particular language is used for describing
algorithms.
•
You need to learn the language well enough to read
the examples
•
You need to learn to express your solution to a prob
lem algorithmically and
unambiguously
•
YOU DO NOT NEED TO LEARN IN DETAIL ALL
THE IDIOSYNCRACIES O± THE PARTICULAR
LANGUAGE USED IN THE BOOK.
◦
You will not be tested on it, nor will most of the
questions in homework use it
◦
I suggest you skim Chapter 1; I won’t cover it
4