Sei sulla pagina 1di 42

Lecture 6b

Matrices

Week 6
12 October 2016
Matrix Definitions, Notation
and Operations
A matrix is another name for a table which can
include data or other information.
A matrix comprises n rows and m columns.
A 3 x 4 matrix would therefore have 3 rows and
4 columns.
A 1 x 4 matrix would have 1 row and 4 columns
and would be referred to as a row vector.
A 4 x 1 matrix would have 4 rows and 1 column
and would be referred to as a column vector.
Vectors are usually denoted by underlining the
letter of the matrix and convention dictates that a
lower case letter is used.
2
Adding and Subtracting
Matrices
Matrices can be added or subtracted together
simply by adding or subtracting the matching
entries.
Addition or subtraction is only possible if the
matrices are of the same order, i.e. they have the
same number of rows and columns.
So in general if:
a11 .. .. .. a1n b11 .. .. .. b1n

.. .. .. .. .. ..
A .. .. .. ; B .. .. ..

.. .. .. .. .. ..

n1
a .. .. .. a nn n1
b .. .. .. b nn
3
Adding and Subtracting
Matrices
Then we can represent the addition of the two
matrices by:
a11 b11 .. .. .. a1n b1n

.. .. ..
AB .. .. ..

.. .. ..

an1 bn1 .. .. .. ann bnn

And we can represent the subtraction of the two


matrices by:
a11 b11 .. .. .. a1n b1n

.. .. ..
A B .. .. ..

.. .. .. 4

a
n1 n1 b .. .. .. ann bnn
Adding and Subtracting
Matrices

Sometimes the addition or subtraction operation


will lead to a zero answer.
This is referred to as the zero matrix which can
simply be written as 0.

5
Scalar Multiplication
of Matrices
Scaling a matrix means multiplying each element
by a certain factor.
The factor can be positive, negative, fractional or
whole.
For example if we have the matrix:
a11 a12
A
a21 a22
And we want to find kA where k is the scalar then
we multiply each element by k:

k a11 k a12
kA
k a21 k a22
6
Scalar Multiplication
of Matrices
Examples of scalar multiplication
3 7 6
1 0 2
X ;Y ; Z 4 7 3
0 1 2 5 2 7

Find:
2X
3Y
0.5Z

7
Scalar Multiplication
of Matrices

2 1 2 0 2 0
2 X ;
2 0 2 1 0 2
32 6
3Y ;
3 2 6
0 .5 3 0 .5 7 0 .5 6 1 .5 3 .5 3

0 .5 Z 0 .5 4 0 .5 7 0 .5 3 2 3 .5 1 .5
0.5 5 0.5 2 0.5 7 2.5 1 3.5

8
Transposing Matrices
Transposition really means switching around. If:

a b c

A d e f
g h i

Then the transpose of A, denoted AT is shown as:
a d g

A b e h
c f i

Note that after the transposition the dimensions of the matrix
will change. That is, a matrix with n rows and m columns will
have m rows and n columns. E.g. A 2 x 4 becomes a 4 x 2 after
transposition.
9
Matrix Multiplication

Matrices can be multiplied together if the number


of rows in one matrix is the same as the number of
columns in the other matrix.
If we define the dimensions of a matrix as m x n
where m is the number of rows and n is the
number of columns.
Then if we were to multiply a (m x n) matrix by
another (n x m) then the resultant matrix would be
m x m and the multiplication operation has only
been possible since the number of columns in the
first matrix (the lead matrix) is equal to the
number of columns in the second matrix (the lag
matrix).
10
Matrix Multiplication
A little trick is: to place the two sets of dimensions in
the order in which they are to be multiplied, then
circle the last number of the lead matrix dimensions
and the first number of the lag matrix dimensions.
If the two numbers are equal then they are
conformable.
Furthermore, the outer numbers will provide the
dimensions of the product matrix.
Lead Lag Dimensions
Conformable?
Matrix Matrix of product
(2 x 2) (2 x 2) Yes (2 x 2)
(1 x 3) (3 x 3) Yes (1 x 3)
(2 x 4) (4 x 2) Yes (2 x 2)

11
Matrix Multiplication
Having determined that it is possible to undertake
matrix multiplication we then must follow the
procedure to multiply two matrices.
For example if:
a11 a12 b11 b12
A and B
a21 a22 b21 b22
And we want to calculate AB we take the first row
of A and multiply each element against the
corresponding element of the first column of matrix
B and add together.
So AB is:
a11 b11 a12 b21 a11 b12 a12 b22
AB
a21 b11 a22 b21 a21 b12 a22 b22
12
Matrix Multiplication:
Examples
2 3 2 1
Let A ; B
4 5 1 1
2 2 3 1 2 1 3 ( 1) 7 1
AB
4 2 5 1 4 1 5 ( 1) 13 1

1 4 2

Let C 2 6 3 ; D 5 0 6
1 7 9

CD 2 1 6 5 3 ( 1) 2 4 6 0 3 7) 2 2 6 6 3 9
29 29 67

13
Matrix Multiplication:
Examples
1 2

