Using Microsoft Excel to Perform Matrix Operations

Math Analysis Honors
Ch 12 Matrices in Excel WS
1.
Read the instructions “Using Microsoft Excel to Perform Matrix Operations”
2. Open up Microsoft Excel.
Save the open workbook as Matrices your name(s) ex: Matrices Jimbo Smith .
3. Notice that there are tabs at the bottom labeled Sheet 1, Sheet 2, and Sheet 3. Clicking these tabs
toggles between the different “sheets” that make up the workbook. Right-click on a sheet label to
rename it, click the far right sheet tab to add a new sheet.
Add a sheet so there are 4 sheets.
4. Rename Sheet 1 as Basic Operations. Type your name(s) in a cell at the top of the sheet. Create the
following matrices in this sheet:
𝐴=�
2 5 −3
�
1 0 −4
3 9
𝐵=�
−1 2
2 −5
−7
� 𝐶 = �4 0 �
10
7 1
then in the sheet also display the results of :
𝐴+𝐵
𝐵−𝐴
5∗𝐴
𝐵𝐶
3
0 1
𝐷 = �−5 2 6�
4 −8 7
determinant of 𝐷
inverse of 𝐷
Make the sheet look nice by boxing and labeling the matrices. Add color to the outlines and/or cells.
5.
Rename Sheet 2 as Solving Systems. In this sheet solve the following systems of equations using
inverse matrices.
For each problem display the coefficient matrix, the determinant of the coefficient matrix, the inverse of
the coefficient matrix, the constant matrix, and the solutions matrix.
Make the sheet look nice by boxing and labeling the problems and the matrices. Add color to the
outlines and/or cells.
a. 3𝑥 + 8𝑦 − 𝑧 = −18
2𝑥 + 𝑦 + 5𝑧 = 8
2𝑥 + 4𝑦 + 2𝑧 = −4
6.
b. 5𝑥 − 3𝑦 + 2𝑧 = 12
2𝑥 + 4𝑦 − 3𝑧 = −9
4𝑥 − 2𝑦 + 5𝑥 = 13
Rename Sheet 3 as Word Problems. In this sheet set up matrices to solve the word problems
described on the Word Problems WS. For each problem display the coefficient matrix, the determinant
of the coefficient matrix, the inverse of the coefficient matrix, the constant matrix, and the solutions
matrix.
Make the sheet look nice by boxing and labeling the problems and the matrices. Add color to the
outlines and/or cells.
7.
Rename Sheet 4 as Food Web. In this sheet set up matrices as described in the Food Web WS.
Answer questions in text boxes that are inserted in the sheet. Make the sheet look nice!
Using Microsoft Excel to Perform Matrix Operations
Purpose: This tutorial was created to provide you with step-by-step instructions on how to
perform various matrix (array) operations using Microsoft Excel. Although this
tutorial was created using the screen shots from Excel 2007, the instructions given
should be able to be completed using Excel 2010 without too much difficulty.
Many of the Microsoft Excel functions that you will be using to complete these matrix operations are
array functions – returning more than one value at a time. To enter an array function into a Microsoft
Excel worksheet, you must hold down the CRTL and the SHIFT keys while pressing the ENTER key:
CRTL+SHIFT+ENTER. Once this is done, braces will surround the array formula.
What will be discussed through this tutorial?
 How to organize (enter) data into matrices. (page 1)
 How to add matrices. (page 2)
 How to subtract matrices. (page 2)
 How to find the transpose of a matrix. (page 2)
 How to multiply a matrix by a scalar (real number). (page 3)
 How to multiply two matrices. (page 3)
 How to find the inverse of a square matrix. (page 3)
 How to find the determinant of a square matrix. (page 4)
 How to use inverse matrices to solve systems of equations. (pages 4-5)
How to organize (enter) data into matrices:
A computer spreadsheet is a series of small blocks (cells) where the columns are
labeled with capital letters and the rows are labeled by numbers. To enter a matrix
into Microsoft Excel, simply type each matrix element into its own small block (cell).
Suppose that we wish to enter:
1 2 3 


