meljun cortes - matrix algebra mathematics of computing

26
Lesson 10 - 1 Year 1 CS113/0401/v1 Matrix definition Rectangular array of numbers Size of matrix is given by no of rows and no of columns e.g. A = 2 x 3 matrix e.g. B = 3 x 3 matrix 2 9 16 1 0 -1 8 1 0 -1 0 1 4 1 5 LESSON 10 MATRIX ALGEBRA

Upload: meljun-cortes

Post on 05-Jul-2015

155 views

Category:

Documents


4 download

DESCRIPTION

MELJUN CORTES - Matrix Algebra Mathematics of Computing

TRANSCRIPT

Page 1: MELJUN CORTES - Matrix Algebra Mathematics of Computing

Lesson 10 - 1

Year 1

CS113/0401/v1

♦ Matrix definition

• Rectangular array of numbers

• Size of matrix is given by no of rows and no of columns

• e.g. A = 2 x 3 matrix

• e.g. B = 3 x 3 matrix

2 9 161 0 -1

8 1 0-1 0 1 4 1 5

LESSON 10MATRIX ALGEBRA

Page 2: MELJUN CORTES - Matrix Algebra Mathematics of Computing

Lesson 10 - 2

Year 1

CS113/0401/v1

♦ Vectors

• A single row matrix is called a row Vector

– e.g. [ 5 9 1 2 ]

• A single column matrix is called column vector

• e.g.16

1

0

-1

MATRIX ALGEBRA

Page 3: MELJUN CORTES - Matrix Algebra Mathematics of Computing

Lesson 10 - 3

Year 1

CS113/0401/v1

1 11 20 1 1

2 0 11 0 2

1 11 20 1 1

2 0 11 0 2

1+2 11+ 0 2+10+1 1+0 1+2

3 11 31 1 3

MATRIX OPERATION♦ Matrix Addition

• Must be of same dimension

• result is of same dimension

E.g. A =

B =

A + B = +

=

=

Page 4: MELJUN CORTES - Matrix Algebra Mathematics of Computing

Lesson 10 - 4

Year 1

CS113/0401/v1

1 11 28 1 1

-2 0 11 9 -2

1 11 28 1 1

-2 0 11 9 -2

1+(-2) 11+ 0 2-18-1 1-9 1-(-2)

3 11 17 -8 3

MATRIX OPERATION

♦ Matrix Subtraction

• Same rule as matrix addition

e.g.A =

B =

A - B = +

=

=

Page 5: MELJUN CORTES - Matrix Algebra Mathematics of Computing

Lesson 10 - 5

Year 1

CS113/0401/v1

5 21 -1

5 21 -1

5x2 2x21x2 -1x2

10 4 2 -2

MATRIX OPERATION

♦ Matrix Multiplication

• Scalar Multiplication

e.g.A =

2A = 2

=

=

Page 6: MELJUN CORTES - Matrix Algebra Mathematics of Computing

Lesson 10 - 6

Year 1

CS113/0401/v1

MATRIX OPERATION

♦ Matrix Multiplication

• No of columns is 1st matrix must be equal no of rows in 2nd matrix

• Result is of dimension

– No of rows in 1st matrix by no of column in 2nd matrix

e.g. If A is of dimension 2 x 3

B is of dimension 3 x 1

Then R=A * B is defined

R is of dimension 2 x 1

Page 7: MELJUN CORTES - Matrix Algebra Mathematics of Computing

Lesson 10 - 7

Year 1

CS113/0401/v1

R1 C1

3 12 47 4

A =

B =8 0 5 43 2 11 1

AB =3 12 47 4

8 0 5 43 2 11 1

3x8+1x3 3x0+1x2 3x5+1x11 3x4+1x1 2x8+4x3 2x0+4x2 2x5+4x11 2x4+4x1 7x8+4x3 7x0+4x2 7x5+4x11 7x4+4x1

=

= 27 2 26 13

28 8 54 1268 8 79 32

MATRIX OPERATION

♦ Matrix Multiplication

Page 8: MELJUN CORTES - Matrix Algebra Mathematics of Computing

Lesson 10 - 8

Year 1

CS113/0401/v1

♦ In matrix algebra unity is any square matrix whose top left to bottom right diagonal consists of 1s where all the rest of the matrix consists of zeros

♦ Matrices are only equal where they are the same size and have the same elements in the same place, i.e.

I =1 00 1

or I =1 0 00 1 00 0 1

or I =

1 0 0 00 1 0 00 0 1 00 0 0 1

1 0 00 1 00 0 1

1 00 1

UNITY MATRIX

Page 9: MELJUN CORTES - Matrix Algebra Mathematics of Computing

Lesson 10 - 9

Year 1

CS113/0401/v1

UNITY MATRIX

♦ As wit normal numbers where a number multiplied by one equals itself (3 x 1 = 3) so with matrices, A matrix multiplied by the unity matrix equals itself, i.e.

AI = A and IA = A

1 00 1