1 2 3 4 3 7
X ;Y
5 6 7 8 0 3

5 2

1 1 2 3 3 0 4 5 1 2 2 7 3 3 4 2
XY
5 1 6 3 7 0 8 5 5 2 6 7 7 3 8 ( 2)
27 17
XY
63 57

14
Matrix Inversion
Unfortunately inverting a matrix is slightly more
cumbersome than simply inverting a number. For
example if we invert 4 we get . Moreover it is more
cumbersome to invert a 3x3 matrix as opposed to a
2x3 matrix. a b
Starting with the 2x2 matrix, A = c d

If we wish to find the inverse of A, A-1, we must
follow the following steps:
1. Swap elements a and d.
2. Change the signs of elements b and c.
3. Multiply the matrix we now have by the
determinant, 1/[ad bc]
15
Inversion of a 2x2 Matrix
Example.
1 4
Consider the 2x2 matrix, A =
0 3

Using our 3 step method:


1. Step 1 gives, 3 4
0
1
2. Step 2 gives, 3 4

0 1
3. Step 3 gives,
1 3 4 1 3 4 1 4 3

1x3 (4)x0 0 1 3 0 1 0 1
3 16
Matrix Inversion
Note that if multiply 4 by you get the answer 1.
Likewise if you take a matrix and multiply it by its
inverse you arrive at the matrix equivalent of 1, the
identify matrix, I.
The 2x2 matrix I is: 1 0
0 1

Note if we multiply A in our previous example by A-
1 we get:

1 4 1 4
1 1 ( 4) 0 1 ( 4 3 ) ( 4) ( 13 ) 1 0

3

1
0 3 0 3 0 1 3 0 0 ( 3 ) (3 ) ( 3 ) 0 1
4 1

17
Determinant of a Matrix
The term (ad-bc) is known as the determinant of
the matrix, denoted det(A).
Note that if (ad-bc) is zero we cannot work out the
inverse of the matrix.
Note:
(ad-bc) = 0 then the matrix is a singular matrix
and cannot be inverted.
(ad bc) 0 then the matrix is non-singular and
can be inverted.

18
Applications of 2x2 Matrices
and Inversions
We can use the previous technique of inverting 2 x 2
matrices to solve simultaneous equations problems.
Consider the economic data below concerning two
commodities, tea and coffee.
An economist finds that:
4P1 P2 = 1
-2P1 + 3P2 = 12
Where P1 denotes the price of tea and P2 denotes
the price of coffee.
It is possible to utilise matrices to find the equilibrium
values for P1 and P2.
19
Applications of 2x2 Matrices
and Inversions
Writing the system of equation in matrix form,
Ax=z.
Where:
4 1 P1 1
A , x , z
2 3 P2 12

If we pre-multiply both sides of the equation by A-1


we get:
A-1Ax=A-1z = Ix=A-1z and so x=A-1z
Hence to find the vector x we need to find the
inverse of A and multiply it by the vector, z.
20
Applications of 2x2 Matrices
and Inversions
A-1 can be found by the three step process outline
earlier and is equal to:

1 1 3 1 3 10 1

A 10

3 4 1 2 2 4 15 2
5

Multiplying this by the vector, z, we get:

3 10 1
1 3 10 1210 3 2
10

2 12 1 24
15 5 5 5 5

Hence P1 = 1.5 and P2=5.


21
Inversion of a 3x3 Matrix
Consider the following matrix A which has three rows
and three columns.
a11 a12 a13

A a21 a22 a23
a a a
31 32 33

The first step in inverting a 3x3 matrix is to find the


co-factor associated with each element. This is done
by deleting the row and column associated with each
element and then finding the determinant of the
remaining 2 x2 matrix.
22





23
Inversion of a 3x3 Matrix
Co-factor associated with the element in row 1,
column 1.
Delete column 1 and row 1.

a11 a12 a13



a21 a22 a23
a a a
31 32 33

24
Inversion of a 3x3 Matrix
Co-factor associated with the element in row 1,
column 1.
Delete column 1 and row 1.

a11 a12 a13



a21 a22 a23
a a a
31 32 33

25
Inversion of a 3x3 Matrix
Co-factor associated with the element in row 1,
column 1.
Delete column 1 and row 1.

a11 a12 a13



a21 a22 a23
a a a
31 32 33

26
Inversion of a 3x3 Matrix
Find the determinant of the resultant 2x2 matrix.

a22 a23

a32 a33

27
Inversion of a 3x3 Matrix
Find the determinant of the resultant 2x2 matrix.

a22 a23

a32 a33

28
Inversion of a 3x3 Matrix

Find the determinant of the resultant 2x2 matrix.

a22 a23

a32 a33

The resultant determinant is called the minor of a 11


and is equal to a22a33 a23a32.
The cofactor of each element is then found by
multiplying the minor by +1 or -1 according to this
structure.
29
Inversion of a 3x3 Matrix

There are still a number of steps required to find the


inverse of a 3x3 matrix.
Before we progress consider the matrix:

1 2 3

