Matrices 1 - BCI

advertisement
Advanced Math 45S
Unit 3: Matrices 1
Unit 3: Matrices
1. Introduction
2. Matrix Addition (and Subtraction)
3. Matrix Multiplication
Introduction
A manufacturer of computer modems wants to organise some data pertaining to production so that it
can easily be processed by a computer.
Three models are being made as shown below
Number of Chips
Number of Switches
Model A
13
2
Model B
18
3
Model C
20
4
13 18 20
The numbers can be arranged as (
) in a “parts per modem” matrix
2
3
4
So a Matrix is a rectangular array of real numbers. Note the use of brackets around the matrix. We often
13 18 20
call a matrix by a (capital) letter, eg. P = (
)
2
3
4
The dimensions of a matrix is given as number of rows by number of columns. So our matrix above (P)
would be 2 by 3.
A matrix with only one row is called a row matrix. Eg (1
4 7) This is a 1 by 3 matrix
1
A matrix with only one column is called a column matrix. Eg ( 9 ) This is a 3 by 1 matrix
−2
Individual entries in a matrix can be identified using subscripts. i.e. x21 would refer to the number in the
2nd row and the first column.
π‘š11
𝑀 = (π‘š21
π‘š31
π‘š12
π‘š22 )
π‘š32
Example: Find m32 in the matrix below.
1 4
𝑀 = (−3 2
12 7
m32 means 3rd row, 2nd column so m32 = 7
Page 1 of 7
−7
14 )
6
Advanced Math 45S
Unit 3: Matrices 1
Square matrices are a little special.
A 2 by 2 matrix is called a square matrix with order 2.
A 3 by 3 matrix is called a square matrix with order 3.
A 4 by 4 matrix is called a square matrix with order 4. Etc.
Matrix Addition (and Subtraction)
Matrices can only be added if they are the same size.
Example: Given the matrices
1 7
3 −1 6
5 −3 −6
5
4 3
𝐴=(
),𝐡 = (
) , 𝐢 = (2 4 ) , 𝐷 = (
)
−2 4 3
−1 2 −2
−2 −4 1
4 −2
3 −1 6
8 −4 0
5 −3 −6
𝐴+𝐡 =(
)+(
)=(
)
−2 4 3
−3 6 1
−1 2 −2
Note that A11 is added to B11, A12 is added to B12 etc. thus the resulting matrix will have the same
dimensions as A and B.
Adding A and C makes no sense as there isn’t a C13 to add to A13 so A + C does not exist.
Note also that
3 −1 6
8 −4 0
5 −3 −6
𝐡+𝐴=(
)+(
)=(
)
−2 4 3
−3 6 1
−1 2 −2
Thus
A+B=B+A
The addition of matrices is communtative –i.e. changing the order of the matrices does not affect the
result.
Now consider( A + B) + D
3 −1 6
5 −3 −6
5
4 3
(𝐴 + 𝐡) + 𝐷 = [(
)+(
)] + (
)
−2 4 3
−1 2 −2
−2 −4 1
8 −4 0
13 0 3
5
4 3
=(
)+(
)= (
)
−3 6 1
−5 2 2
−2 −4 1
And A + (B + D)
3 −1 6
5 −3 −6
5
4
𝐴 + (𝐡 + 𝐷) = (
) + [(
)+(
−2 4 3
−1 2 −2
−2 −4
3 −1 6
10 1 −3
13 0
=(
)+(
)= (
−2 4 3
−3 −2 −1
−5 2
Thus (A + B) + D = A + (B + D)
Page 2 of 7
3
)]
1
3
)
2
Advanced Math 45S
Unit 3: Matrices 1
The addition of matrices is associative – i.e. Within an expression containing two or more occurrences in
a row of the same associative operator, the order in which the operations are performed does not
matter as long as the sequence of the operands is not changed. That is, rearranging the parentheses in
such an expression will not change its value
Associativity is not to be confused with commutativity. Commutativity justifies changing the order or
sequence of the operands within an expression while associativity does not.
Just like adding zero to a number doesn’t change the number, adding a zero matrix doesn’t change a
matrix. i.e.
1 2
0
(
)+(
3 4
0
0
1 2
)=(
)
0
3 4
The value 0 is called the identity element for the addition of matrices.
A negative matrix, or additive inverse matrix is found by negating each element of the inverse.
3 −1 6
𝐴=(
)
−2 4 3
−3 1 −6
−𝐴 = (
)
2 −4 −3
This is useful when it comes to subtracting matrices since
B – A = B + (-A)
−3 1 −6
2 −2 −12
5 −3 −6
𝑖. 𝑒. 𝐡 − 𝐴 = (
)+(
)=(
)
2 −4 −3
1 −2 −5
−1 2 −2
Note that A + (-A) results in the zero matrix
3 −1 6
−3 1 −6
0
(
)+(
)=(
−2 4 3
2 −4 −3
0
Assignment #1
Page 3 of 7
0 0
)
0 0
Advanced Math 45S
Unit 3: Matrices 1
Matrix Multiplication
If the elements in a column matrix represent the price of fast food items
π‘“π‘Ÿπ‘–π‘’π‘ 
1.50
𝑃 = (π‘π‘’π‘Ÿπ‘”π‘’π‘Ÿ) = (2.00)
1.00
π‘‘π‘Ÿπ‘–π‘›π‘˜
Each item has to have tax added on to it (PST and GST = 12%)
So amount of tax can be found by multiply each item by 0.12. As a matrix operation this looks like
0.18
1.50
𝑇 = 0.12 (2.00) = (0.24)
0.12
1.00
so the total cost of each item is given by:
0.18
1.68
1.50
𝐢 = 𝑃 + 𝑇 = (2.00) + (0.24) = (2.24)
0.12
1.12
1.00
another way of doing this would be to multiply the original matrix P by 1.12
1.68
1.50
𝐢 = 1.12 (2.00) = (2.24)
1.12
1.00
In general terms, if A and B are matrices and x and y are numbers
π‘Ž11
a) 𝐼𝑓 𝐴 = (π‘Ž
π‘Ž12
π‘₯π‘Ž11 π‘₯π‘Ž12
) π‘‘β„Žπ‘’π‘› π‘₯𝐴 = (π‘₯π‘Ž
)
π‘Ž
21
22
21 π‘₯π‘Ž22
i.e. each term in the matric is multiplied by the number
b)
c)
d)
e)
f)
g)
x(yA) = xy(A)
(x+y)A = xA + yA
(-1)A = -A
x(A+B) = xA + xB
π‘₯0 = 0 π‘€β„Žπ‘’π‘Ÿπ‘’ 0 𝑖𝑠 π‘‘β„Žπ‘’ π‘§π‘’π‘Ÿπ‘œ π‘šπ‘Žπ‘‘π‘Ÿπ‘–π‘₯
0𝐴 = 0
Back to our fast food problem!
Zach is feeling generous and is going to buy his friends lunch. Between them they want 5 fries, 3 burgers
and 4 drinks. To work this out using matrix operations we create a row matrix for the number of items in
the order.
𝑂 = (#π‘œπ‘“ π‘“π‘Ÿπ‘–π‘’π‘ 
#π‘œπ‘“ π‘π‘’π‘Ÿπ‘”π‘’π‘Ÿπ‘  #π‘œπ‘“ π‘‘π‘Ÿπ‘–π‘›π‘˜π‘ ) = (5 3
4)
To work out the total cost of the items we multiple the row matrix O by the column matrix C
Page 4 of 7
Advanced Math 45S
Unit 3: Matrices 1
𝑇 = 𝑂 × πΆ = (5 3
1.68
4) (2.24) = (19.60)
1.12
thus a 1 x 3 matrix multiplied by a 3 x 1 matrix results in a 1x1 matrix
Thomas thinks it is cheaper at a different fast food restaurant - $1.12 for fries, $1.96 for burgers and
$2.12 for drinks (including taxes).
We can create a matrix to represent the prices at both restaurants
1.68 1.12
𝐢 = (2.24 1.96)
1.12 2.12
so the multiplication becomes
𝑇 = 𝑂 × πΆ = (5
1.68 1.12
)
3 4 (2.24 1.96)
1.12 2.12
= (19.60 19.96)
As we can see, the 2nd restaurant was 36c more expensive
Talon wants to get in on the act and decides to buy his friends lunch as well. Between the students at
Major Pratt, they want 6 fries, 4 burgers and 3 drinks. This means that the order matrix changes to have
two rows, one for Zach’s order, the other for Talon’s:
Now
5 3
𝑂=(
6 4
4
)
3
Calculating the cost for both restaurants:
5 3
𝑇 =𝑂×𝐢 =(
6 4
1.68 1.12
19.60 19.96
4
) (2.24 1.96) = (
)
22.40 20.92
3
1.12 2.12
This time the second restaurant is cheaper than the first for Talon but Zachs order costs less than Talons
in both cases!
As you can see, the elements in row matrices multiple elements in a column matrix, resulting in 1
element in the resulting matrix
(π‘Ž11
π‘Ž12
1x3
Page 5 of 7
𝑏11
π‘Ž13 ) (𝑏21 ) = (π‘Ž11 𝑏11 + π‘Ž12 𝑏21 + π‘Ž13 𝑏31 )
𝑏31
3x1
1x1
Advanced Math 45S
Unit 3: Matrices 1
Example:
(3
5
−2 1) ( 2 ) = (3 × 5 + −2 × 2 + 1 × −1) = (10)
−1
This can be extended to larger matrices
π‘Ž11
(π‘Ž
21
π‘Ž12
π‘Ž22
𝑏11
π‘Ž13
𝑏
)
(
21
π‘Ž23
𝑏31
2x3
𝑏12
𝑏22 ) = (π‘…π‘œπ‘€1 × πΆπ‘œπ‘™1 π‘…π‘œπ‘€1 × πΆπ‘œπ‘™2)
π‘…π‘œπ‘€2 × πΆπ‘œπ‘™1 π‘…π‘œπ‘€2 × πΆπ‘œπ‘™2
𝑏32
3x2
2x2
Examples
−2 6
1
2 3
1 × −2 + 2 × 4 + 3 × −5
1 × 6 + 2 × −4 + 3 × 1
(
) ( 4 −4) = (
)
−1 −3 5
−1 × −2 + −3 × 4 + 5 × −5 −1 × 6 + −3 × −4 + 5 × 1
−5 1
−13 1
=(
)
−35 11
Note that when multiplying matrices the first matrix must have the same number of columns as the
number of rows in the second matrix resulting in a matrix with the same number of rows as the first
matric and the same number as columns as the second matrix.
Matrices that do not follow this rule can NOT be multiplied.
Eg a 2 x 3 matrix and a 2 x 6 matrix can not be multiplied together.
But a 4 x 5 matrix can be multiplied by a 5 x 2 matrix resulting in a 4 x 2 matrix.
In general, the multiplication of matrices is not commutative.
0
𝑖. 𝑒. 𝑖𝑓 𝐴 = (
1
0
0 1
) π‘Žπ‘›π‘‘ 𝐡 = (
)
0
0 0
then
0 0 0
𝐴𝐡 = (
)(
1 0 0
0
𝐡𝐴 = (
0
1
0 0
)=(
)
0
0 1
1 0 0
1 0
)(
)=(
)
0 1 0
0 0
so AB ≠ BA
The multiplication is associative: i.e. (AB)C = A(BC)
Page 6 of 7
Advanced Math 45S
Unit 3: Matrices 1
1 2
1 4
3 1
Using 𝐴 = (
),𝐡 = (
) π‘Žπ‘›π‘‘ 𝐢 = (
)
−1 3
−2 2
1 0
So
(𝐴𝐡)𝐢 = [( 1 2) ( 1 4)] (3
−1 3 −2 2
1
1
−3 8 3 1
−1 −3
)=(
)(
)=(
)
0
−7 2 1 0
−19 −7
1 2
1 4 3 1
1 2
7
1
−1 −3
𝐴(𝐡𝐢) = (
) [(
)(
)] = (
)(
)=(
)
−1 3
−2 2 1 0
−1 3 −4 −2
−19 −7
hence (AB)C=A(BC) i.e. multiplication is associative
Multiplication is Left Distributive. i.e. A(B+C) = AB + AC
1 2
1 4
3
𝐴(𝐡 + 𝐢) = (
) [(
)+(
−1 3
−2 2
1
1
1 2
2 9
4 5
)] = (
)(
)=(
)
0
−1 3 −1 2
−7 1
1 2
1 4
1 2 3
𝐴𝐡 + 𝐴𝐢 = (
)(
)+(
)(
−1 3 −2 2
−1 3 1
1
−3 8
2 9
5 1
)=(
)+(
)=(
)
0
−7 2
−7 1
0 −1
hence A(B+C) = AB + AC i.e. multiplication of matrices is left distributive
Multiplication is Right Distributive i.e. (B+C)A = BA + CA
1 4
3
(𝐡 + 𝐢)𝐴 = [(
)+(
−2 2
1
1
1 2
1 2
−1 23
4 5
)] (
)=(
)(
)=(
)
0
−1 3
−3 4
−1 2 −1 3
1 4
1 2
3 1
1 2
−3 14
2
𝐡𝐴 + 𝐢𝐴 = (
)(
)+(
)(
)=(
)+(
−2 2 −1 3
1 0 −1 3
−4 2
1
9
−1 23
)=(
)
2
−3 4
hence (C+B)A = CA + BA i.e. multiplication of matrices is right distributive
However, in general A(B+C) ≠ (B+C)A
1 2
1 4
3 1
1 2
2 9
4 5
𝐴(𝐡 + 𝐢) = (
) [(
)+(
)] = (
)(
)=(
)
−1 3
−2 2
1 0
−1 3 −1 2
−7 1
(𝐡 + 𝐢)𝐴 = [( 1 4) + (3
−2 2
1
1
1 2
1 2
−1 23
4 5
)] (
)=(
)(
)=(
)
0
−1 3
−3 4
−1 2 −1 3
hence A(B+C) ≠ (B+C)A
An interesting result from a multiplication is that the multiplication of two non-zero matrices can result
in the zero matrix.
3 1 −1 3
0
(
)(
)=(
6 2
3 −9
0
Assignment #2
Page 7 of 7
0
)
0
Download