Docsity

Matrix Multiplication and LU Factorization, Study notes of Mathematics

Toggle sidebar
bg1
1
IB Paper 7: Linear Algebra Handout 2
2.6 The Column Picture for Matrix Multiplication, revisited
We saw in Handout 1 that when we multiply a matrix and a vector, we get
A x =
11 12 1
21 22 2
1 2
...
...
... ... ... ...
...
n
n
m m mn
a a a
a a a
a a a
1
2
n
x
x
x
= 1 2
...
...
n
a a a
↑ ↑ ↑
↓ ↓ ↓
1
2
n
x
x
x
= 1 1 2 2 3 3 ...
n n
x a x a x a x a
+ + + +
In this section we will show that something similar happens when we multiply two matrices
together.
Consider the simplest case of the product of two simple matrices
a b e f ae bg af bh ae af bg bh
c d g h ce dg cf gh ce cf dg dh
+ +
= = = = +
+ +
A BC
a
b
e f g h
cd
= +
A
This pattern generalises
11 12 13 11 12 13
21 22 23 21 22 23
31 32 33 31 32 33
b b b c c c
b b b c c c
b b b c c c
= =
A BC
11 11 12 21 13 31 11 12 12 22 13 32 11 13 12 23 13 33
21 11 22 21 23 31 21 12 22 22 23 32 21 13 22 23 23 33
31 11 32 21 33 31 31 12 32 22 33 32 31 13 32 23 33 33
b c b c b c b c b c b c b c b c b c
b c b c b c b c b c b c b c b c b c
b c b c b c b c b c b c b c b c b c
+ + + + + +
= + + + + + +
+ + + + + +
Splitting into 3 matrices
11 11 11 12 11 13 12 21 12 22 12 23 13 31 13 32 13 33
21 11 21 12 21 13 22 21 22 22 22 33 23 31 23 32 23 33
31 11 31 12 31 13 32 21 32 22 32 23 33 31 33 32 33 33
b c b c b c b c b c b c b c b c b c
b c b c b c b c b c b c b c b c b c
b c b c b c b c b c b c b c b c b c
= + +
Now, these matrices can be recognised as
[
]
[
]
[
]
11 11 12 13 12 21 22 23 13 31 32 33
21 22 23
31 32 33
b c c c b c c c b c c c
b b b
b b b
= + +
A
1
st
terms in each sum
2
nd
terms in each sum
3
rd
terms in each sum
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Matrix Multiplication and LU Factorization and more Study notes Mathematics in PDF only on Docsity!

IB Paper 7: Linear Algebra Handout 2

2.6 The Column Picture for Matrix Multiplication, revisited

We saw in Handout 1 that when we multiply a matrix and a vector , we get

A x =

11 12 1

21 22 2

1 2

n

n

m m mn

a a a

a a a

a a a

1

2

n

x

x

x

1 2

n

a a a

1

2

n

x

x

x

1 1 2 2 3 3

n n

x a + x a + x a + + x a

In this section we will show that something similar happens when we multiply two matrices

together.

Consider the simplest case of the product of two simple matrices

a b e f ae bg af bh ae af bg bh

c d g h ce dg cf gh ce cf dg dh

A BC

a e f b g h

c d

A

This pattern generalises

11 12 13 11 12 13

21 22 23 21 22 23

31 32 33 31 32 33

b b b c c c

b b b c c c

b b b c c c

A BC

11 11 12 21 13 31 11 12 12 22 13 32 11 13 12 23 13 33

21 11 22 21 23 31 21 12 22 22 23 32 21 13 22 23 23 33

31 11 32 21 33 31 31 12 32 22 33 32 31 13 32 23 33 33

b c b c b c b c b c b c b c b c b c

b c b c b c b c b c b c b c b c b c

b c b c b c b c b c b c b c b c b c

Splitting into 3 matrices

11 11 11 12 11 13 12 21 12 22 12 23 13 31 13 32 13 33