A =1 00 1

for example

AI = x =1 62 3

1x1+6x0 0x6+0x30x1+1x2 0x6+1x3

=1 62 3

Similarly

1 62 3

IA =1 00 1

x 1x1+6x0 1x0+6x12x1+3x0 2x0+3x1

=

= 1 62 3 thus proving that Al = IA = A

Note: The unit matrix, I, must always be square.

Page 10: MELJUN CORTES - Matrix Algebra Mathematics of Computing

Lesson 10 - 10

Year 1

CS113/0401/v1

EQUIVALENT MATRIX

♦ Two matrices are equal if and only if their corresponding elements are equal. For instance, if

then matrix A = matrix B

Example:

a. Find the values of x and y if A + B = C

b. Is BC + CB?

c. Evaluate 3B

A = 2 34 5

2 34 5

and B =

Given A = x 21 y

B =, 3 -54 2

8 -35 0

and C =

Page 11: MELJUN CORTES - Matrix Algebra Mathematics of Computing

Lesson 10 - 11

Year 1

CS113/0401/v1

a. A +B = x 21 y

+ 3 -54 2

X+3 2-51+4 y+2

=

= X+3 -3 5 y+2

X+3 -3 5 y+2

= 8 -35 0

X-3 = 8 and y + 2 = 0

EQUIVALENT MATRIX

♦ Solution:

Since A + B = C

Therefore x = 5, y = 2

Page 12: MELJUN CORTES - Matrix Algebra Mathematics of Computing

Lesson 10 - 12

Year 1

CS113/0401/v1

b. BC = 3 -54 2

8 -35 0

= 24-25 -9+032+10 -12+0

= -1 -942 -12

CB = 3 -54 2

8 -35 0

=24-12 -40-615+0 -25+0

=12 -4615 -25

c. 3B = 3 3 -54 2

= 3x3 3(-5)3x4 3x2

= 9 -1512 6

EQUIVALENT MATRIX♦ Solution:

Thus BC = CB

Page 13: MELJUN CORTES - Matrix Algebra Mathematics of Computing

Lesson 10 - 13

Year 1

CS113/0401/v1

A group operates a chain of filling stations in each of which are employed cashiers, attendants and mechanics as shown

The number of filling stations are

How many of the various types of staff are employed in Southern England and in Northern England?

Large stations

Medium stations

Small stations

Southern England

3

5

12

Northern England

7

8

4

Matrix B, i.e. 3 x 2

Types of filling station

Cashier

Attendants

Mechanics

Large

4

12

6

Medium

2

6

4

Small

1

3

2

Matrix A, i.e. 3 x 3

Exercise

Page 14: MELJUN CORTES - Matrix Algebra Mathematics of Computing

Lesson 10 - 14

Year 1

CS113/0401/v1

Solution

A is a 3 x 3 matrix, B is a 3 x 2 matrix therefore AB is feasible and will be a 3 x 2 matrix.

A x B = AB

4 2 112 6 3 6 4 2

3 7 5 812 4

X11 X12

X21 X22

X31 X32

X11 = (4x3) + (2x5) + (1x12) = 34X12 = (4x7) + (2x8) + (1x4) = 48X21 = (12x3) + (6x5) + (3x12) = 102X22 = (12x7) + (4x5) + (3x4) = 144X31 = (6x3) + (4x5) + (2x12) = 62X32 = (6x7) + (4x8) + (2x4) = 82

Cashiers

Attendants

Mechanics

South

3

5

12

North

7

8

4

AB is

Page 15: MELJUN CORTES - Matrix Algebra Mathematics of Computing

Lesson 10 - 15

Year 1

CS113/0401/v1

1

2

1 2 3 4 5

3

4

5

6

6

C

C’

A B

A’ B’

X

y

TRANSFORMATION

A transformation is an operation which transform a point or a figure into another point or figure.

Translation

A translation is a transformation which moves all points in a place through the same direction.e.g. The triangle ABC has been transformed onto the triangle A”B”C” by a translation [ ] i.e. 3 squares to the right and 2 squares up inthe plane of the paper.

Page 16: MELJUN CORTES - Matrix Algebra Mathematics of Computing

Lesson 10 - 16

Year 1

CS113/0401/v1

Point a is mapped onto A’ by a

translation , denoted by T.

Enlargement (E)

An enlargement with centre O, scale factor k is a transformation which enlarges a given figure by k times the original size. If k > O, the given figure and its image are on the same side of the centre of enlargement O.If k > O, the given figure and its image are on opposite sides of O.

32

Xy

11

+

+

T =X’y’

32 =

43

Translation

Page 17: MELJUN CORTES - Matrix Algebra Mathematics of Computing

Lesson 10 - 17

Year 1

CS113/0401/v1

OA’ OB’ OC’= = =

OA OB OC

o

C

C’

A

A’

BB’

Under an enlargement, Area of image

= k2

Area of Figure

Enlargement (E)The figure and its image after an enlargement are similar, The scale factor K

