Anda di halaman 1dari 8

Faculty of Computing,

Engineering and the Built


Environment

Data Analysis UG1


Vectors and Matrices
1 - Vectors
1.1 Introduction
Many quantities occur in computing which require both a magnitude and a direction. These quantities
are called vector quantities because they are defined by their magnitude and direction, as opposed to
scalar quantities which need only a magnitude eg volume, temperature, area, length.

1.2 Notation
Vectors are usually denoted by a lower case letter that is either in bold type (as in text books) or
underlined.

The vector from A to B is referred to as the vector AB or the vector a

The vector from B to A is a , ie same magnitude but in the opposite direction.

The magnitude of a is written as |a| and is referred to as the modulus of a

If a vector has modulus of 1 then it is called a unit vector.

There are a number of ways of specifying a vector.

1.2.a Components of a vector in terms of a unit vector


y i is defined as the unit vector in the direction Ox

j is defined as the unit vector in the direction Oy

O x
i

Data Analysis UG1 1


Example 1.2.1

2 a The vector a = 3i + 2j

O
1 2 3

1.2.b Cartesian form


Usually written as a column matrix

Example 1.2.2

3
a=
2

1.3 Modulus
The modulus of a vector is the length and is found by Pythagoras theorem.
It is denoted thus:|a|
|a| = 32 22 9 4 13

1.4 Addition of vectors


The sum of two vectors is defined as the single or resultant vector c

a+b=c

c
b

The resultant can also be obtained by adding the horizontal components and adding the vertical
components

Example 1.4.1

If a = 3i + 2j and b = 2i + 5j then c= (3 + 2)i + (2 + 5)j = 5i + 7j in unit vector form.

Data Analysis UG1 2


1.5 Subtraction of vectors
Example 1.5.1

If a = 3i + 2j and b = 2i + 5j then a b = (3 2)i + (2 5)j = i 3j

This can be shown diagrammatically thus:

a
b
a b

1.6 Multiplication by a scalar quantity


Example 1.6.1

If a = 3i + 2j then 4a = 4(3i + 2j ) = 12i + 8j

Multiply each component by the scalar quantity


(These are similar to operations on complex numbers)

As with all vectors direction is important - remember that the vector from A to B is not the
same as the vector from B to A.

Data Analysis UG1 3


2 - Matrices

Introduction
Matrices are a convenient notation which enables us to handle large quantities of information and systems of
equations more effectively. For instance, these model the way in which data is stored in a two dimensional array in
computer programming.

2. Matrices and Determinants


2.1 Matrix
A rectangular array of numbers whose positions are relevant. Using matrices allows us to manipulate and store
information more easily.

An M by N matrix (M x N) has M rows and N columns.

2.1.1 General Matrix Notation

a 11 a 12 a 13 .......... a 1n
a 21 a 22 a 23 .......... a 2n
a 31 a 32 a 33 .......... a 3n
A=
. . . . .
. . . . .
a m1 a m2 a m3 .......... a m n
MxN

2.1.2 Column Matrix Row Matrix

b1
b2
B= . C= c1 c2 c 3 .......... c n
.
bm
Mx1 1xN

2.1.3 Element of a Matrix

ai j for a 2 Dimensional matrix A where i = 1, 2, 3 .. m (row number) and


j = 1, 2, 3 .. n (column number)

Data Analysis UG1 4


2.2 Matrix Algebra
It is possible to perform operations between matrices. The more useful operations are defined (kept as similar to
operations between Real numbers as possible)

2.2.1 Equality

4 3 4 3
A= B= Then A = B
1 2 1 2

5 2 5 1
C= D= Then C D
3 4 3 4

2.2.2 Addition Add the corresponding elements

2 3 1 0 3 3
1 4 + 0 -4 = 1 0
1 5 1 3 0 8
A + B = C

2.2.3 Subtraction Subtract the corresponding elements

2 3 1 0 1 3
1 4 0 -4 = 1 8
1 5 1 3 -2 2
A B = C

It follows therefore that only matrices of the same size (or order) may be added or subtracted

2.2.4 Scalar Multiple Multiply each element by the scalar multiple

