## Activity 1-5

### Matrix Multiplication

For this lab activity, we will be using sum-products and then matrix multiplication to solve two sets of problems.At the end of class, if you are done, please check this activity off with the TAs. Otherwise, please complete and share your spreadsheet with

`cs0030handin@gmail.com`

by the end of the day.
#### Task 1

We first want to use sum-products and matrix multiplication to calculate two individuals’ meal expenses.

1. Copy this spreadsheet into your Google drive. You’ll see matrix A, in pink, which provides the number of items purchased by Po and Master Shifu. You’ll also see matrix B, in blue, which lists the prices for the three items, for each of the two meals. Notice that the number of columns of A is equal to the number of rows of B. This is necessary for the matrix multiplication you’ll perform later.

2. You’ll now want to fill in the green cells in `D14:E15`

. `D14`

will be for Po’s breakfast total, and `D15`

for Master Shifu’s breakfast total. Column E will be for their respective lunch totals. For these green cells, you should use `SUMPRODUCT`

.

Start out with D14. You’ll want a `SUMPRODUCT`

formula equivalent to (1 noodle bowl x $2) + (2 dumplings x $3) + (3 bean buns x $4), which evaluates to 20 dollars.

In general, when using `SUMPRODUCT`

, you should pass in either two rows or two columns. In your case, your data is not in this format--you start out with a row (items) and a column (prices). Thus, you should use the `TRANSPOSE`

function in one of the arguments, transforming your prices column into a row. Your function should look like:

` SUMPRODUCT("row", TRANSPOSE("column")) `

where “row” and “column” are specified in the matrices.

Once you have obtained the correct result for `D14`

, fill in the rest of the green table.

3. While the `SUMPRODUCT`

formula you wrote wasn’t too complex, there’s a simpler way to find these same totals. Using `MMULT`

(matrix multiplication), you can use one formula to compute all the possible row-column sum-products. You’ll fill in the yellow cells this way.

The general syntax for `MMULT`

looks like:

`MMULT(“array1”, “array2”)`

. The number of columns in array1 must be the same as the number of rows in array2. Because `MMULT`

is designed to work with both rows and columns, we do not need to transpose any data.

In `D21`

, use the `MMULT`

formula in which “array1” is Matrix A and “array2” is Matrix B. Your formula should fill in all 4 yellow cells, automatically calculating all the necessary sum-products.

#### Task 2

We’ll now use matrix multiplication to help us calculate students’ final grades for a course.

For this course, the professor has created two grading schemes. In determining a particular student’s final grade, the professor will use whichever scheme leads to a higher grade for that student (in this case, some students can be graded according to scheme 1, others according to scheme 2). For Scheme 1, all assignments are weighted relatively equally. For Scheme 2, the final is weighted more heavily.

On the `Task2`

sheet, you’ll see these two grading schemes and the students’ scores for each assignment.

For this task, you should calculate each student’s final grade under both Scheme 1 and Scheme 2. Then for each student, note which grading scheme leads to a higher final grade. You only need to use `MMULT`

for this task. (You no longer need to call `SUMPRODUCT`

).

Once you're done, please check off your lab with a TA or share your file with cs0030handin@gmail.com by midnight, 2/14.