Transcript Matrices

Student Handbook
1
Matrices
• A matrix (plural: matrices, not matrixes) is a
rectangular array of numbers such as
1 2 3 6000 
2 3 2 7000


1 1 2 4000
• Matrices are useful when modelling a variety
of real-life problems, and are the abstract
mathematical counterparts of array data
structures in programming.
2
Matrix
Entries
• In this section we show how to add and multiply
matrices.
• We shall identify the numbers inside a matrix by
their position. In matrix
A=  1
2 0
  3 4 3


• we may describe the number 1 as “the entry in
the first row, first column”, or more precisely write
a11 = 1.
3
Matrix
Entries
• Similarly a = 2 is the entry in the first row,
12
•
•
•
•
second column.
More generally we write aij for the entry in the
ith row, jth column.
Matrices come in different sizes. Since A has two
rows and three columns, we call A a 2×3 or
“2 by3” matrix.
The size of a matrix determines what other
matrices it can be added to or multiplied with.
Matrices are equal if they are the same size and
their corresponding entries are equal.
4
Addition
 Two matrices A and B of the same size can be
added together and the sum A+B is obtained by adding
the corresponding entries.
 For example
1 0   3 6  4 6
 0 2   5  3  5  1

 
 

2  1  0 1  2 0
5
Addition
 However, the sum
 1 0  1 3 4 
 0 2   2 2 5

 

2  1 3 1 6
is not defined, since the first matrix is 3×2 but the
second is 3 × 3.
6
Scalar Multiplication
 To multiply a matrix A by a scalar c just means
that c is some real number and that we
multiply every entry in A by c.
 Let
1 6
A = 

2
0
1


and let c = , then
2
1
2
1
A
2

1

3


0
7
Scalar Multiplication
 The difference A - B of two matrices of the
same size is just another way of writing
A + (-1)B:
2
1 6  1 4 1 6
  1 4 0
2 0   0 3  2 0  (1)  0 3  2  3

 
 


 

8
Matrix Multiplication
• If A is a k × m matrix and B is an m × n matrix,
then the product C = AB is the k×n matrix whose
entries are found as follows:
• To calculate cij, take row i from matrix A and
column j from matrix B, multiply the corresponding
entries together, and add up the results.
• Note that AB is defined iff the number of columns
of A matches the number of rows of B.
9
Matrix Multiplication
 For example
1 6  0 4
2 5 2 2



3 4 4 0
is undefined, because the matrices to be
multiplied are 3 × 2 and 3 × 2.
 So it is possible to have two matrices that can be added
but not multiplied together.
10
Examples of Products
0 
1 2    6
 3
where the matrices to be multiplied are 1 × 2 and 2 × 1,
so that multiplication is defined and the product is 1 ×
1.
 3 1
 3  0  1 2 3  (1)  1 4 
2 0 0  1  2  0  0  2 2  (1)  0  4

 2 4  



 2 1
 2  0  1 2 2  (1)  1 4 
11
Examples of Products
1
2
 0  2
 2 2 
where the matrices to be multiplied are 3 × 2
and 2 × 2, so that multiplication is defined and
the product is 3 × 2.
12
Why?
• Let’s show, by a real-life example, why matrix
multiplication is defined in such a strange way.
• Suppose a superannuation fund has investments
in three countries.
• The deposits in each country are divided among
government bonds, mortgages, and shares.
• Let’s represent the amount currently invested in each
country, in millions of dollars, by the table
13
Why?
Country A
Country B
Country C
Bonds
5
3
2
Mortgages
10
9
6
Shares
20
15
10
• The table can be simplified to the matrix
5 10 20
3 9 15 


X = 2 6 10 


14
Why?
 Now suppose the average yields are 4%
for bonds, 7% for mortgages, and 10% for
shares.
 How would we work out the earnings
the superannuation fund can expect from its
investments in each country?
15
Why?
 The amount earned in Country A would be
(amount invested in bonds)·(yield of bonds)
+ (amount in mortgages) ·(yield of mortgages)
+ (amount in shares) ·(yield of shares)
= (5)(.04) + (10)(.07) + (20)(.10).
 This is like working out an entry in a matrix
product.
16
Why?
• Let the yield matrix be
Y=
0.04 
0.07 


 0.1 
• Then the amount earned in Country A is just the first
entry of the product
XY =
5 10 20 0.04
3 9 15  0.07



2 6 10   0.1 
17
Why?
• and the earnings for the other countries are
the second and third entries:
5 10 20 0.04  2.9 
3 9 15  0.07  2.25


 

2 6 10   0.1   1.5 
• The fund earns 2.9 million in Country A, 2.25
million in Country B, and 1.5 million in
Country C.
18
Representing Systems of
Equations
 Here is another use for products. The system of linear
equations
2x - 3y = 5
4x + y = 0
can be represented compactly by the matrix
equation:
2  3  x  5
 4 1   y   0 

   
19
Representing Systems of
Equations
which is of the form
AX = B
where
2  3
 x
5
A
, X  ,B 

4 1 
 y
0
20
A• You
Real
Life
Problem
have a bacteria culture containing three
species of bacteria. Each species requires
different amounts of three nutrients: nitrates,
carbohydrates, and phosphates.
• The requirements are given in the table, in
micrograms per day.
Species
Nitrates Carbohydrates Phosphates
A
1
2
1
B
2
3
1
C
3
2
2
21
A Real Life Problem
 The daily supply of nitrates is 6000 units, of
carbohydrates is 7000 units, and of
phosphates is 4000 units.
 How many bacteria of each species can the