A 2 1 0
1 1 1

Step 1 is to find the minors associated with each


element following the process outlined above.

30
Inversion of a 3x3 Matrix
Minor of a11 = 1x1 0 x (-1) = 1
Minor of a12 = 2 x1 0 x 1 = 2
Minor of a13 = 2 x (-1) 1 x 1 = -3
Minor of a21 = -2 x 1 3 x (-1) = 1
Minor of a22 = 1 x 1 3 x 1 = -2
Minor of a23 = 1 x (-1) (-2) x 1 = 1
Minor of a31 = -2 x 0 3 x 1 = -3
Minor of a32 = 1 x 0 3 x 2 = -6
Minor of a33 = 1 x 1 (-2) x 2 = 5

31
Inversion of a 3x3 Matrix
The matrix of minors is then:
1 2 3

1 2 1
3 6 5

Multiplying by +1 or -1 according to this structure we


arrive at the matrix of co-factors.

1 2 3

1 2 1
3 6 5

32
Inversion of a 3x3 Matrix
The next step is to create the adjoint matrix of A, adj(A),by
transposing each of the elements of the matrix of co-factors.
Applying this to our example:

1 2 3 1 1 3

1 2 1 adj ( A) 2 2 6
3 6 3 1 5
5

33
Inversion of a 3x3 Matrix
The next step is find the determinant of matrix A.
There are a number of ways of doing this but since we have
already obtained the co-factors we can multiple these by the
original elements of matrix A and add them together to find
the determinant.
1 2 3 1 2 3

A 2 1 0 matrix of co-factors = 1 2 1
1 1 1 3 6 5

Det(A)=1x1 + (-2)x(-2) + 3 x (-3)


34
Det(A)=1 + 4 -9 =-4
Inversion of a 3x3 Matrix
The 5th and final step to obtaining the inverse of a 3 x 3 matrix
is to multiply the determinant by the adjoint of A.

1 1 3

adj ( A) 2 2 6
Det(A) = -4
3 1 5

1 1 3 0.25 0.25 0.75


1 1
A 2 2 6 0.5 0.5 1.5
4
3 1 5 0.75 0.25 1.25 35
Applications of 3x3 Matrices
and Inversions
We have already seen how to use matrices to solve
an economic problem where two variables are linked.
To do this we need to invert a 2x2 matrix.
We then looked at how to invert a 3x3 matrix.
A logical progression is to utilise the inversion of a
3x3 matrix in solving a system of three equations.
Consider:
2P1 P2 + P3 = 5
P1 -3P2 + 2P3 = 2
2P1 + P2 +4P3 = -3
Where P1, P2 and P3 denote the profits from the
production of tea, coffee and cocoa respectively.
36
Applications of 3x3 Matrices
and Inversions
Writing the system of equation in matrix form,
Ax=z.
Where: 2 1 1 P1 5

A 1 3 2 , x P2 , z 2
2 1 4 P 3
3
If we pre-multiply both sides of the equation by A-1 we
get:
A-1Ax=A-1z = Ix=A-1z and so x=A-1z
Hence to find the vector x we need to find the inverse
of A and multiply it by the vector, z.

37
Applications of 3x3 Matrices
and Inversions: Cramers Rule

We said previously that it is more cumbersome to


invert a 3x3 matrix than a 2x2 matrix. Well imagine
if you had to invert a 4x4 matrix or a 5x5 matrix?
Cramers rule helps us solve any system of
equations.

38
Cramers Rule
Writing the system of equation in matrix form,
Ax=z.
Here x is the vector of unknowns.
Cramers rule tells us that if we want to find a
certain x variable, let us call it xi, then we can find
it as follows. det( Ai )
xi
det( A)
The matrix Ai above is formed by substituting the ith
column of the original matrix A with the column
vector, z.

39
Cramers Rule: Example
To illustrate the similarities between the matrix
inversion approach and the Cramers rule
approach we will again consider the following
system of equations.
2P1 P2 + P3 = 5
P1 -3P2 + 2P3 = 2
2P1 + P2 +4P3 = -3
Hence:

2 1 1 P1 5

A 1 3 2 , x P2 , z 2
2 1 4 P 3
3
40
Cramers Rule: Example
The first step is to find the determinant of A.
Expanding by row 1 we get:
3 2 1 2 1 3
det( A) 2 ( 1) 1
1 4 2 4 2 1
2 12 2 1( 4 4) 1(1 6)
2( 14) 0 7 21

Now forming the three matrices: A1, A2 and A3.


5 1 1 2 5 1 2 1 5

A1 2 3 2 ; A2 1 2 2 ; A3 1 3 2
3 1 4 2 3 4 2 1 3

41
Cramers Rule: Example
The determinants of the matrices A1, A2 and A3
can be shown to be -63, 21 and 42 respectively.
Hence as the determinant of A is -21:
P1 = -63/-21 = +3
P2 = 21/(-21) = -1
P3 = 42/(-21) = -2
These are of course the same values we found
using the matrix inversion approach.

42

Potrebbero piacerti anche