Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 4 Rules of Matricies.

Similar presentations


Presentation on theme: "Lecture 4 Rules of Matricies."— Presentation transcript:

1 Lecture 4 Rules of Matricies

2 Addition and Subtraction of Matrices
To add or subtract matrices, they must be of the same order, m x n where m is the number of rows, and n is the number of columns. We always say the number of rows, then the number of columns in this order. To add matrices of the same order, add their corresponding entries. To subtract matrices of the same order, subtract their corresponding entries. The general rule is as follows using mathematical notation: The i represents the row number, and j the column number

3 Example: Addition Add the matrices

4 Example: Addition Solution
Add the matrices Solution: First note that each matrix has dimensions of 3x3, so we are able to perform the addition. The result is shown at right: Adding corresponding entries, we have

5 Example: Subtraction Now, we will subtract the same two matrices

6 Example: Subtraction Solution
Now, we will subtract the same two matrices Subtract corresponding entries as follows: =

7 Scalar Multiplication
The scalar product of a number k and a matrix A is the matrix denoted by kA, obtained by multiplying each entry of A by the number k. The number k is called a scalar. In mathematical notation,

8 Example: Scalar Multiplication
Find (-1)A, where A =

9 Example: Scalar Multiplication Solution
Find (-1)A, where A =

10 Alternate Definition of Subtraction of Matrices
The definition of subtraction of two real numbers a and b is a – b = a + (-1)b or “a plus the opposite of b”. We can define subtraction of matrices similarly: If A and B are two matrices of the same dimensions, then A – B = A + (-1)B, where (-1) is a scalar.

11 Example The example on the right illustrates this procedure for two 2x2 matrices.

12 Matrix Equations Example: Find a, b, c, and d so that

13 Matrix Equations Example: Find a, b, c, and d so that
Solution: Subtract the matrices on the left side: Use the definition of equality to change this matrix equation into 4 real number equations: a - 2 = 4 b + 1 = 3 c + 5 = -2 d - 6 = a = 6 b = 2 c = -7 d = 10

14 Product of a Row Matrix and a Column Matrix
In order to understand the general procedure of matrix multiplication, we will introduce the concept of the product of a row matrix by a column matrix. A row matrix (or ROW VECTOR) consists of a single row of numbers, while a column matrix (or COLUMN VECTOR) consists of a single column of numbers. If the number of columns of a row matrix equals the number of rows of a column matrix, the product of a row matrix and column matrix is defined. Otherwise, the product is not defined.

15 Row by Column Multiplication
Example: A row matrix consists of 1 row of 4 numbers so this matrix has four columns. It has dimensions 1 x 4. This matrix can be multiplied by a column matrix consisting of 4 numbers in a single column (this matrix has dimensions 4 x 1). 1x4 row matrix multiplied by a 4x1 column matrix. Notice the manner in which corresponding entries of each matrix are multiplied:

16 Matricies in Mathematica
When multiplying matricies in Mathematica, you have to use what is called the “Dot” operator, see RV.CV RV is 1x4 CV is 4x1, thus they are conformable, and result in a 1x1 (otherwise known as a scalar)

17 Pay attention to order Be careful however, as we will see, it REALLY matters what order you put things in when doing matrix mathematics Multiplying CV.RV, gives you a 4x4. Why?

18 Example: Revenue of a Car Dealer
A car dealer sells four model types: A, B, C, D. In a given week, this dealer sold 10 cars of model A, 5 of model B, 8 of model C and 3 of model D. The selling prices of each automobile are respectively $12,500, $11,800, $15,900 and $25,300. Represent the data using matrices and use matrix multiplication to find the total revenue.

19 Solution using Matrix Multiplication
We represent the number of each model sold using a row matrix (4x1), and we use a 1x4 column matrix to represent the sales price of each model. When a 4x1 matrix is multiplied by a 1x4 matrix, the result is a 1x1 matrix containing a single number.

20 Mathematica… you need the dot

21 Matrix Product (Conformity)
If A is an m x p matrix and B is a p x n matrix, the matrix product of A and B, denoted by AB, is an m x n matrix whose element in the i th row and j th column is the real number obtained from the product of the i th row of A and the j th column of B. If the number of columns of A does not equal the number of rows of B, the matrix product AB is not defined. Very easy to keep track of if you always write down the matrix dimensions. Inner numbers must be equal, outer numbers give you new matrix size with m rows and n columns

