## 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.

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.

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`).