4 5 6
7 8 9 
...
As seen in the given diagram above, just type:
“1” into a cell A2
“4” into a cell A3
“7” into a cell A4
“2” into a cell B2
“5” into a cell B3
“8” into a cell B4
“3” into a cell C2
“6” into a cell C3
“9” into a cell C4
NOTE #1: Pressing ENTER after each entry will usually make the cursor go down to the next cell.
Pressing the RIGHT ARROW key after each entry will make the cursor move to the next cell to the
right.
NOTE #2: The default direction is down, but you can change the direction in which the cursor moves
through the EXCEL OPTIONS dialog box . . .
Microsoft Office Button → Excel Options → Advanced → Editing Options
Monmouth University
Mathematics Department
instructor: Donna M. Wacha
Matrix (Array) Operations
How to add matrices:
page 2 of 5
1 2 3  10 11 12

 

 4 5 6  + 13 14 15 
7 8 9  16 17 18 
Step-by-Step Instructions:
1. Enter the data of each matrix onto the worksheet.
2. Highlight another section of the worksheet that
has the same dimensions as the answer matrix.
NOTE: The sum of [A] + [B] will be the same dimensions as both [A] and [B], or 3x3.
Therefore, the cells I2 through K4 have been highlighted in the given diagram.
3. Type: =(A2:C4)+(E2:G4) (This will appear in the formula bar.)
4. Since this answer will result in an array (matrix), you will need to: CRTL+SHIFT+ENTER
(NOTE: Braces will surround the formula indicating that it is an array formula.)
How to subtract matrices:
1 2 3   9 8 7 

 

4 5 6  - 6 5 4 
7 8 9   3 2 1 
Step-by-Step Instructions:
1. Enter the data of each matrix onto the worksheet.
2. Highlight another section of the worksheet that
has the same dimensions as the answer matrix.
NOTE: The difference of [A] – [B] will be the same dimensions as both [A] and [B], or 3x3.
Therefore, the cells I2 through K4 have been highlighted in the given diagram.
3. Type: =(A2:C4)–(E2:G4) (This will appear in the formula bar.)
4. Since this answer will result in an array (matrix), you will need to: CRTL+SHIFT+ENTER
(NOTE: Braces will surround the formula indicating that it is an array formula.)
How to find the transpose of a matrix:
1 2 


3 4
 5 6 
Step-by-Step Instructions:
1. Enter the data of the given matrix onto the worksheet.
2. Highlight another section of the worksheet that has the
dimensions as the answer matrix.
NOTE: Since we are finding the transpose of a 3x2 matrix, the answer will be a 2x3 matrix.
Recall that the transpose of a matrix swaps the given rows for columns and the given columns
for rows. So, if the given matrix as an order of RxC then its transpose will have an order of CxR.
3. Type: =TRANSPOSE(A2:B4) (This will appear in the formula bar.)
4. Since this answer will result in an array (matrix), you will need to: CRTL+SHIFT+ENTER
(NOTE: Braces will surround the formula indicating that it is an array formula.)
Monmouth University
Mathematics Department
instructor: Donna M. Wacha
Matrix (Array) Operations
page 3 of 5
How to multiply a matrix by a scalar (real number):
1 2 3


4 5 6
3
7 8 9


10 11 12 
Step-by-Step Instructions:
1. Enter the data of the given matrix onto the worksheet.
2. Highlight another section of the worksheet that has the
dimensions as the answer matrix.
NOTE: Since we are multiplying a 4x3 matrix by the scalar,
the answer will be a 4x3 matrix.
3. Type: =3*(A2:C5) (This will appear in the formula bar.)
4. Since this answer will result in an array (matrix), you will need to: CRTL+SHIFT+ENTER
(NOTE: Braces will surround the formula indicating that it is an array formula.)
How to multiply two matrices:
 1 2 3  1 2 3 4 

 

 4 5 6  × 5 6 7 8 
7 8 9  9 10 11 12 
Step-by-Step Instructions:
1. Enter the data of each matrix onto the
worksheet.
2. Highlight another section of the worksheet
that has the dimensions as the answer matrix.
NOTE: Since we are multiplying a 3x3 matrix by a 3x4 matrix, the answer will be a 3x4 matrix.
3. Type: =MMULT(A2:C4, E2:H4) (This will appear in the formula bar.)
4. Since this answer will result in an array (matrix), you will need to: CRTL+SHIFT+ENTER
(NOTE: Braces will surround the formula indicating that it is an array formula.)
NOTE: Recall that multiplication of matrices is NOT commutative. So, if we reversed the two
matrices (BA), we would be attempting to multiply a 3x4 matrix by a 3x3 matrix. Since the two
middle numbers do not match, the multiplication cannot be completed.
How to find the inverse of a square matrix: If A =
2 5 4 


