65
Matrices Matrices And And Linear Linear Systems Systems

Matrices And Linear Systems. Matrices – definitions 1 A matrix is a rectangular array of numbers. Examples: Note that we surround the matrix with “brackets”

Embed Size (px)

Citation preview

Matrices Matrices And And

Linear Linear SystemsSystems

Matrices – definitions 1Matrices – definitions 1

A matrix is a rectangular array of numbers.

2 1

4 0.3

Examples:

1 0 1

1 9 0

2 3 4 0 1 5

1 6 3 0 0 1

19 7 2 2 1 8

3 3 5 1 10 0

Note that we surround the matrix with “brackets” (or “braces”)

1 0 1 91

7

6

2

0

Matrices – definitions 2Matrices – definitions 2

Matrices are comprised of rows and columns:

This is a row; the 1st row.2 3 4 0 1 5

1 6 3 0 0 1

19 7 2 2 1 8

3 3 5 1 10 0

This is a column; the 6th column.

This is an element of the matrix (or an “entry” of the matrix).

Matrices – definitions 3Matrices – definitions 3

The order of a matrix is written as (m x n) where m is the number of rows and n is the number of columns. For example:

2 3 4 0 1 5

1 6 3 0 0 1

19 7 2 2 1 8

3 3 5 1 10 0

This matrix has order…

4 x 6

1 0 1

1 9 0

This matrix has order… 2 x 3

(Try a few more)

Matrices – arithmetic 1Matrices – arithmetic 1

The rules for combining matrices are similar but different from those for numbers or vectors. Be careful about that!

1 0 2 1

4 3 7 0

Addition and subtraction

1 0 8 2 1

4 3 6 7 0

3 1 3 -3

Matrices – arithmetic 2Matrices – arithmetic 2

We deduce our first rule about matrices:

a e b f

c g d h

A B

Let a b

c d

A e f

g h

B

These matrices had order 2x2, but the same rule will always work as long as A and B have the same order.

Matrices – arithmetic 3Matrices – arithmetic 3

Notice that adding matrices is just like adding vectors. That’s because vectors are matrices with only one column.

Hopefully you remember that we can multiply a vector by a “scalar” (real number) like this:

1 3

2 3 6

3 9

v v

We can do exactly the same with any matrix of any order (this follows from the rule of addition).

Matrices – arithmetic 4Matrices – arithmetic 4

Just as for vectors, we cannot divide a matrix by another matrix, but we can multiply in certain cases.

To see a detailed example of how this works, please now turn to page 301 of the red book.

A good simple way to remember how to multiply matrices:

“Rows x Columns”

Matrices – arithmetic 5Matrices – arithmetic 5

Matrix multiplication is limited.

We can multiply matrix A of order m x nby matrix B of order p x q if and only if

rows by columns rows by columns

rows by columns

m n n q

m q

Schematically:

For each pair of matrices on the next slide, decide ifyou can multiply them, and then try it!

n p

Matrices – arithmetic 6Matrices – arithmetic 6

1 0 3 2A =

5 1 2

4 3 6

9 8 1

B =

6 3 4

2 5 1

8 6 1

C =

4

4

1

3

D =

2 3

6 7

1 4

1 0

E =

2 3 4

1 0 1

F =

9 4

0 10

3 1

G =

Matrices – arithmetic 7Matrices – arithmetic 7

7AD =

48 22 23

18 39 13

62 19 43

BC =

78 47 10

1 5 33

73 34 21

CB =

39 32

54 40

84 115

BG =

1 9AE =

1 6 11

5 18 31

2 3 8

2 3 4

EF =

66 10

21 57

75 29

CG =

4 0 12 8

4 0 12 8

1 0 3 2

3 0 9 6

DA =

Any more?

Matrices – arithmetic 8Matrices – arithmetic 8

48 22 23

18 39 13

62 19 43

BC =

78 47 10

1 5 33

73 34 21

CB =

From our calculations, you should have noticed something important:

In general we say that given any two matrices A, B, then usually:

AB BA

Matrix multiplication is

NOT commutative

Matrices – arithmetic 9Matrices – arithmetic 9

The fact that multiplication is not commutative means that we must be very careful when saying “AB”; it is not the same as “BA”. However, matrix multiplication is “associative”, which means:

