49
Lesson 5 Matrix Algebra and The Transpose Math 20 September 28, 2007 Announcements I Thomas Schelling at IOP (79 JFK Street), Wednesday 6pm I Problem Set 2 is on the course web site. Due October 3 I Problem Sessions: Sundays 6–7 (SC 221), Tuesdays 1–2 (SC 116) I My office hours: Mondays 1–2, Tuesdays 3–4, Wednesdays 1–3 (SC 323)

Lesson 5: Matrix Algebra (slides)

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Lesson 5: Matrix Algebra (slides)

Lesson 5Matrix Algebra and The Transpose

Math 20

September 28, 2007

Announcements

I Thomas Schelling at IOP (79 JFK Street), Wednesday 6pm

I Problem Set 2 is on the course web site. Due October 3

I Problem Sessions: Sundays 6–7 (SC 221), Tuesdays 1–2 (SC116)

I My office hours: Mondays 1–2, Tuesdays 3–4, Wednesdays1–3 (SC 323)

Page 2: Lesson 5: Matrix Algebra (slides)

Remember the definition of matrix addition

DefinitionLet A = (aij)m×n and B = (bij)m×n be matrices. The sum of Aand B is the matrix C = (cij)m×n defined by

cij = aij + bij

That is, C is obtained by adding corresponding elements of A AndB.

We do not define A + B if A and B do not have the samedimension.

Page 3: Lesson 5: Matrix Algebra (slides)

Remember the definition of matrix addition

DefinitionLet A = (aij)m×n and B = (bij)m×n be matrices. The sum of Aand B is the matrix C = (cij)m×n defined by

cij = aij + bij

That is, C is obtained by adding corresponding elements of A AndB.We do not define A + B if A and B do not have the samedimension.

Page 4: Lesson 5: Matrix Algebra (slides)

Properties of Matrix Addition

RulesLet A, B, C, and D be m × n matrices.

(a) A + B = B + A

(so addition is commutative)

(b) A + (B + C) = (A + B) + C (so addition is associative)

(c) There is a unique m × n matrix O such that

A + O = A

for any m × n matrix A. The matrix O is called the m × nadditive identity matrix.

(d) For each m × n matrix A, there is a unique m × n matrix Dsuch that

A + D = O

(We write D = −A.) So additive inverses exist.

Page 5: Lesson 5: Matrix Algebra (slides)

Properties of Matrix Addition

RulesLet A, B, C, and D be m × n matrices.

(a) A + B = B + A (so addition is commutative)

(b) A + (B + C) = (A + B) + C (so addition is associative)

(c) There is a unique m × n matrix O such that

A + O = A

for any m × n matrix A. The matrix O is called the m × nadditive identity matrix.

(d) For each m × n matrix A, there is a unique m × n matrix Dsuch that

A + D = O

(We write D = −A.) So additive inverses exist.

Page 6: Lesson 5: Matrix Algebra (slides)

Properties of Matrix Addition

RulesLet A, B, C, and D be m × n matrices.

(a) A + B = B + A (so addition is commutative)

(b) A + (B + C) = (A + B) + C

(so addition is associative)

(c) There is a unique m × n matrix O such that

A + O = A

for any m × n matrix A. The matrix O is called the m × nadditive identity matrix.

(d) For each m × n matrix A, there is a unique m × n matrix Dsuch that

A + D = O

(We write D = −A.) So additive inverses exist.

Page 7: Lesson 5: Matrix Algebra (slides)

Properties of Matrix Addition

RulesLet A, B, C, and D be m × n matrices.

(a) A + B = B + A (so addition is commutative)

(b) A + (B + C) = (A + B) + C (so addition is associative)

(c) There is a unique m × n matrix O such that

A + O = A

for any m × n matrix A. The matrix O is called the m × nadditive identity matrix.

(d) For each m × n matrix A, there is a unique m × n matrix Dsuch that

A + D = O