1 4 3  ,
1 -3 -2 
find A–1.
1. Enter the data of the given matrix onto the worksheet.
2. Highlight another section of the worksheet that has the
dimensions as the answer matrix.
NOTE: Since we are finding the inverse of a 3x3 matrix, its
inverse will be a 3x3 matrix.
3. Type: =MINVERSE(A2:C4) (This will appear in the formula bar.)
4. Since this answer will result in an array (matrix), you will need to: CRTL+SHIFT+ENTER
(NOTE: Braces will surround the formula indicating that it is an array formula.)
Monmouth University
Mathematics Department
instructor: Donna M. Wacha
Matrix (Array) Operations
page 4 of 5
How to find the determinant of a square matrix: If A =
2 5 4 


1 4 3  ,
1 -3 -2 
2
5
4
find: 1 4
3
1 -3 -2
1. Enter the data of the given matrix onto the worksheet.
2. Highlight another section of the worksheet that has the
dimensions as the answer.
NOTE: Since we are finding the determinant of a matrix,
we need to highlight just one cell (F2 in the diagram).
3. Type: =MDETERM(A2:C4) (This will appear in the formula bar.)
4. Since this answer will NOT result in an array (matrix) but a single number, you can just press the
ENTER key. However, if you do the combination of CRTL+SHIFT+ENTER, you will still get
the same response. (NOTE: If you just press the ENTER key, braces will not surround the
formula. But, if you do the combination of CRTL+SHIFT+ENTER, braces will surround the
formula indicating that it is an array formula.)
How to use inverse matrices to solve systems of linear equations:
Suppose we wish to solve this system:
2a + 3b – c + 3d + e = 22
3a + b – 4c + 3d – e = 0
a – 2b + 3c – 4d + 2e = 0
a + 2b – 3c + 2d – 2e = –6
2a
+ 4d – 5e = –7
The matrix equation for this system is:
 2 3 -1 3 1   a   22 

    
 3 1 -4 3 -1 b   0 
1 -2 3 -4 2  x  c  =  0 

    
1 2 -3 2 -2  d   -6 
 2 0 0 4 -5   e   -7 
1. Enter the data of the coefficient matrix onto the worksheet (cells A2 to E6).
2. Find the determinant of the coefficient matrix:
 Highlight another section of the worksheet (cell G2) where the determinant will be
displayed.
 Type: =MDETERM(A2:E6)
 Remember to: ENTER . . . or . . . CRTL+SHIFT+ENTER
 NOTE: A matrix will have no inverse if its determinant is zero (0). If the coefficient
matrix of a system of equations has a determinant equal to zero (0), the system will not
have a unique solution. However, you will need to determine whether the given system
of equations has a general solution or no solution at all by completing the Gauss-Jordan
Elimination (row operations) method.
3. Find the inverse of this coefficient matrix:
 Highlight another section of the worksheet that has the dimensions as the inverse. Since
we are finding the inverse of a 5x5 matrix, its inverse will also be 5x5 matrix.
Monmouth University
Mathematics Department
instructor: Donna M. Wacha
Matrix (Array) Operations
page 5 of 5
 Type: =MINVERSE(A2:E6)
 Remember to: CRTL+SHIFT+ENTER
4. Enter the data of the constant matrix onto the worksheet (cells O2 to O6).
5. Multiply the “inverse matrix” (cells I2 to M6) by the “constant matrix” (cells O2 to O6):
 Highlight another section of the worksheet that has the dimensions of the answer matrix.
For this example, we will be multiplying a 5x5 matrix with a 5x1 matrix which will result
in a product that should be a 5x1 matrix.
 Type: =MMULT(I2:M6,O2:O6) (This will appear in the formula bar.)
 Remember to: CRTL+SHIFT+ENTER