culture grow?
22
Modelling
the
data
• Let x be the number of bacteria of species A,
y
the number of B, and z the number of C.
• We want to use our data to find the values of
x, y, and z.
• But first we have to represent that data in a
way that connects the information with the
unknowns x, y, and z.
• This gives us a system of linear equations:
23
Modelling
the
data
 If the entire daily supply of 6000 units of nitrates is
used up, then
x + 2y + 3z = 6000.
 Similarly, from the data about carbohydrates we get
2x + 3y + 2z = 7000
 and from the phosphate data we get
x + y + 2z = 4000.
24
Solving Linear Equations
 In this section we show how matrices arise
when solving systems of linear equations.
 Key concepts in this section: system of linear
equations, augmented matrix, coefficient
matrix, elementary transformation, echelon
form, rank of a matrix.
25
Echelon
Form
 We have the following system of equations to
solve:
x + 2y + 3z = 6000
2x + 3y + 2z = 7000
x + y + 2z = 4000
 but it is unclear what values of x, y, and z
would satisfy the equations.
26
Echelon
Form
• So we transform this system into a new system which
has the same solutions but is easier to solve.
• If the new system is in echelon form it is easy to solve:
x + 2y + 3z = 6000
y + 4z = 5000
3z = 3000
• Now z = 1000 and back-substituting gives
y = 5000-4000 = 1000 and
x = 6000-2000-3000 =1000.
27
Matrix
Representation
 Suppose we are going to transform the system
of equations into a new system in echelon form.
 It will reduce the labour if we simplify the
representation.
 Instead of writing down the equations, we write
down just the coefficients of the unknowns on
the left and the constants on the right, giving us
the augmented matrix of the system.
28
Matrix
Representation
 So from the system
x + 2y + 3z = 6000
2x + 3y + 2z = 7000
x + y + 2z = 4000
 we get the augmented matrix
1 2 3 6000 
2 3 2 7000


1 1 2 4000
29
Elementary
Transformations
We can change a system of equations into a
•
•
•
•
new system with the same solutions:
by swapping equations
or
by multiplying through by a nonzero number
or
by adding one equation to another.
In terms of the augmented matrix, this means we may:
30
Elementary Transformations
 interchange two rows: Rj ↔ Rk
 multiply through by a nonzero number:
Rj ⟶ c × Rj
 add one row to another row: Rj ⟶ Rj + Rk.
 In fact, we often combine the last two transformations
so as to add a multiple of one row to another row:
 Rj ⟶ Rj + c × Rk
31
Example
 The system of linear equations gives
1 2 3 6000 
2 3 2 7000


1then
 give
1 R 2⟶4000
 R2 ⟶ R2 - 2R1 and
R
R
3
3
1
3 6000 
1 2
0  1  4  5000


0  1  1  2000 
32
Example
 R ⟶ (-1) R and then R ⟶ R + R give
2
2
3
3
2
1 2 3 6000 
0 1 4 5000


0 0 the
3 system
3000 of equations
 This matrix represents
x + 2y + 3z = 6000
y + 4z = 5000
3z = 3000
33
Example
with solutions x = 1000, y = 1000, and z = 1000.
 By using elementary transformations to reduce
the augmented matrix to echelon form.
 We get a new system of equations with the
same solutions as the original system.
 The technique is called Gaussian elimination.
34
No
Solutions?
 When the augmented matrix of a system of
linear equations in n unknowns is reduced to
echelon form, the last row may be of the form
[0 … 0 c] with c ≠ 0
 so that the corresponding equation is
0 x1 + …+ 0 xn = c
 which has no solution, because no matter
what values we substitute for the unknowns
x1, x2, …, xn
35
No
Solutions?
 The lefthand side still adds up to zero, whereas the
righthand side is nonzero.
 But if the last row has at least one nonzero coefficient
[0 …an c] where an ≠ 0
 Then the system has at least one solution, irrespective
of the value of c, since the final equation is
0x1 + …+ anxn = c
36
Infinitely Many Solutions
 Suppose our model was initially the system
x + 2y + 3z = 6000
2x + 3y + 2z = 7000
 which we reduced to echelon form to get
x + 2y + 3z = 6000
y + 4z = 5000
37
Infinitely Many Solutions
• Instead of a unique value for z, we can let z be
any real number t, and then get values for y and
x in terms of t, namely y = 5000 - 4t and
x = 6000 - 2(5000 - 4t) - 3t = 5t - 4000.
• We can produce specific solutions by giving t
specific values such as t = 0 (so that x = -4000,
y = 5000, and z = 0) and t = 1 (so that x =
-3995, y = 4996, and z = 1).
38
Homogeneous
Systems
 If the constants on the righthand side are all zero, as in
the system
x + 2y + 3z = 0
2x + 3y + 2z = 0
x + y + 2z = 0
then the system always has at least one solution, because
we may take x = y = z = 0.
 Such systems of equations are called homogeneous.
39
Homogeneous
Systems
 We need not use an augmented matrix to
represent a homogeneous system, since the
last column will consist entirely of zeros.
 Instead we may use the coefficient matrix in
which only the values of the coefficients of the
unknowns are displayed:
1 2 3 
 2 3 2


1 1 2
40
Rank
 The rank of a matrix is the number of nonzero
rows left after the matrix has been reduced to
echelon form.
 A system of linear equations has a solution iff
the rank of the augmented matrix is equal to
the rank of the coefficient matrix.
 Why?
41
Rank
 Because the only way for a system to
have no solutions is for the augmented matrix
in echelon form to have as its last nonzero row
[0 … 0 c] with c ≠ 0.
 But now the rank of the augmented matrix is
greater than the rank of the coefficient matrix.
 So if the ranks are equal, it means that this
case cannot arise
42