21 11 21 12 21 13 22 21 22 22 22 33 23 31 23 32 23 33

31 11 31 12 31 13 32 21 32 22 32 23 33 31 33 32 33 33

b c b c b c b c b c b c b c b c b c

b c b c b c b c b c b c b c b c b c

b c b c b c b c b c b c b c b c b c

Now, these matrices can be recognised as

[ ] [ ] [ ]

11 11 12 13 12 21 22 23 13 31 32 33

21 22 23

31 32 33

b c c c b c c c b c c c

b b b

b b b

A

st

terms in each sum 2

nd

terms in each sum 3

rd

terms in each sum

If we denote the columns of B as b 1

, b 2

, etc. and the rows of C as

1

c

2

c

, etc. then this can be

written more succinctly as

T T T

1 1 2 2 3 3

A = b c  + b c  + b c 

A product of vectors x y

T

is referred to as an outer product of x and y. (the dot product x

T

y = x. y is

also called an inner product ). So that

A = BC = sum of the outer products of each of the columns of B

with the corresponding row of C.

This is not the only consequence of viewing the product like this. If we denote the columns of A as

a 1

, a

2

, etc.

[ ] [ ] [ ]

11 12 13 21 22 23 31 32 33

1 2 3 1 2 3

c c c c c c c c c

a a a b b b

is equivalent to

[ ] [ ] [ ]

11 21 31

1 1 2 3

c c c

a b b b

[ ] [ ] [ ]

12 22 32

2 1 2 3

c c c

a b b b

and

[ ] [ ] [ ]

13 23 33

3 1 2 3

c c c

a b b b

Now, there is nothing special about 3 × 3 matrices. For the general case of

A = B C

where A is an m × n matrix, B is an m × k matrix, C is an k × n matrix,

[ ] [ ]

[ ]

11 12 1 21 22 2

1 2 1 2

1 2

n n

n

k k kn

k

c c c c c c

a a a b b

c c c

b

(b) Find the matrix which subtracts 1 × first column and 2 × second column from the 3rd, while

leaving the first and second columns alone.

In terms of column vectors

1 1

a = b

2 2

b = a

3 3 1 2

a = b − b − 2 b

1 2 3

a a a

[ ] [ ] [ ]

1 2 3

b b b

2 1 3

b b b

1 0 1

0 1 2

0 0 1

−

−

2.7 The Row Picture for Matrix Multiplication

It is usually true for matrices that, if there is a property that applies to columns, then there is a

corresponding one that applies to rows. Returning to (2.1) & (2.2) for the general case

A = B C

where A is an m × n matrix, B is an m × k matrix, C is an k × n matrix, we see that

T T T T

1 1 2 2 3 3 k k

A = b c + b c + b c + ... + b c

can also be interpreted as

11 12 1 1 1 2

21 22 2 2

1 2

k

k

k

m m mk m

a b b b c c c

a b b b

a b b b

i.e.

[ ] [ ] [ ]

11 12 1 1 1 2

k k

← a →  = b ← c →  + b ← c → + + b  ← c →

[ ] [ ] [ ]

21 22 2 2 1 2

k k

← a →  = b ← c →  + b ← c → + + b ← c →

[ ] [ ] [ ]

1 2 1 2

m m mk m k

← a →  = b  ← c →  + b ← c → + + b ← c →

where the notation

1

c

has been used to indicate that we are talking about vectors which represent

the rows , rather than the columns. The general form for the i ’th row is

[ ] [ ] [ ]

i i 1 1 i 2 2 ik k

← a →  = b  ← c →  + b ← c → + + b  ← c →

So, for example,

[ ] [ ]

is equivalent to

[ ]

and

[ ]

Examples

(a) Find the matrix which subtracts 1 × first row and 2 × second row from the 3rd, while leaving

the first and second rows alone.

In terms of row vectors

1 1

a = c