If the image of a point (x,y) under a transformation is the point itself i.e. (x,y), the point (x,y) is called an invariant point of the transformation.If a line is mapped onto itself under a transformation, the line is said to be an invariant linr under the transformation.

Page 18: MELJUN CORTES - Matrix Algebra Mathematics of Computing

Lesson 10 - 18

Year 1

CS113/0401/v1

A reflection is a transformation which reflects all points of a plane in a line ( on the plane ) called the mirror line.

ABC is mapped onto A’B’C’ under a reflection in the line XY which is the perpendicular bisector of AA’, BB’ OR CC’.

Under a reflection, the figure and its image are congruent.

Example:

x

A’A

C’C

B’B

Y

Reflection

Page 19: MELJUN CORTES - Matrix Algebra Mathematics of Computing

Lesson 10 - 19

Year 1

CS113/0401/v1

Rotation (R)

A rotation is a transformation which rotates all points on plane about a fixed point known as the centre of rotation, 6through a given angle in anti-clockwise of clockwise direction.

The angle through which the points are rotated is called the angle of rotation.

The triangle ABC is rotated about the origin O through 90 in the anti-clockwise direction, and mapped onto triangle A’B’C’.

Page 20: MELJUN CORTES - Matrix Algebra Mathematics of Computing

Lesson 10 - 20

Year 1

CS113/0401/v1

OBC is mapped onto OB’C’ under a shear along the x-axis with factor k.

OC’ 6K = = = 2

OC 3

Shearing (H)

A shear parallel to the x-axis is a transformation which moves a point (x,y) parallel to the x-axis through a distance ky, where k is the shear factor.

Page 21: MELJUN CORTES - Matrix Algebra Mathematics of Computing

Lesson 10 - 21

Year 1

CS113/0401/v1

difference in y-coordinates of corresponding pointsk =

x-coordinates of original point

Shearing (H)

A shear parallel to the y-axis is a transformation which moves a point (x,y) parallel to the y-axis through a distance kx, where k is the shear factor.

Stretching (S)

♦ One way stretch

• A stretch parallel to the x-axis is a transformation which move a point (x,y) parallel to the x-axis, through a distance ky, where k is the stretch factor.

• A stretch parallel to the y-axis is a transformation which moves a point (x,y) parallel to the y-axis through a distance ky, where k is the stretch factor.

Page 22: MELJUN CORTES - Matrix Algebra Mathematics of Computing

Lesson 10 - 22

Year 1

CS113/0401/v1

distance of new point the invariant linek =

x-coordinates of original point

Shearing (S)

In the case of stretching parallel to the x-axis, the invariant line is the x-axis.

In the case of stretching parallel to the y-axis, the invariant line is the y-axis.

Page 23: MELJUN CORTES - Matrix Algebra Mathematics of Computing

Lesson 10 - 23

Year 1

CS113/0401/v1

Shearing (S)

♦ Two Way Stretch

If a figure is stretched parallel to the x-axis as well as parallel to the y-axis, then the stretch is called a two-way stretch.

Under a two-way stretch with h and k as constants of stretch parallel to the x-axis and y-axis respectively a point (x,y) is mapped onto (hx,ky).

Page 24: MELJUN CORTES - Matrix Algebra Mathematics of Computing

Lesson 10 - 24

Year 1

CS113/0401/v1

Example: Matrix represents a

transformation T.Given (x,y) is the image of the point (a,b) under the transformation T, find x and y in terms of a and b.Solution: Write the ordered pairs, (a,b)

and (x,y) as column vectors:

Premultiply by the matrix ,

we get

Therefore, x = a + 3b, y = 2a - 5b

1 32 -5

ab

andxy

ab

1 33 -5

xy =

1 32 -5

ab

=1xa + 3xb

2xa + (-5)xb

a + 3b2a -5b=

Shearing (S)

Page 25: MELJUN CORTES - Matrix Algebra Mathematics of Computing

Lesson 10 - 25

Year 1

CS113/0401/v1

The matrix defines a

transformation T which maps the points (a,b) onto ( a + 3b, 2a - 5b ).

Example:Find the coordinates of the image of the point (-3,2) under the transformation represented

by the matrix

Solution:Let the image of the point = (x,y)

Therefore the images of the point = (-11,-15)

1 32 -5

3 -15 0

Xy

=3 -15 0

-3 2

3x(-3) + (-1)x25x(-3) + 0x2

=

=

= -9-2-15+0

-11-15

Stretching (S)

Page 26: MELJUN CORTES - Matrix Algebra Mathematics of Computing

Lesson 10 - 26

Year 1

CS113/0401/v1

Example:Find the matrix of the transformation which maps (1,0 ) onto (4,1) and (0,1) onto (3,2).

Solution:Let the matrix of transformation

=

(1,0) (4,1)

because (4,1) is the image of (1,0)

10

Stretching (S)

a bc d

41

a bc d=

41 =

a + 0c + 0

= ac