6. The final solution for the system of equations will appear in resulting matrix. For this example,
in the matrix that appears in cells R2 to R6. Therefore, the solutions for the given system is:
a=1
b=2
c=3
d=4
e=5
Monmouth University
Mathematics Department
instructor: Donna M. Wacha
ECHELON WORD PROBLEMS
1. A person receives $306 per year in simple interest from three investments totalling
$3200. Part is invested at 8%, part at 9% and part at 10%. There is $1800 more
invested at 10% than at "t%. Find the amount invested at each rate.
2. The pollution count for a city is 600. This pollution is produced by three industries ­
coal, steel and plastics. The coal industry contributes twice as much to the pollution
count as the steel industry. It is known that the pollution count would be 500 if the
pollution count from the coal industry were reduced by 50%. Find the pollution count
for the three industries.
3. In an experiment involving mice, a zoologist needs a food mix that contains, among
other things... 23 gm of protein, 6.2 gm of fat and 16 gm of moisture. She has on hand
food mixes of the following compositions: Mix A contains 20% protein, 2% fat and 15%
moisture; Mix B contains 10% protein, 6% fat and 10% moisture; Mix C contains 15%
protein, 5% fat and 5% moisture. How many grams of each mix should be used to get
the desired diet mix?
4. A garment industry manufactures three shirt styles. Each shirt requires the services
of three departments: cutting, sewing and packaging. The maximum hours available for
each department is 1160, 1560 and 480 labor-hours per week respectively. Style A
requires 0.2 hr for cutting, 0.3 hr for sewing and 0.1 hr for packaging. Style B requires
0.4 hr for cutting, 0.5 hr for sewing and 0.2 hr for packaging. Style C requires 0.3 hr
for cutting, 0.4 hr for sewing and 0.1 hr for packaging. How many of each shirt style
must be produced each week to operate at full capacity?
MAH Ch 12 Food Web WS
Problem: Because of damp, rainy weather, the insect population of an area
has increased dramatically. The insects are annoying to people and animals.
State authorities are in favor of using an insectidde that would literally wipe
out the entire insect population. You, as an employee of the Environmental
Protection Agency, must determine whether this action will be detrimental to
the environment.
Model: The line diagram shown below is called a digraph and represents a
small food web. The directed segment joining cat and rat, for example, indicates
that cats eat rats. A number, 1, 2, or 3, is associated with each animal for
later reference.
Rat (2)
~
cat (1)
Mouse (3).
The relationships expressed in this digraph can be represented by a
matrix if we let the numbers 1, 2, and 3 represent the respective rows and
columns in a 3 x 3 matrix. In constructing a matrix to convey the information of
the digraph, let the position for each entry be designated by the ordered pair
(i, J), the iindicating the row position and thejindicating the column
position, and where position (i,}) is filled in the following manner:
position (i, JJ = { 1 if i feeds on j ootherwise Thus, the matrix associated with the digraph above is .
1 2 3
101 1
2 0 0 1
3 000
call this matrix F. Notice that there are three l's in the matrix
representing the three directed segments of the digraph.
1) Find F2 where F2
= F * F.
The lin position (I, 3) indicates that cats use mice as an indirect food
source as well; that is, cats eat rats, and rats eat mice.
Consider the following digraph of a f<XXI web for seven animals, including
the insects that are causing the problem.
~
Field Mouse (2)
Bear (1)
----_~
.£) .. Insect (~V
\
Crayfish (4)
/­
Trout (6)
2) Construct the associated mabix to represent this web. Notice that rows
2 and 3 each contain a single I, indicating that the associated animals have
only a single food sourCe. Column 1 contains all O's. What does a column of
O's indicate?
3) Notice that bears and trout have the most direct sources of food. This
can be determined by finding the sums of the numbers in the rows. These sums
indicate the number of direct food sources for each animal. Find the seven row
sums.
4) Column 3 has the most I's. What does this suggest about the food web?
.
The matrix F2 denotes indirect (through one intermediary) sources of food .
.
5) Find F2. Notice that column 3 contains all nonzero numbers. This
indicates that an the animals rely on insects for food, either directly or
indirectly.
I
6) Find F + F2 and the associated row sums. This matrix denotes the total
number of direct and indirect sources of food for each animal.
7) Which animal has the most food sources?
Let us now introduce the insecticide into the food web. Since the entire
insect pOpulation will be killed,. several animals wilt lose a source of food.
8) Construct a new matrix,. F',. to represent the food web with no insects.
Notice the effect this has on the overall animal population.
9) What has happened to the row sums? Since tadpoles and field mice rely
solely on insects for their food, what will happen?
10) Find p 2 and P
+ p2.
11) What are the row sums? Compare these answers with those of the original
matrix,. F.
12) Will all the animals be affected by the insecticide? Which animal(s)
will be least affected?
Organize and summarize your findings in a brief report, using your data to
convince the authorities that this insecticide is harmful to the environment.