22 Premultiply and Postmultiply are not the same (noncommutative)
Premultiply A by B means BA Postmultiply A by B means AB

23 Multiplying a 2x4 matrix by a 4x3 matrix to obtain a 2x3
The following is an illustration of the product of a 2x4 matrix with a 4x3. (Note 4=4, and 2x3 is new matrix dimension. First, the number of columns of the matrix on the left must equal the number of rows of the matrix on the right, so matrix multiplication is defined. A row-by column multiplication is performed three times to obtain the first row of the product:

24 Final Result

25 Undefined Matrix Multiplication
Why is the matrix multiplication below not defined? 4 by 3 and a 2 by 4. 3 is not 2… can’t proceed!

26 Undefined Matrix Multiplication Solution
Why is the matrix multiplication below not defined? The answer is that the left matrix has three columns but the matrix on the right has only two rows. To multiply the second row [4 5 6] by the third column, 3 , there is no number to pair with 6 to multiply

27 Example Given A = B = Find AB if it is defined: 3=3 2x2 is new size

28 Solution Since A is a 2 x 3 matrix and B is a 3 x 2 matrix, AB will be a 2 x 2 matrix. 1. Multiply first row of A by first column of B: 3(1) + 1(3) +(-1)(-2)=8 2. First row of A times second column of B: 3(6)+1(-5)+ (-1)(4)= 9 3. Proceeding as above the final result is =

29 Is Matrix Multiplication Commutative?
Now we will attempt to multiply the matrices in reverse order: BA = ? We are multiplying a 3 x 2 matrix by a 2 x 3 matrix. This matrix multiplication is defined, but the result will be a 3 x 3 matrix. Since AB does not equal BA, matrix multiplication is not commutative. =

30 Transposes of Matricies
Now, we will find the Transpose of the matrix. You just make the rows into columns. If it is a column vector, it becomes a row vector, and vice versa It is denoted by a PRIME or what you see as an apostrophe.

31 Rules of Transpose (A’)’=A (A+B)’=A’+B’ (AB)’=B’A’
The third is the most confusing, but most important!!! We use this property quite a bit in economics

32 Practical Application
Suppose you a business owner and sell clothing. The following represents the number of items sold and the cost for each item. Use matrix operations to determine the total revenue over the two days: Monday: 3 T-shirts at $10 each, 4 hats at $15 each, and 1 pair of shorts at $20. Tuesday: 4 T-shirts at $10 each, 2 hats at $15 each, and 3 pairs of shorts at $20.

33 Solution of Practical Application
Represent the information using two matrices: The product of the two matrices gives the total revenue: Then your total revenue for the two days is = [110   130] Price times Quantity = Revenue Qty sold of each item on Monday Unit price of each item: Qty sold of each item on Tuesday

34 Identity Matrix for Multiplication
1 is called the multiplicative identity for real numbers since a(1) = (1)a = a For example 5(1) = 5 A matrix is called square if it has the same number of rows and columns, that is, it has size n x n. The set of all square matrices of size n x n also has a multiplicative identity In, with the property AIn = InA = A In is called the n x n identity matrix.

35 Identity Matrices 2 x 2 identity matrix: 3 x 3 identity matrix

36 Identity Matrix Multiplication
AI = A (Verify the multiplication) We can also show that IA = A and in general AI = IA = A for all square matrices A.

37 Inverse of a Matrix All real numbers (excluding 0) have an inverse.
For example .

38 Matrix Inverses Matrix must be square to have an inverse
Some (not all) square matrices also have matrix inverses If the inverse of a matrix A exists, we shall call it A-1 Then Notice this is ‘commutative’ and a square multiplied by it’s inverse is equal to the identity matrix. More specifically, the equation to find an inverse is 1/determinant of A, multiplied by the adjoint (or minor) of A. Determinants? Adjoints?

39 This formula comes in handy

40 Rules of Matrix Inversion
The second rule here is the most frequently used. It’s really important you get the order correct.

41 Inverse of a 2x2 Matrix, formulaic
There is a simple procedure to find the inverse of a two by two matrix. This procedure only works for the 2 x 2 case. An example will be used to illustrate the procedure. Example: Find the inverse of

42 Inverse of a 2x2 matrix (memorize)
Step 1: Determine whether or not the inverse actually exists. We define Δ = the determinant of the matrix. In order for the inverse of a 2 x 2 matrix to exist, Δ cannot equal zero. (We will call this a determinant) If Δ happens to be zero, then we conclude the inverse does not exist, and we stop all calculations. In our case Δ = 2(2)-1(3) = 1, so we can proceed. Det[] finds the matrix determinant ad-bc for a 2x2

43 Inverse of a 2x2 matrix (continued)
Step 2. Reverse the entries on the main diagonal. In this example, both entries are 2, and no change is visible. Step 3. Reverse the signs of the other diagonal entries 3 and 1 so they become -3 and -1 Step 4. Divide each element of the matrix by the ‘determinant’ which in this case is 1, so no apparent change will be noticed.

44 Inverse of a 2x2 matrix (continued)
The inverse of the matrix is then To verify that this is the inverse, we will multiply the original matrix by its inverse and hopefully obtain the 2 x 2 identity matrix: =

45 General 2x2 Matrix Inversion

46 Adjoint (Minors and Cofactors)
The adjoint is defined as a matrix of ‘cofactors’ (see the C) which are determinants of minor matricies multiplied by negative 1 if the sum of R&C is odd The minor of element a11 below is

47 First, a 2x2

48 Example: Inverse of a 3x3 Matrix
Find the inverse of Start by finding the determinant of the matrix (expand along first column 1((1)(1)-(2)(-2)) + (-1)2((-1)(1)-(3)(-2)) + (-2)((-1)(2)-(3)(1)) = 1(5)+-2(5)+(-2)(-5) = 5. The first term in the formula is 1/|A| = 1/5 or 0.2.

49

50

51 Inverse of a General Square Matrix
1. Augment the matrix with the n x n identity matrix. 2. Use elementary row operations to transform the matrix on the left side of the vertical line to the n x n identity matrix. The row operations are used for the entire row, so that the matrix on the right hand side of the vertical line will also change. 3. When the matrix on the left is transformed to the n x n identity matrix, the matrix on the right of the vertical line is the inverse.

52 Example: Inverse of a 3x3 Matrix
Find the inverse of Step 1. Multiply R1 by (-2) and add the result to R2. Step 2. Multiply R1 by 2 and add the result to R3

53 Example (continued) Step 3. Multiply row 2 by (1/3) to get a 1 in the second row, first position. Step 4. Add R2 to R1. Step 5. Multiply R2 by 4 and add the result to R3. Step 6. Multiply R3 by 3/5 to get a 1 in the third row, third position.

54 Example (continued) Step 7. Eliminate the (5/3) in the first row, third position by multiplying R3 by (-5/3) and adding result to R1. Step 8. Eliminate the (-4/3) in the second row, third position by multiplying R3 by (4/3) and adding result to R2. Step 9. You now have the identity matrix on the left, which is our goal.

55 Example Solution The inverse matrix appears on the right hand side of the vertical line and is displayed below. Many calculators as well as computers have software programs that can calculate the inverse of a matrix quite easily.

56 Determinant and Inverse of 3x3 GENERAL
Rearrangement of the Mathematica output in the second line you should see a(ei-fh) + b(ei-fg) + c(dh-ge). This is called ‘expanding’ along the first row, and multiplying by the ‘sub-determinants’ or determinant of the matrix made up of those values that are not in the same row or column as your expansion term…

57 Cramer’s Rule Cramer’s Rule, extends from the previous method of inversion using the adjoint (or transpose of the cofactor matrix… or more thoroughly the transpose of the matrix of minor determinants), to a system of equations. If we have a problem, such as Ax=d where x is a column vector of unknowns, and d is a column vector of answers, we can find xi by replacing the ith column of A with the values from d, take the determinant, and then divide it by the determinant of A

58 Cramer’s Rule Generally… x*j is the solution to the jth variable.
x*j is found by

59 Cramer’s Rule in Mathematica

60 Matrix Equations Let’s review one property of solving equations involving real numbers. Recall If ax = b then x = , or A similar property of matrices will be used to solve systems of linear equations. Many of the basic properties of matrices are similar to the properties of real numbers, with the exception that matrix multiplication is not commutative.

61 Basic Properties of Matrices
Assuming that all products and sums are defined for the indicated matrices A, B, C, I, and 0, we have Addition Properties Associative: (A + B) + C = A + (B+ C) Commutative: A + B = B + A Additive Identity: A + 0 = 0 + A = A Additive Inverse: A + (-A) = (-A) + A = 0

62 Basic Properties of Matrices (continued)
Multiplication Properties Associative Property: A(BC) = (AB)C Multiplicative identity: AI = IA = A Multiplicative inverse: If A is a square matrix and A-1 exists, then AA-1 = A-1A = I Combined Properties Left distributive: A(B + C) = AB + AC Right distributive: (B + C)A = BA + CA

63 Basic Properties of Matrices (continued)
Equality Addition: If A = B, then A + C = B + C Left multiplication: If A = B, then CA = CB Right multiplication: If A = B, then AC = BC The use of these properties is best illustrated by an example of solving a matrix equation. Example: Given an n x n matrix A and an n x p matrix B and a third matrix denoted by X, we will solve the matrix equation AX = B for X.

64 Solving a Matrix Equation
Reasons for each step: Given; since A is n x n, X must by n x p. Multiply on the left by A-1. Associative property of matrices Property of matrix inverses. Property of the identity matrix Solution. Note A-1 is on the left of B. The order cannot be reversed because matrix multiplication is not commutative.

65 Example Example: Use matrix inverses to solve the system

66 Example Example: Use matrix inverses to solve the system Solution:
Write out the matrix of coefficients A, the matrix X containing the variables x, y, and z, and the column matrix B containing the numbers on the right hand side of the equal sign.

67 Example (continued) Form the matrix equation AX = B. Multiply the 3 x 3 matrix A by the 3 x 1 matrix X to verify that this multiplication produces the 3 x 3 system at the bottom:

68 Example (continued) If the matrix A-1 exists, then the solution is determined by multiplying A-1 by the matrix B. Since A-1 is 3 x 3 and B is 3 x 1, the resulting product will have dimensions 3 x 1 and will store the values of x, y and z. A-1 can be determined by the methods of a previous section or by using a computer or calculator. The resulting equation is shown at the right:

69 Example Solution The product of A-1 and B is The solution can be read off from the X matrix: x = 0, y = 2, z = -1/2 Written as an ordered triple of numbers, the solution is (0, 2, -1/2)

70 Doing this using Mathematica

71 Another Example Example: Solve the system on the right using the inverse matrix method. You can enter this in Mathematica the old way as well if you desire. Notice, that this won’t work, what is Mathematica telling us?

72 Another Example Example: Solve the system on the right using the inverse matrix method. Solution: The coefficient matrix A is displayed at the right. The inverse of A does not exist. (We can determine this by using a calculator.) We cannot use the inverse matrix method. Whenever the inverse of a matrix does not exist, we say that the matrix is singular. We can figure this out because the determinant of this matrix is ZERO

73 Singular Matrix For matrix Determinant is 1((-1)*3-2*1)+ 2(2*3-2*3)+
1(2*1-(-1)*3) OR -5+0+5=0… This is singular Try expanding along the second row, or second column… always the same Determinant is ZERO For a system to be solvable… it must have a NON-ZERO DETERMINANT Also called “NONSINGULAR”

74 Cases When Matrix Techniques Do Not Work
There are two cases when inverse methods will not work: 1. If the coefficient matrix is singular 2. If the number of variables is not the same as the number of equations.

75 Application Production scheduling: Labor and material costs for manufacturing two guitar models are given in the table below: Suppose that in a given week $1800 is used for labor and $1200 used for materials. How many of each model should be produced to use exactly each of these allocations? Guitar model Labor cost Material cost A $30 $20 B $40

76 Solution Let x be the number of model A guitars to produce and y represent the number of model B guitars. Then, multiplying the labor costs for each guitar by the number of guitars produced, we have 30x + 40y = 1800 Since the material costs are $20 and $30 for models A and B respectively, we have 20x + 30y = 1200. This gives us the system of linear equations: 30x + 40y = x + 30y = 1200 We can write this as a matrix equation:

77 Solution (continued) Solution: Produce 60 model A guitars and no model B guitars. The inverse of matrix A is

78 Leontief Input-Output Analysis
In this section, we will study an important economic application of matrix inverses and matrix multiplication. This branch of applied mathematics is called input-output analysis and was first proposed by Wassily Leontief, who won the Nobel Prize in economics in 1973 for his work in this area.

79 Wassily Leontief (continued)
At Harvard, he developed his theories and methods of Input-Output analysis. This work earned him the Nobel prize in Economics in 1973 for his analysis of America's production machinery. His analytic methods, as the Nobel committee observed, became a permanent part of production planning and forecasting in scores of industrialized nations and in private corporations all over the world. Professor Leontief passed away on Friday February 6th, For more information on his life, visit

80 Basic Input-Output Problem
The main problem of input-output analysis is the following: Consider an economy with several industries. Each industry has a demand for products from other instrustries (internal demand). There are also external demands from the outside. Find a production level for the industries that will meet both internal and external demands.

81 Two-Industry Model Example
We start with an economy that has only two industries (agriculture and energy) to illustrate the method. Later, this method will generalized to three or more industries. These two industries depend upon each other. For example, each dollar’s worth of agriculture produced requires $0.40 of agriculture and $0.20 of energy. Each dollar’s worth of energy produced requires $0.20 of agriculture and $0.10 of energy. So, both industries have an internal demand for each others resources. Let us suppose there is an external demand of $12,000,000 of agriculture and $9,000,000 dollars of energy.

82 Example: Matrix Equations
Let x represent the total output from agriculture and y represent the total output of energy (in millions of $) The expressions 0.4x + 0.2y 0.2x + 0.1y can be used to represent the internal demands for agriculture and energy. The external demands of 12 and 9 million must also be met, so the revised equations are : x = 0.4x + 0.2y + 12 y = 0.2x + 0.1y + 9 These equations can be represented by the following matrix equation:

83 Example:Technology Matrix (M )
Read left to right, E then up A = M E

84 Example: Solving the Matrix Equations
We can solve this matrix equation as follows: X = MX+D X – MX = D IX – MX = D (I – M)X = D if the inverse of (I – M) exists.

85 Example: Solution We will now find First, find (I – M):
The inverse of (I – M) is:

86 Solution (continued) After finding the inverse of (I – M), multiply that result by the external demand matrix D. The answer is: Produce a total of $25.2 million of agriculture and $15.6 million of energy to meet both the internal demands of each resource and the external demand.

87 Another Example Suppose consumer demand changes from $12 million dollars of agriculture to $8 million dollars and energy consumption changes from $9 million to $5 million. Find the output for each sector that is needed to satisfy this final demand.

88 Example (continued) Suppose consumer demand changes from $12 million dollars of agriculture to $8 million dollars and energy consumption changes from $9 million to $5 million. Find the output for each sector that is needed to satisfy this final demand. Solution: Recall that our general solution of the problem is The only change in the problem is the external demand matrix. (I – M) did not change. Therefore, our solution is to multiply the inverse of (I –M) by the new external demand matrix D.

89 Example Solution

90 More Than Two Sectors of the Economy
This method can also be used if there are more than two sectors of the economy. If there are three sectors, say agriculture, building and energy, the technology matrix M will be a 3 x 3 matrix. The solution to the problem will still be although in this case it is necessary to determine the inverse of a 3 x 3 matrix.

91 Example: Three-Industry Model
An economy is based on three sectors, agriculture (A), energy (E), and manufacturing (M). Production of a dollar’s worth of agriculture requires an input of $0.20 from the agriculture sector and $0.40 from the energy sector. Production of a dollar’s worth of energy requires an input of $0.20 from the energy sector and $0.40 from the manufacturing sector. Production of a dollar’s worth of manufacturing requires an input of $0.10 from the agriculture sector, $0.10 from the energy sector, and $0.30 from the manufacturing sector. Find the output from each sector that is needed to satisfy a final demand of $20 billion for agriculture, $10 billion for energy, and $30 billion for manufacturing.

92 Example (continued) The technology matrix is as follows: Output A E Ma
Input

93 Example (continued) Thus, the output matrix X is given by:
X (I - M) D An output of $33 billion for agriculture, $37 billion for energy, and $64 billion for manufacturing will meet the given final demands.


Download ppt "Lecture 4 Rules of Matricies."

Similar presentations


Ads by Google