( ) A BC (AB)Cwhenever these multiplications make sense.

Remember: “left multiply” is different from “right multiply” but

the sequence in which several multiplications occur doesn’t

matter

Matrices – arithmetic 10Matrices – arithmetic 10

This concludes the section on Matrix Arithmetic.

If this material was new to you, you have to practice it!

Matrices – transformation 1Matrices – transformation 1

Consider what happens if we left multiply a 2D vector by a 2x2 matrix:

1 1

2 1

x

y

A •Is this multiplication possible?

• Why?•What is the order of A?

Yes; (2x2)x(2x1) gives a resulting matrix whose order is (2x1).

So A is another 2D vector: 2

x y

x y

A

Matrices – transformation 2Matrices – transformation 2

The matrix M: 1 1

2 1

can be thought of as a transformation which sends any vector to a new vectorx

y

X

Y

What are the unit vectors i and j changed to, under the transformation M?

1 1 0 1 ,

0 2 1 1

We can say that the image of i and j under the transformation M are the vectors given by the columns of M.

Matrices – transformation 3Matrices – transformation 3

It’s very important to understand it visually:

x

y

i

j

1

2

1

1

These are just two vectors;what about others?

Matrices – transformation 4Matrices – transformation 4

Think about how regions are transformed, e.g. the unit square:

x

y

i

j

Now we can see what the transformation is doing! Can you describe it in English?

Answer: •rotation (counterclockwise)•stretch (or “enlarge”)•shear (no reflection)

Matrices – transformation 5Matrices – transformation 5

Basic ideas to remember:

•A matrix M of order (n x n) can be thought of as a transformation of n-dimensional space•Applying the transformation to an n-dimensional vector means left multiplying that vector by M•To find the geometrical effect of M we can apply it to each unit vector (i, j, (k), ..)

Exercise: Describe the effect of the transformation on a cube of unit volume.0.5 0 0

0.5 1 0

0.5 0 4

Matrices – transformation 5Matrices – transformation 5

Answer:

1 0.5 0 0 0 0

0 0.5 , 1 1 , 0 0

0 0.5 0 0 1 4

In words:• i is transformed to 0.5i + 0.5j + 0.5k• j is transformed to itself (unchanged)• k is stretched by a factor of 4

Visually, a cube changes to a parallelepiped

through a combination of stretch, shear and rotate.

Matrices – transformation 6Matrices – transformation 6

Consider again our original 2-D transformation matrix M:

1 1

2 1

x

y

Mx We have seen that M maps the unit square, with (i,j) as sides, to a parallelogram. What is the area of that parallelogram?

After some investigation, you should see that for any matrix a b

c d

the area will be ad bc

(To think about: why isn’t matrix multiplication commutative?)

Matrices – Scalar and vector productMatrices – Scalar and vector product

Practice your understanding. What is:

Please refer to the handout for a summary of scalar (dot)and vector (cross) product

i i

j j

k k

i j

j i

k i

j k

0

0

0

k

= -k

= -j

= i

The vector product is distributive and associative, but not commutative:

a b b a

Matrices – Scalar and vector product 2Matrices – Scalar and vector product 2

Let’s recall the transformation of areas:

x

y

i

j

The area of the blue square is

1 i j

The area of the red parallelogram is

sina b a b

ad bcc d c d

a

c

b

d

Matrices – Scalar and vector product 3Matrices – Scalar and vector product 3

A summary so far:

For a 2D transformation given by a matrix :

•In general, M can stretch, shear, rotate and reflect any given line or shape•You can understand what M does by recognizing that it maps i to and j to

•M always maps parallelograms to parallelograms, and the area is changed by a factor

•(The sign of ad-bc indicates reflection or not)

a b

c d

M =

a

c

b

d

ad bc

Matrices – Determinants 1Matrices – Determinants 1

What does it mean visually if ?

It means:1. The 2 vectors which i and j are mapped to

are in the same line2. The area of the parallelogram in the “image”

is zero

0ad bc

Definition: The DETERMINANT of a 2x2 matrix is and it represents a

scale factor for area. Its sign indicates whether there is a reflection.

a b

c d

M = ad bc

Matrices – Determinants 2Matrices – Determinants 2