(We write D = −A.) So additive inverses exist.

Page 8: Lesson 5: Matrix Algebra (slides)

Properties of Matrix Addition

RulesLet A, B, C, and D be m × n matrices.

(a) A + B = B + A (so addition is commutative)

(b) A + (B + C) = (A + B) + C (so addition is associative)

(c) There is a unique m × n matrix O such that

A + O = A

for any m × n matrix A. The matrix O is called the m × nadditive identity matrix.

(d) For each m × n matrix A, there is a unique m × n matrix Dsuch that

A + D = O

(We write D = −A.) So additive inverses exist.

Page 9: Lesson 5: Matrix Algebra (slides)

Proof

Proof.Let’s prove (b). We need to show that every entry of A + (B + C)is equal to the corresponding entry of (A + B) + C.

Well,

[A + (B + C)]ij = aij + [B + C]ij = aij + (bij + cij)

= (aij + bij) + cij as real numbers

= [A + B]ij + cij = [(A + B) + C]ij .

Page 10: Lesson 5: Matrix Algebra (slides)

Proof

Proof.Let’s prove (b). We need to show that every entry of A + (B + C)is equal to the corresponding entry of (A + B) + C. Well,

[A + (B + C)]ij = aij + [B + C]ij = aij + (bij + cij)

= (aij + bij) + cij as real numbers

= [A + B]ij + cij = [(A + B) + C]ij .

Page 11: Lesson 5: Matrix Algebra (slides)

Remember the definition of matrix multiplication

DefinitionLet A = (aij)m×n and B = (bij)n×p. Then the matrix product ofA and B is the m × p matrix whose jth column is Abj . In otherwords, the (i , j)th entry of AB is the dot product of ith row of Aand the jth column of B. In symbols

(AB)ij =n∑

k=1

aikbkj .

Another way to look at it:

A(b1 b2 . . . bp

)=(Ab1 Ab2 . . . Abp

)

Page 12: Lesson 5: Matrix Algebra (slides)

Remember the definition of matrix multiplication

DefinitionLet A = (aij)m×n and B = (bij)n×p. Then the matrix product ofA and B is the m × p matrix whose jth column is Abj . In otherwords, the (i , j)th entry of AB is the dot product of ith row of Aand the jth column of B. In symbols

(AB)ij =n∑

k=1

aikbkj .

Another way to look at it:

A(b1 b2 . . . bp

)=(Ab1 Ab2 . . . Abp

)

Page 13: Lesson 5: Matrix Algebra (slides)

Examples

Let

A =

(1 2−1 2

)B =

(0 23 1

)

C =

(1 −1 22 3 −1

)D =

0 1 2 0−1 0 2 03 1 0 0

Compute

(a) (A + B)C

(b) AC + BC

(c) A(BC)

(d) (AB)C

(e) AC and CA

(f) AB and BA

Page 14: Lesson 5: Matrix Algebra (slides)

Does matrix multiplication distribute?

Solution to (a) and (b)

(A + B)C =

(9 11 −28 7 1

)= AC + BC

In fact, this is true in general:

Distributive rules for matricesIf A, B, and C are of appropriate sizes, then

(A + B)C = AC + BC.

If A, B, and C are of appropriate sizes, then

A(B + C) = AB + AC

Page 15: Lesson 5: Matrix Algebra (slides)

Does matrix multiplication distribute?

Solution to (a) and (b)

(A + B)C =

(9 11 −28 7 1

)= AC + BC

In fact, this is true in general:

Distributive rules for matricesIf A, B, and C are of appropriate sizes, then

(A + B)C = AC + BC.

If A, B, and C are of appropriate sizes, then

A(B + C) = AB + AC

Page 16: Lesson 5: Matrix Algebra (slides)

Is matrix multiplication associative?

Solution to (c) and (d)

A(BC) =

(14 6 86 −6 12

)= (AB)C

In fact, this is true in general:

Associative rules for matrix multiplication

If A, B, and C are of appropriate sizes, then

(AB)C = A(BC)

Page 17: Lesson 5: Matrix Algebra (slides)

Is matrix multiplication associative?

Solution to (c) and (d)

A(BC) =

(14 6 86 −6 12

)= (AB)C

In fact, this is true in general:

Associative rules for matrix multiplication

If A, B, and C are of appropriate sizes, then

(AB)C = A(BC)

Page 18: Lesson 5: Matrix Algebra (slides)

Is matrix multiplication commutative?

Solution to (e)

AC =

(5 5 03 7 −4

), but CA is not even defined. We cannot

multiply a 2 × 3 matrix by a 2 × 2 matrix.

Solution to (f)

BA =

(−2 42 8

), but AB =

(6 46 0

).

So matrix multiplication is (usually) not commutative, even whenit’s possible to test.

Page 19: Lesson 5: Matrix Algebra (slides)

Is matrix multiplication commutative?

Solution to (e)

AC =

(5 5 03 7 −4

),

but CA is not even defined. We cannot

multiply a 2 × 3 matrix by a 2 × 2 matrix.

Solution to (f)

BA =

(−2 42 8

), but AB =

(6 46 0

).

So matrix multiplication is (usually) not commutative, even whenit’s possible to test.

Page 20: Lesson 5: Matrix Algebra (slides)

Is matrix multiplication commutative?

Solution to (e)

AC =

(5 5 03 7 −4

), but CA is not even defined. We cannot

multiply a 2 × 3 matrix by a 2 × 2 matrix.

Solution to (f)

BA =

(−2 42 8

), but AB =

(6 46 0

).

So matrix multiplication is (usually) not commutative, even whenit’s possible to test.

Page 21: Lesson 5: Matrix Algebra (slides)

Is matrix multiplication commutative?

Solution to (e)

AC =

(5 5 03 7 −4

), but CA is not even defined. We cannot

multiply a 2 × 3 matrix by a 2 × 2 matrix.

Solution to (f)

BA =

(−2 42 8

), but AB =

(6 46 0

).

So matrix multiplication is (usually) not commutative, even whenit’s possible to test.

Page 22: Lesson 5: Matrix Algebra (slides)

Is matrix multiplication commutative?

Solution to (e)

AC =

(5 5 03 7 −4

), but CA is not even defined. We cannot

multiply a 2 × 3 matrix by a 2 × 2 matrix.

Solution to (f)

BA =

(−2 42 8

),

but AB =

(6 46 0

).

So matrix multiplication is (usually) not commutative, even whenit’s possible to test.

Page 23: Lesson 5: Matrix Algebra (slides)

Is matrix multiplication commutative?

Solution to (e)

AC =

(5 5 03 7 −4

), but CA is not even defined. We cannot

multiply a 2 × 3 matrix by a 2 × 2 matrix.

Solution to (f)

BA =

(−2 42 8

), but AB =

(6 46 0

).

So matrix multiplication is (usually) not commutative, even whenit’s possible to test.

Page 24: Lesson 5: Matrix Algebra (slides)

Is matrix multiplication commutative?

Solution to (e)

AC =

(5 5 03 7 −4

), but CA is not even defined. We cannot

multiply a 2 × 3 matrix by a 2 × 2 matrix.

Solution to (f)

BA =

(−2 42 8

), but AB =

(6 46 0

).

So matrix multiplication is (usually) not commutative, even whenit’s possible to test.

Page 25: Lesson 5: Matrix Algebra (slides)

Is matrix multiplication commutative?

Solution to (e)

AC =

(5 5 03 7 −4

), but CA is not even defined. We cannot

multiply a 2 × 3 matrix by a 2 × 2 matrix.

Solution to (f)

BA =

(−2 42 8

), but AB =

(6 46 0

).

So matrix multiplication is (usually) not commutative, even whenit’s possible to test.

