Math 2524: Activity 3 (Excel and Matrices, continued) Fall

Math 2524: Activity 3 (Excel and Matrices, continued)
Fall 2002
Inverse of a Matrix:
This activity will illustrate how Excel can help you find and use the inverse of a matrix. It will also
discuss a matrix function called the determinant and a method called Cramer's Rule that uses
determinants to solve systems of equations.
Example 1: (part 1 - do not type into Excel, just read through this example)
Given the following matrix A, find A-1.
A=
1
0
2
-2
1
-1
3
0
3
In this example you will be shown the results of finding the inverse of the matrix by hand using row
reduction. You have learned (or will soon learn) in the class lectures how to do this.
Since A is a square 3x3 matrix, it is possible that A-1 exists. First create a 3x6 matrix composed of matrix A
on the left augmented with the I3 on the right. This is illustrated by matrix C below.
C=
1
0
2
-2
1
-1
3
0
3
1
0
0
0
1
0
0
0
1
Row-reduce the augmented matrix, making sure that the final matrix is in reduced row echelon form. If the
left side half of the matrix looks like the 3x3 identity matrix, the right side of the matrix will contain A-1. If
the left side of the matrix has either a row or a column consisting of all zeros then the inverse does not
exist. Below is the matrix C in reduced row echelon form. Can you find the inverse of A? To test your
guess, multiply the matrix A and its inverse to see if you get the identity matrix I.
1
0
0
-1
-1
1
0
1
0
0
1
0
0
0
1
2/3
1
-1/3
Be sure you understand the above process for finding the inverse matrix.
Now you will learn the Excel command to give you the inverse quickly.
Example 1: (part 2 – work this and following examples in Excel as you read through this problem)
Enter matrix A into your spreadsheet. Since A is a 3x3 matrix, its inverse will also be a 3x3 matrix. Choose
the position where you want the inverse to appear. In a cell immediately to the left of this position, enter
the label "A^(-1)=". Highlight the 3x3 block of cells that will contain the inverse and type the following
command: =minverse(B1:D3). Next press the Shift-Ctrl-Enter keys(or Apple-Enter) simultaneously.
Your results should resemble the following.
A^(-1)=
-1
0
0.666
-1
1
1
0
1 -0.333
Page 1 of 5
Math 2524: Activity 3 (Excel and Matrices, continued)
Fall 2002
Now we will look at an example using the inverse to solve a system of equations in the form AX=B.
Example 2:
Consider the system:
X
-
2X
-
2Y
Y
Y
+
3Z
+
3Z
=
=
=
4
-3
1
Notice that the coefficient matrix A is the same matrix that we used above so we have already found the
inverse. Now you only need to enter the 3x1 matrix B into your spreadsheet and perform matrix
multiplication to find the solution: X = (A-1)*B. The commands used are: =minverse(B1:D3) (to find
the inverse) and =mmult(B5:D7, B9:B11) (to perform the multiplication).
A=
A-1=
1
0
2
-2
1
-1
3
0
3
-1
0
0.666
-1
1
1
1
0
-0.333
B=
4
-3
1
X=
0
-3
-0.666
NOTE:
In your final answers you often will have unwieldy decimal answers. You may wish to reduce the number
of decimal places. Simply go to the decimal icons and click on the icon until you have the decimal
representation you want. You may also highlight the cells and go to Format-Cells-Number and select the
desired number of decimal places. Often you will have a value that looks something like 374E-16. This is
scientific notation for the value .0000000000000000374 which is essentially the zero value. You may
wish to replace this value with zero BUT you must be careful. First you must convert your “commands”
to actual numerical values. As in the last activity, highlight the entire matrix and go to Edit and then
Copy. With the same block of cells still highlighted, choose Edit and Paste special. A dialogue box will
appear. You should click on values and then OK. This converts all cells to regular numerical values and
allows you to delete a value and replace it with another value such as zero.
Page 2 of 5
Math 2524: Activity 3 (Excel and Matrices, continued)
Fall 2002
Problems to be handed in: (Using Excel’s inverse command to solve systems of equations)
1. Consider the system of equations
.25x1 − .25x 2 + .5x 3 + .75x4 =
3
.5x1 + .5x 2
+ .5x4 =
2
x1
+. .25x 2 − .25x 3 − .25x4 = −2
.25x1 + .5x 2 + .75x 3
= −1.5
Use Excel to perform the following operations. Identify your matrices by labeling as in the examples
shown in the introduction.
(a) Define the coefficient matrix (not augmented) to be matrix A.
(b) Define the column matrix of constants to be matrix B.
(c) Find A-1.
(d) Solve the system using A-1 by multiplying A-1B.
(e) Clearly state the solution to the system.
2. An electronics company produces transistors, resistors, and computer chips. Each transistor requires
3 units of copper, 1 unit of zinc, and 2 units of glass. Each resistor requires 3, 2, and 1 units of the
three materials, respectively; and each computer chip requires 2, 1, and 2 units of these materials,
respectively. This information may be easier to read by putting it into a table.
copper
transistors  3
 3