Determinants in 3 dimensions.

A transformation in 3D such as maps the unit cube to a parallelepiped:

as already discussed. How can we find the volume of the parallelepiped?

1 2 3

1 2 3

1 2 3

a a a

b b b

c c c

A

The area of the base is |b x c|

Matrices – Determinants 3Matrices – Determinants 3

You should have found that the correct formula for the volume is:a b c

This is not ambiguous (we don’t need brackets). Why?

By symmetry (a, b, c are not special), we can also write: or b a ×c b c×aThe term is called the “scalar triple product” of the three vectors a, b, c.

a b c

It is also the DETERMINANT of the matrix A.

Matrices – Determinants 4Matrices – Determinants 4

Let’s examine how we can calculate the determinant of A.

1 2 3

1 2 3

1 2 3

a a a

b b b

c c c

A

Consider the 3 rows as vectors:

1 2 3a a a i j k a

1 2 3b b b i j k b

1 2 3c c c i j k c

Then

What do you notice about these three terms?

1 2 3 1 2 3

2 3 3 2 1 3 1 3 1 2 1 2( ) ( )

b b b c c c

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

b c i j k i j k

i j k

Matrices – Determinants 5Matrices – Determinants 5

Answer: they are all determinants of 2x2 matrices:

1 2 3

1 2 3

1 2 3

a a a

b b b

c c c

1 2 3

1 2 3

1 2 3

a a a

b b b

c c c

1 2 3

1 2 3

1 2 3

a a a

b b b

c c c

Hopefully you can now see that the determinant of A, which is the scalar triple product a.bxc, is the sum of the products of each component of a with the determinant of the 2x2 matrix it doesn’t intersect:

2 3 1 3 1 21 2 3

2 3 1 3 1 2

det( )b b b b b b

a a ac c c c c c

A

Matrices – Special matricesMatrices – Special matrices

Before we delve further into the wonderful world of determinants, it will be useful to know a few special kinds of matrix:

Square matrix -

Transpose -

Any matrix with the same number of rows as columns

TA , the transpose of A, is the matrix formed by swapping the rows and columns of A

Example:3 1

3 1 41 0

1 0 74 7

TA A

Matrices – Special matrices 2Matrices – Special matrices 2

Diagonal matrix -

A square matrix all of whose entries are zero except those on the main diagonal.

Using subscript notation, we would say that:

is diagonal 0iji j a A

Examples (all of these matrices are diagonal):

1 0 0

0 2 0

0 0 3

3 0 0 0

0 3 0 0

0 0 0 0

0 0 0 1

0 0

0 0

2

(usually we would not consider a non-square matrix as diagonal).

Matrices – Special matrices 3Matrices – Special matrices 3

Identity matrix -

A diagonal matrix all of whose entriesare 1.

The identity matrix is always written as

As you can see, for each number n there is a correspondingidentity matrix:

1 0 0

0 1 0

0 0 1

1 0 0 0

0 1 0 0

0 0 1 0

0 0 0 1

1 0

0 1

1 ...

or nI I

Matrices – Special matrices 4Matrices – Special matrices 4

Null matrix - consists of all zeros.

Discuss:

1. If , what does that tell you about A?2. Let’s right-multiply a matrix M of order

(2x3) by an identity matrix. (a) What is the order of the identity matrix? (b) What is the product MI?

3. What is the result if we multiply I by I?4. Is diagonal matrix multiplication

commutative?5. Prove that 6. Do the operations “matrix multiplication”

and “matrix transpose” commute?

T TAA A A

TA A

Matrices – Determinants 6Matrices – Determinants 6

Find the determinants of these 2x2 and 3x3 matrices:

1 0

0 1

A1 0 0

0 4 0

0 0 3

B

6 3 4

2 5 1

8 6 1

C =

What patterns/rules do you notice?What makes it easy/difficult?

6 3 4

2 5 1

0 0 0

D = Answers:det(A) = 1det(B) = -12det(C) = 160det(D) = 0

Matrices – Determinants 7Matrices – Determinants 7

Remembering the principle that a 3x3 determinant represents a scale factor for volume, answer these conceptual questions without calculating: 1. What is det(I)? (I=identity) Explain

