- 152 Views
- Uploaded on
- Presentation posted in: General

Matrices

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Matrices

Section 2.6

Monday, 2 June

MATRICES

- Introduction
- Matrix Arithmetic:
- Sum, Product

- Transposes and Powers of Matrices
- Identity matrix, Transpose, Symmetric matrices

- Zero-one Matrices:
- Join, Meet, Boolean product

2

MATRICES

Definition: If m and n are positive integers, an m×n matrix consists of (mn) elements, arranged in m rows and n columns.

element in ith row, jth column

m rows

n columns

Also written as A=aij

When m = n, Ais called asquare matrix.

3

MATRICES

- Definition: Let Aand B be two matrices. Then A= B if A and B have the same number of rows and the same number of columns, and every element at each position in A equals the element at corresponding position in B.

* Showing equality is not trivial if elements are real numbers subject to digital approximation.

4

MATRICES

Let A = aij, B = bij be mn matrices. Then:

A + B = aij + bij, and A–B= aij–bij

5

MATRICES

- Makealot, Inc. manufactures widgets, nerfs, smores, and flots.
- It supplies three different warehouses (#1,#2,#3).

Opening inventory:

Sales:

Closing inventory:

wi ne sm fl

#1

–

=

#2

#3

MATRICES

>> A = [ 1, -1; 3, 4; 2, 0 ]

A =

1 -1

3 4

2 0

>> B = [ 3, 4; 1, -4; 2, 3]

B =

3 4

1 -4

2 3

>> A+B

ans =

4 3

4 0

4 3

>> A-B

ans =

-2 -5

2 8

0 -3

Octave is a free version from Source Forge

MATRICES

Let A be an mk matrix, and B be a kn matrix. Then their product is: AB=[cij], where

8

MATRICES

Let A be an mk matrix, and B be a kn matrix. Then their product is: AB=[cij], where

9

MATRICES

+

+

=

a

b

a

b

a

b

c

21

12

22

22

23

32

22

Let A be an mk matrix, and B be a kn matrix. Then their product is: AB=[cij]

10

MATRICES

>> A

A =

1 -1

3 4

2 0

>>C =

3 1 2

4 -4 3

>> A*C

ans =

-1 5 -1

25 -13 18

6 2 4

% to get ans row 2, col 3,

% dot product A row 2 by

% C col 3

>> [ 3, 4] * [2; 3]

ans =

18

>> dot ( [3,4], [2, 3])

ans =

18

Note the semicolon to produce a 2 x1 column vector or matrix

MATRICES

- Given an n×mmatrix A and an r×smatrix B:
- The product AB is defined only if m = r .
- When defined, AB is an n×smatrix.

23

34

24

12

MATRICES

- Construct:F: food×nutrient matrixC: day× units-consumed matrix
- Using F and C, calculate:W: day×nutrient matrix
- What do the following represent?
- W(1,1)?
- W(1,2)?
- W(2, 3)?

MATRICES

F:

C:

W:

=

=

W(1,1): 355 Fat Cal’s on Sat; W(1,2): 220 Prot Cal’s on Sat;W(1,3): 1250 Sodium on Sat; W(2,1): 330 Fat Cal’s on Sun; etc.

MATRICES

>> Food = [25, 30, 100;

50, 10, 250;

40, 20, 150;

40, 15, 100 ]

Food =

25 30 100

50 10 250

40 20 150

40 15 100

>> Consumption = [3 0 5 2; 5, 1, 0, 4]

Consumption =

3 0 5 2

5 1 0 4

>> Consumption * Food

ans =

355 220 1250

335 220 1150

MATRICES

- Prove or disprove: If A and B are matrices, and AB is defined, then BA is also defined.
- This is false. Consider, e.g,:

- Prove or disprove: If A and B are matrices and if AB and BA are both defined, then AB = BA.
- This is false. Consider, e.g.,

- Matrix multiplication is not commutative

Under what circumstances are ABand BA both defined?

16

MATRICES

- Let A, B and C be matrices. Prove or disprove: If the product (AB)C is defined, then so is the product A(BC).
- This is true. To see why, assume that A is m ×n. Then, since AB is defined, there is some positive integer ksuch that B is n ×k and AB is m×k. As (AB)C is defined and AB is m×k, there is some positive integer l such that C is k ×l.These conclusions imply that BC is defined and is n ×l, which in turn implies that A(BC) is defined (and is m ×l).

MATRICES

- Let A, B and C be matrices. If (AB)C defined, then (AB)C = A(BC).
- Assume A is m ×n, B is n ×k and C is k ×l. The result follows from:

ipth element of AB

qjth element of BC

ijth element of (AB)C

ijth element of A(BC)

MATRICES

23

34

a11b12+ a12b22+ a13b32= c12

It takes 3 multiplications (and 2 additions) to calculate each element.

There are 24=8 elements to calculate.

So 243 multiplications are needed.

In general to multiply an (mk) matrix and a (kn) matrix requires m·k·n multiplications.

19

MATRICES

Consider the product of the following matrices. Should we do (AB)C or A(BC)?

(A B) C

20 ∙ 40 ∙10 = 8000 operations

32000

20 ∙ 30 ∙40 = 24000 operations

A (B C)

30 ∙ 40 ∙10 = 12000 operations

18000

20 ∙ 30 ∙10 = 6000 operations

So, A(BC) is bestin this case.

20

MATRICES

The identity matrix is a square matrix with all 1’s along

the diagonal and 0’s elsewhere.

We write In to denote the n ×nidentity matrix.

Given an mn matrix A, we have A =Im A = A In

21

MATRICES

The identity matrix is a square matrix with all 1’s along

the diagonal and 0’s elsewhere.

We write In to denote the n ×nidentity matrix.

Given an mn matrix A, we have A =Im A = A In

22

MATRICES

- Let A and B be nn matrices.
- If AB=BA=Inthen B is called the inverse of A, denoted B=A-1.
- Not all square matrices are invertible.

Thus:

23

MATRICES

- Represent a system of linear equalities as a matrix equation:

- There is a unique solution if the coefficient matrix is invertible:

MATRICES

- Given an n ×m matrix A = (aij), the transpose of A, written At, is the m ×n matrix that has element aij in row j and column i, for 1 ≤ i ≤ m and 1 ≤ j ≤ n.

Flip across diagonal

MATRICES

A square matrix A is said to be symmetric if A = At.

Non-symmetric:

Symmetric:

26

MATRICES

Are the following matrices symmetric?

- The 100 × 100 matrix M = [mij] satisfying mij= gcd(i,j)
- The 100 × 100 matrix S = [sij] satisfying sij= i−j
- I2000

MATRICES

- Let A be ann ×n matrix. Thepowers of A are defined recursively:0th power of A: A0 = Inkth power of A: Ak = A∙Ak −1, for k > 0

. . .

28

MATRICES

- Let A be ann ×n matrix. Thepowers of A are defined recursively:0th power of A: A0 = Inkth power of A: Ak = A∙Ak −1, for k > 0

k

Ak= AA ∙∙∙ A

29

MATRICES

Calculate

MATRICES

Calculate

MATRICES

- All entries are 0 or 1.
- Operations are Boolean operations: Let A = [aij] and B = [bij] be m ×n zero-one matrices. Then:
- The join of A and B, written A B, is the m ×n zero-one matrix [aijbij].
- The meet of A and B, written A ∧B, is the m ×n zero-one matrix [aij∧bij].

32

MATRICES

Delta connection matrix:

Delta operates direct flights: From: To: From: To DTW JFK JFK DTW JFK MIA MIA JFK MIA LAX LAX MIA

Airtran operates direct flights: From: To: From: To: FNT DTW DTW CLE CLE TOL TOL JFK DTW JFK DTW MIA

Order the airport codes: 1:CLE, 2:DTW, 3:FNT, 4:JFK, 5:LAX, 6:MIA, 7: TOL

C D F J L M T

D =

C D F J L M T

MATRICES

Delta operates direct flights: From: To: From: To DTW JFK JFK DTW JFK MIA MIA JFK MIA LAX LAX MIA

Airtran operates direct flights: From: To: From: To: FNT DTW DTW CLE CLE TOL TOL JFK DTW JFK DTW MIA

Order the airport codes: 1:CLE, 2:DTW, 3:FNT, 4:JFK, 5:LAX, 6:MIA, 7: TOL

Airtran connections:

C D F J L M T

A =

C D F J L M T

MATRICES

C D F J L M T

C D F J L M T

D =

A =

C D F J L M T

C D F J L M T

What operation on A and D produces the matrix showing the airports connected by a Delta flight or an Airtran flight?

What operation on A and D produces the matrix showing the airports connected by both a Delta flight and an Airtranflight? (You have a choice of airlines.)

MATRICES

Airports connected by a Delta flight or an Airtran flight:

D A =

=

MATRICES

Airports connected by both a Delta flight and an Airtran flight:

D A =

=

MATRICES

>> or(Delta, Airtran)

ans =

0 0 0 0 0 0 1

1 0 0 1 0 1 0

0 1 0 0 0 0 0

0 1 0 0 0 1 0

0 0 0 0 0 1 0

0 0 0 1 1 0 0

0 0 0 1 0 0 0

>> and(Delta, Airtran)

ans =

0 0 0 0 0 0 0

0 0 0 1 0 0 0

0 0 0 0 0 0 0

0 0 0 0 0 0 0

0 0 0 0 0 0 0

0 0 0 0 0 0 0

0 0 0 0 0 0 0

>> Delta = [ 0 0 0 0 0 0 0;

0 0 0 1 0 0 0;

0 0 0 0 0 0 0;

0 1 0 0 0 1 0;

0 0 0 0 0 1 0;

0 0 0 1 1 0 0;

0 0 0 0 0 0 0 ];

>> Airtran = [ 0 0 0 0 0 0 1;

1 0 0 1 0 1 0;

0 1 0 0 0 0 0;

0 0 0 0 0 0 0;

0 0 0 0 0 0 0;

0 0 0 0 0 0 0;

0 0 0 1 0 0 0 ];

MATRICES

AB

Domination law says you

can stop when you find

a ‘1’

AB

39

MATRICES

AB BA

In general, A⊙B B⊙A

Example:

BA

AB

40

MATRICES

- A Boolean power matrix can be defined in exactly the same way as a power matrix. For a nn square matrix A, the power matrix:
A[0] = In and

A[r] = AA[r −1] for r > 0

AA . . . A

41

MATRICES

Airports connected via taking a Delta flight and then an Airtran flight.

DA =

=

C D F J L M T

C D F J L M T

C D F J L M T

MATRICES

Airports connected via taking a Delta flight and then an Airtran flight.

DA =

=

C D F J L M T

C D F J L M T

C D F J L M T

MATRICES

Airports connected via taking a Delta flight and then an Airtran flight.

DA =

=

C D F J L M T

C D F J L M T

C D F J L M T

MATRICES

Calculate the airports connected via taking an Airtran flight and then a Delta flight:

AD =

=

C D F J L M T

MATRICES

Flight connections

Airports connected via any number of Delta or Airtran flights (including no flights).

I (DA) (DA)[2] (DA)[3] (DA)[4] …

From CLE: get to all but FNT. . .From FNT: get to all. . .

To JFK: from any of the airports

. . .

To FNT: only from FNT

C D F J L M T

MATRICES