Page 26: Lesson 5: Matrix Algebra (slides)

The Transpose

But there is another operation on matrices, which is just flippingrows and columns.

DefinitionLet A = (aij)m×n be a matrix. The transpose of A is the matrixA′ = (aij)n×m whose (i , j)th entry is aji .

Example

Let A =

1 23 45 6

. Then

A′ =

(1 3 52 4 6

).

Page 27: Lesson 5: Matrix Algebra (slides)

The Transpose

But there is another operation on matrices, which is just flippingrows and columns.

DefinitionLet A = (aij)m×n be a matrix. The transpose of A is the matrixA′ = (aij)n×m whose (i , j)th entry is aji .

Example

Let A =

1 23 45 6

. Then

A′ =

(1 3 52 4 6

).

Page 28: Lesson 5: Matrix Algebra (slides)

The Transpose

But there is another operation on matrices, which is just flippingrows and columns.

DefinitionLet A = (aij)m×n be a matrix. The transpose of A is the matrixA′ = (aij)n×m whose (i , j)th entry is aji .

Example

Let A =

1 23 45 6

. Then

A′ =

(1 3 52 4 6

).

Page 29: Lesson 5: Matrix Algebra (slides)

Examples

Let

A =

(1 2−1 2

)B =

(0 23 1

)

C =

(1 −1 22 3 −1

)D =

0 1 2 0−1 0 2 03 1 0 0

Compute

(a) (A′)′

(b) (A + B)′ and A′ + B′(c) (AC)′ and A′C′

(d) (AC)′ and C′A′

Page 30: Lesson 5: Matrix Algebra (slides)

Solution to (a).

(A′)′ =

A

In fact, this is true in general.

Page 31: Lesson 5: Matrix Algebra (slides)

Solution to (a).

(A′)′ = A

In fact, this is true in general.

Page 32: Lesson 5: Matrix Algebra (slides)

Solution to (a).

(A′)′ = A

In fact, this is true in general.

Page 33: Lesson 5: Matrix Algebra (slides)

Does the transpose distribute over addition?

Solution to (b).

(A + B)′ =

(1 24 3

)= A′ + B′

In fact, this is true in general.

Page 34: Lesson 5: Matrix Algebra (slides)

Does the transpose distribute over addition?

Solution to (b).

(A + B)′ =

(1 24 3

)= A′ + B′

In fact, this is true in general.

Page 35: Lesson 5: Matrix Algebra (slides)

Does the transpose distribute over multiplication?

Solution to (c) and (d).

(AC)′ =

5 35 70 −4

, but A′C′ is not defined.

On the other hand,

C′A′ =

5 35 70 −4

= (AC)′.

This is true in general.

Page 36: Lesson 5: Matrix Algebra (slides)

Does the transpose distribute over multiplication?

Solution to (c) and (d).

(AC)′ =

5 35 70 −4

, but A′C′ is not defined. On the other hand,

C′A′ =

5 35 70 −4

= (AC)′.

This is true in general.

Page 37: Lesson 5: Matrix Algebra (slides)

Does the transpose distribute over multiplication?

Solution to (c) and (d).

(AC)′ =

5 35 70 −4

, but A′C′ is not defined. On the other hand,

C′A′ =

5 35 70 −4

= (AC)′.

This is true in general.

Page 38: Lesson 5: Matrix Algebra (slides)

Remember these properties (including which ones aren’t true)because they are the rules of the game in linear algebra!

Page 39: Lesson 5: Matrix Algebra (slides)

Transpose and dot product

Notice:p · q = p′q

Also,

TheoremLet A be an n × n matrix and v, w vectors in Rn. Then

v · Aw = (A′v) ·w.

Proof.Remember v ·Aw is a scalar, so is equal to its own transpose. Then

v · Aw = (v′Aw)′ = (Aw)′(v′)′ = w′A′v = w · A′v = (A′v) ·w.