resistors
comp.chips  2
zinc
1
2
1
glass
2 
1 
2 
The supply of these materials varies from week to week, so the company needs to determine a
different production run each week, based on the supplies available. Suppose that for the week
beginning October 11 the total amounts of materials available are 810 units of copper, 410 units of
zinc, and 490 units of glass. A system of equations is set up to model the production run:
3x1 + 3x2

1x1 + 2x2
2x + 1x
 1
2
+ 2x3
+ 1x3
+ 2x3
= 810
= 410
= 490
Note that the equations in this system do not represent the rows of the table, but the columns. When
information is in a table, it may or may not be used in exactly that position. Because the amount of
copper available is 810 units, the total copper used must add up to that amount, which requires
looking at the copper column.
Page 3 of 5
Math 2524: Activity 3 (Excel and Matrices, continued)
Fall 2002
To solve the system and find the production run for the first week, the method of solution will use the
inverse of the coefficient matrix. This will also allow future production runs to be quickly determined.
(a) The symbol definition for the system is given above. Tell what the variables x1, x 2, and x 3
represent and give the verbal definition for the first equation of the system. That is, describe in
words the exact information that the equation is relating to you.
(b) Solve the system by following the same steps as a) - e) in problem 1). Write the solution in the
form of a brief memo to the production line supervisor from the department manager (you). A few
short sentences will suffice, typed beside your work in Excel.
(c) For the week beginning October 18 you again have to decide the production run. This time the
total amounts available are 700 units of copper, 380 units of zinc, and 450 units of glass. On
scratch paper, write the system that must be solved and look at similarities with the first system.
Solve, using the inverse. Whenever possible, use your work from previous steps. Do not
duplicate your previous work. Write another memo for the new information.
3. Use Excel to solve problem #38, page 270 in your text.
4. Use Excel to solve problem #57, page 270-271 in your text.
Determinants and Cramer’s Rule:
Another matrix concept that is very important is the determinant. This is a tool that can come in very
handy. In this example will discuss two uses for it.
Example 3:
3 3
Does the Matrix C =  1 2
 2 1
2
1 have an inverse?
2
If the matrix is a square matrix, it may have an inverse. You can use the Excel’s determinant command to
determine if an inverse exists. If the value of the determinant is zero then the answer is NO, there is no
inverse for the matrix. If the value the determinant is not zero, then the answer is YES and the inverse does
exist. In order to use Excel to find the determinant, type the matrix into your spreadsheet. Highlight one
empty cell and type in the command =mdeterm(B1:D3) (assuming that your matrix C was entered into
the cell block defined by B1:D3) and hit Shift-Ctrl-Enter ( or Apple-Enter). The actual determinant for
C is given by det(C) = 3. Verify this value yourself with Excel.
Determinants can be used to solve a system of equations if the coefficient matrix of the system has an
inverse.
Page 4 of 5
Math 2524: Activity 3 (Excel and Matrices, continued)
Fall 2002
Example 4:
The following system is the system of equations from problem 2 in the “Problems to be handed in” set
above:
3x1 + 3x2

1x1 + 2x2
2x + 1x
 1
2
+ 2x3
+ 1x3
+ 2x3
= 810
= 410
= 490
Below are several determinants associated with this system. Can you see the pattern used to create the
determinants? Notice the determinant array is always written with straight sides instead of the square
brackets used for matrices.
3 3 2
A= 1 2 1
2 1 2
810 3 2
C = 410 2 1
490 1 2
3 810
D = 1 410
2 490
2
1
2
3 3
E= 1 2
2 1
810
410
490
In order to solve the system you will set up your unknowns as follows:
x1= C/A
x2 = D/A
x3 = E/A
Use Excel to find the values of each of the determinants A, C, D, E. Plug in these values into the
appropriate equations from above to find x1, x2 and x3. Did you get the same solution for this system as
before? This method of solving a system of equations is called Cramer’s Rule.
Problems to be handed in: (continued)
5. Use Excel to complete problem #47 on page 270 in your text.
6. Use Excel and Cramer's Rule to redo Example 4) using the value changes given in problem #2, part for
the constants: 700, 380 & 450.
Page 5 of 5