geometrically2. What is det(AB), if det(A)=2 and

det(B)=7? Explain visually.

Don’t forget the pattern of the signs when calculating

determinants:

+ - + - ..

- + - .. ..

+ - .. .. ..

- + .. .. ..

.. .. .. .. ..

Matrices – Determinants 8Matrices – Determinants 8

A few more example questions:

3. What does it mean if det(A)=0?4. Let A be the following matrix:

1 2 3

1 2 3

1 2 3

a a a

b b b

c c c

A

Suppose det(A) = kWhat are the det(B) and det(C), where B and C are the following: 1 2 3

1 2 3

1 2 3

8 8 8a a a

b b b

c c c

B

1 2 3

1 2 3

1 2 3

3 3 3

2 2 2

a a a

b b b

c c c

C

5. Write down the determinant of Dwithout calculations:

1 1 2

5 7 2

3 3 6

D

Matrices – Determinants 9Matrices – Determinants 9

Remember: the determinant of a 3x3 matrix is zero the three

rows or three columns of the matrix are coplanar

(this statement assumes that the zero vector is “in” all planes)

You should now be able to:•Calculate the determinant of a 2x2 matrix•Calculate the determinant of a 3x3 matrix•Recognize the geometrical meaning of the determinantand make deductions based on that knowledge.

Matrices – Inverse 1Matrices – Inverse 1

Given a matrix A, how can we find a matrix B such that AB=I?

Why is this question important?Suppose we want to find x,y such that:

1 1 2

2 1 3

x

y

Or: we want to find a vector that is mapped to

under the transformation

x

y

2

3

1 1

2 1

Matrices – Inverse 2Matrices – Inverse 2

1

1

2

3

2( )

3

2( )

3

2

3

2

3

-1

-1

-1

-1

Ax

A Ax = A

A A x = A

Ix = A

x = AThis can be solved by simple matrix multiplication

Matrices – Inverse 3Matrices – Inverse 3

Simple algebra will show you that

1 1 1

det( )

a b d b d b

c d c a c aad bc

M = M =

M

Calculating the inverse of a 3x3 matrix is a lot more work, usually. There are 4 steps:

1. Calculate the determinant of M2. Find the transpose of M -3. Replace each term in with its

cofactor4. Divide the resulting matrix (called the

“adjoint”) by the result of (1), i.e.:1

adj( )det( )

1M MM

TMTM

Matrices – Inverse 4Matrices – Inverse 4

Please read the yellow book p. 90 for a summary of this method.

Note: There is another method of finding the inverse,which we will discuss later.

•How are the determinants of a matrix M and its inverse related?•Under what circumstances does a matrix M not have an inverse?

det( ) 0 does not exist. 1M M

Matrices – Inverse 5Matrices – Inverse 5

•Find the determinants and inverses, where they exist, of the following square matrices:

2 7

1 3

A1 0 0

0 4 0

0 0 3

B

6 3 4

2 5 1

8 6 1

C =

6 3 4

2 5 1

0 0 0

D =0 1

1 0

E

Matrices – Linear systems 1Matrices – Linear systems 1

Solve the following “system” of equations:

3 4 2 1

3

2 5 3 6

x y z

x y z

x y z

Could you solve the following system using the same method?Would you make mistakes?Are there alternative methods we could use?

3 4 2 9 8 1

8 0 5 4

9 2 2 9 11 90

7 3 2 8 6 8

5 5 3 10 0.4

x y z a b

x y z a b

x y z a b

x y z a b

x y z a b

Ans: (1,1,3)

Matrices – Linear systems 2Matrices – Linear systems 2

We call sets of equations like this:3 4 2 9 8 1

8 0 5 4

9 2 2 9 11 90

7 3 2 8 6 8

5 5 3 10 0.4

x y z a b

x y z a b

x y z a b

x y z a b

x y z a b

“systems of linear equations” because each unknown variable occurs only to power 1, individually. So, there are no terms like:

22 2

5

1, , , , ,cos , yy

x xy za z ex b

Matrices – Linear systems 3Matrices – Linear systems 3

Notice that we can solve linear systems using the inverse of a matrix:To solve:3 4 2 1

3

2 5 3 6

x y z

x y z

x y z

write

3 4 2

1 1 1