1 2 5 3 6 15
3 =
0 3 2 0 9 6

2.2.5 Multiplication The rows of the left hand matrix act on the columns of the right hand matrix.
You go across the rows and down the columns.
6 1
2 1 3 2x6 1x0 3x( 1) 2x( 1) 1x2 3x1 9 3
0 2 =
4 5 6 4x6 5x0 6x( 1) 4x( 1) 5x2 6x1 18 12
1 1
A B = C
2 3 3 2 = 2 2

It follows therefore that the number of columns in the left hand matrix should be the same as the number of
rows in the right hand matrix.

2.2.6 Division Division of matrices is not defined.

Data Analysis UG1 5


2.3 Determinants (Square matrices)
2.3.1 Determinant of 2 x 2 Matrices

a 11 a 12
If A = then Determinant of A = detA = |A| = a11 x a22 - a21 x a12
a 21 a 22

Example 2.1
1 2
If A = then Det A = 1x4 3x2 = 4 6= 2
3 4

Example 2.2
3 4
If B = then Det B = ( 3)x( 1) ( 2)x(4) = 3 8 = 3 + 8 = 11
2 1

2.3.2 Determinant of 3 x 3 Matrices

a 22 a 23 a 21 a 23 a 21 a 22
Det A = a 11 a 12 a 13
a 32 a 33 a 31 a 33 a 31 a 32

Example 2.3
2 5 4
3 6 0 6 0 3
eg A = 0 3 6 then Det A = 2 5 4
7 1 3 1 3 7
3 7 1
= 2( 3 42) 5(0 18) + 4(0 9)
= 2( 45) 5( 18) + 4(9)
= 90 + 90 + 36
= 36

A similar approach (but far more involved) is used for higher order matrices.

Determinants are only defined for square matrices (where the number of rows equals the number of columns).

Data Analysis UG1 6


Vector Problems
In all questions:

5 8 1 3 7 2
a= b= c= d= e= f=
12 15 2 4 24 2

1. Calculate the following

i) a+b ii) a+b c iii) b + 2c iv) b a

v) a d vi) 2d 3c vii) 2e 5a b viii) a (c d)

ix) 2a 3(c + d) 3(e b + c)

2. Write each of the answers from 1. in unit vector form.

3. Calculate the following

i) |a| ii) |b| iii) |c| iv) |d|

v) |e| vi) |f| vii) |a + b| viii) (|a + b|)2

ix) |a| + |b|

Matrices Problems
In all questions:
1 0
4 0 5 1 4 1 1
A= B= C= 3 1 D=
1 2 1 3 2 0 3
1 1
2 0 3 2 2 3
E= 1 2 3 F= 3 1 3
5 3 0 1 5 0

Calculate the following, or say where the answer is undefined.

1. A + B 2. B + A 3. AT 4. 3B 5. 3B A

6. A + C 7. A 2B 8. BA 9. AB 10. CD

11. DC 12. A3

13. a) Det A b) Det B c) Det C


d) Det D e) Det E f) Det F

Data Analysis UG1 7


Answers to Vector Problems
1.

13 12 10
i) ii) iii)
27 29 11

3 2 3
iv) v) vi)
3 16 2

19 7 2
vii) viii) ix)
27 10 21

2.

i) 13i + 27j ii) 12i + 29j iii) 10i + 11j

iv) 3i + 3j v) 2i + 16j vi) 3i 2j

vii) 19i 27j viii) 7i + 10j ix) 2i + 21j

3.
i) 13 ii) 17 iii) 5 iv) 5 v) 25

vi) 2 vii) 29.97 viii) 898 ix) 30

Answers to Matrices Problems

9 1 9 1 4 1 15 3 11 3
1. 2. 3. 4. 5.
0 5 0 5 0 2 3 9 4 7
6 2
6. undefined 7.
3 4

4 1 1
19 2 20 4 0 2 64 0
8. 9. 10. 10 3 0 11. 12.
1 6 3 5 1 3 28 8
2 1 2

13. a) 8 b) 14 c) undefined d) undefined e) 57 f) = 84

Data Analysis UG1 8