2 2

a = c

3 3 1 2

a = c − c − 2 c

1

2

3

a

a

a

1

2

3

c

c

c

(b) Find the matrix which cyclically permutes the rows of a 4 × 4 matrix (i.e. 1 → 2, 2 → 3, 3 → 4,

2 1

a  = c 

3 2

a  = c 

4 3

a  = c 

1 4

a  = c 

1

2

3

4

a

a

a

a

1

2

3

4

c

c

c

c

But hang on a minute

Because addition of matrices can be done in any order, the relationship

T T T T T T

1 1 2 2 3 3 3 3 1 1 2 2

A = b c + b c + b c = b c + b c + b c

appears to suggest that we can re-arrange the columns of B provided we apply the same re-

arrangement to the rows of C. This is in fact true. If the permutation matrix to rearrange the

columns of B is P (as a post -multiplier), then the permutation matrix for the rows of C is P

T

(as a

pre -multiplier).

T T T

A = BC = BP P C = B PP C and PP = I

Can also divide a column of B by a scalar and multiply corresponding row of C by same scalar.

0 1 3 0 0 1

0 0 0 0 0 0 0 0 0 0 0

0 1 3 1 0 1 3 0 0 0 0

0 1 4 1 0 1 3 1 0 0 1

T T

2 2 3 3

Rest l u + rest = l u

and, in general, repeat. In this case we can, however, spot l 3

and

3

u

immediately.

Note that, after each stage of the process, "rest" has one more zero row and one more zero column.

Gathering results

1 2 1 2 0 0 1 2 0 0 0 1

3 1 0

2 1 1

− −

A

1 0 0

3 1 0

2 1 1

2 1 2

0 1 3

0 0 1

−

= L U

3.2 A Second Example

This time I have already inserted the numbers which are determined by the chosen 1's and

0's in L and U.

1 2 0

1 2 0

1 3 1 1 2 0

0 0 0 1

0

1 5 3 3 0

0 6

− − −

T

1 1

A l u + rest

0 0 0

0 0 0 0 0 0 0 0

1 0 0 0 0 0

0 1 0 0

1 3 2

1 3

1 1 3 2

A =

1 0 0

1 1 0

3 1 1

−

1 2 0

0 1 3

0 0 2

3.3 Non-square matrices

A =

No Problem.

1 2 1 3

1 2 1 3

2 1 6 2 2 4 2 6

4 3 11 1 1

0 0 0 0 1

0

2 1 3

0

− − − − −

0 2 1 6 0 0 1

0 0 0 0 0 0 0 0 0 0

1

1

2 1 6

2 4 2 12

0 0 0 0 0 0

0 1 0 0 1 1

−

−

 A =

1 0 0

2 1 0

1 2 1

−

1 2 1 3

2 1 6

0 0 1 1

0

−

3.4 A first look at the solution of A x = b

Consider the equations

2 x + y − 2 z = 1

6 x + 4 y − 3 z = 5

4 x + 3 y = 5

We have already performed LU decomposition on A and we shall see how the simple forms for L

and U pay off when we try to solve these equations.

A

b

Key Points from Lecture 2

  • A = B C ( A m × n B m × k C k × n )

is equivalent to

T T T T

1 1 2 2 3 3 k k

A = b c + b c + b c + ... + b c

which is a sum of outer products.

  • This is a relationship between the columns of A and the columns of B with the elements of

C as the coefficients.

1 2

1 2

j j kj

j k

c c c

a b b b

  • In addition, it also represents a relationship between the rows of A and the rows of C with

the elements of B representing the coefficients.

[ ] [ ] [ ]

1 2 1 2

i i ik i k

← a →  = b ← c → + b ← c → + + b  ← c →    

LU Factorisation

L U
A =

L is always a square matrix, while U always has the same shape as A.

Solution of A x = b

Recast this as (i) find c from L c = b

and then (ii)find x from U x = c.