2 5 3

A

so that1 3 4 2 1

3 1 1 1 3

6 2 5 3 6

1

3

6

x

y

z

x

y

z

1

Ax

A

Matrices – Linear systems 4Matrices – Linear systems 4

Now we can use our knowledge of matrix inverses to find the solution:

Given:3 4 2

1 1 1

2 5 3

Afind: 1A

and thus verify that the solution to the system isx=1, y=1, z=3.Answer: 34 1

19 19 191 5 13 1

38 38 38

3 23 738 38 38

A

Matrices – Gaussian eliminationMatrices – Gaussian elimination

As we can see, matrix inversion is a difficult and error prone method, but it is important to know about it.

Gaussian elimination is a systematic way to solve this type of system. We reduce the augmented matrix to row-echelon form.

Review p. 104-105 of the yellow book for the method.See also p.8-10 of my document “A Visual Introduction to Linear Algebra.

Matrices – Linear systems 5Matrices – Linear systems 5

To keep things simple, let’s stick to systems with 3 equations and 3 unknowns. How many solutions can there be?

•One•Zero•Infinitely many ( a line)•Infinitely many ( a plane)

Consider carefully the images on the next slides, which are copied from my document “A Visual Guide to Linear Algebra”.

Matrices – Linear systems 6Matrices – Linear systems 6

Matrices – Linear systems 7Matrices – Linear systems 7

Matrices – Linear systems 8Matrices – Linear systems 8

Matrices – Linear systems 9Matrices – Linear systems 9

Matrices – Linear systems 10Matrices – Linear systems 10

Matrices – Linear systems 11Matrices – Linear systems 11

In examining these patterns, you should remember that the equationax by cz d

represents a plane whose normal is the vector

a

b

c

p. 107-109 yellow book gives further illustrations. The most important principle, which I now repeat, is that:det( ) 0 is singular

the normals are coplanar

doesn't have unique solution

0

M M

Mx x

Matrices – Linear systems 12Matrices – Linear systems 12

Use Gaussian elimination to find the general solution of the following linear systems. Describe the solutions geometrically:

4 2 0

9 3 6 0

13 13 14 0

x y z

x y z

x y z

1:

-2 0 4 1

1 1 5 2

-1 3 2 3

x

y

z

2: Ans:

142

56

521

Ans: infinite solutions.See next slide.

Matrices – Linear systems 13Matrices – Linear systems 13

To solve a problem like (1), I expect you to use the following method:

4 2 0 1 4 2

9 3 6 0 9 3 6

13 13 14 0 13 13 14

x y z x

x y z y

x y z z

0

Reduce the augmented matrix to row echelon form:

1239

1 4 2 0 1 4 2 0

9 3 6 0 0 1 0

13 13 14 0 0 0 0 0

What does the bottom row of zeros tell you?

Matrices – Linear systems 14Matrices – Linear systems 14

Ans: Only two of the equations are independent. Also, the matrix is singular and its determinant is zero. There isn’t a unique solution, but there clearly are solutions (the null vector is obviously a solution). We reason as follows:•z can take any value, let’s call it μ.•Examining the second row tells us that•Examining the first row tells us:

413

1 4 2 0 1 4 2 0

9 3 6 0 0 1 0

13 13 14 0 0 0 0 0

4 413 13y z

10413 132 4 2 4x z y

Matrices – Linear systems 15Matrices – Linear systems 15

Thus the general solution can be written most simply as:

10413 132 4 2 4x z y

10

4 ,

13

x

yz 10

4

13

This is just the line of intersectionof the three planes:

Matrices – Linear systems 16Matrices – Linear systems 16

The method described in the last two slides can be applied to any linear system and I highly recommend it. Here’s a summary:

•Write the system in augmented matrix form.•Use elementary row operations to change the system to row-echelon form.•If there are no zero rows, find the single solution•If the left hand side has one or more zero rows, deduce whether there are NO solutions or an INFINITE number•If there are an infinite number, parametrize the undefined variables (e.g. z=alpha), and write the other variables in terms of the parameter•Deduce the geometric form of the solution (point, line or plane)

B

mg

R

30

mg

R

PV

O120

60P1V g

Z

Q

Y

X

x

y

i

j

kj i

ki j