Page 40: Lesson 5: Matrix Algebra (slides)

Transpose and dot product

Notice:p · q = p′q

Also,

TheoremLet A be an n × n matrix and v, w vectors in Rn. Then

v · Aw = (A′v) ·w.

Proof.Remember v ·Aw is a scalar, so is equal to its own transpose. Then

v · Aw = (v′Aw)′ = (Aw)′(v′)′ = w′A′v = w · A′v = (A′v) ·w.

Page 41: Lesson 5: Matrix Algebra (slides)

Transpose and dot product

Notice:p · q = p′q

Also,

TheoremLet A be an n × n matrix and v, w vectors in Rn. Then

v · Aw = (A′v) ·w.

Proof.Remember v ·Aw is a scalar, so is equal to its own transpose.

Then

v · Aw = (v′Aw)′ = (Aw)′(v′)′ = w′A′v = w · A′v = (A′v) ·w.

Page 42: Lesson 5: Matrix Algebra (slides)

Transpose and dot product

Notice:p · q = p′q

Also,

TheoremLet A be an n × n matrix and v, w vectors in Rn. Then

v · Aw = (A′v) ·w.

Proof.Remember v ·Aw is a scalar, so is equal to its own transpose. Then

v · Aw = (v′Aw)′ = (Aw)′(v′)′ = w′A′v = w · A′v = (A′v) ·w.

Page 43: Lesson 5: Matrix Algebra (slides)

Example

Some special cases which are useful. Let

A =

(3 2−1 1

)e1 =

(10

)e2 =

(01

)

E11 =

(1 00 0

)E12 =

(0 10 0

)E21 =

(0 01 0

)E22 =

(0 00 1

)

D =

(2 00 −1

)I =

(1 00 1

)Compute

(a) Ae1 and Ae2

(b) AE11 and E11A

(c) AE12 and E12A

(d) AD and DA

Page 44: Lesson 5: Matrix Algebra (slides)

Solution to (a)

Ae1 =

(3−1

)Ae2 =

(21

)

In general,

I Aei is the ith column of A.

I e′jA is the jth row of A.

Page 45: Lesson 5: Matrix Algebra (slides)

Solution to (a)

Ae1 =

(3−1

)Ae2 =

(21

)In general,

I Aei is the ith column of A.

I e′jA is the jth row of A.

Page 46: Lesson 5: Matrix Algebra (slides)

Solution to (b) and (c)

AE11 =

(3 0−1 0

)E11A =

(3 20 0

)AE12 =

(0 30 −1

)E12A =

(−1 10 0

)

In general,

I AEij has all zeros except for the jth column, which is the ithcolumn of A

I EijA has all zeros except for the ith row, which is the jth rowof A

Page 47: Lesson 5: Matrix Algebra (slides)

Solution to (b) and (c)

AE11 =

(3 0−1 0

)E11A =

(3 20 0

)AE12 =

(0 30 −1

)E12A =

(−1 10 0

)In general,

I AEij has all zeros except for the jth column, which is the ithcolumn of A

I EijA has all zeros except for the ith row, which is the jth rowof A

Page 48: Lesson 5: Matrix Algebra (slides)

Solution to (d)

DA =

(6 41 −1

)AD =

(6 −22 −1

)

In general,

I a diagonal matrix times a matrix scales every row of theright-hand matrix by the corresponding diagonal entries

I a matrix times a diagonal matrix scales every column of theleft-hand matrix by the corresponding diagonal entries.

I diagonal matrices do commute

Page 49: Lesson 5: Matrix Algebra (slides)

Solution to (d)

DA =

(6 41 −1

)AD =

(6 −22 −1

)In general,

I a diagonal matrix times a matrix scales every row of theright-hand matrix by the corresponding diagonal entries

I a matrix times a diagonal matrix scales every column of theleft-hand matrix by the corresponding diagonal entries.

I diagonal matrices do commute