Combining Data with a Matrix Product

A stock table times a price column: takings.

A table becomes a matrix

Two shops sell pens and pads. Shop A sold 4 pens and 2 pads, and shop B sold 3 pens and 5 pads. In a table, each shop has a row and each item has a column, with the names written along the edges.

Take the names away and the same four counts, in the same places, make the 2 × 2 matrix S = (4 2; 3 5). The names are not written, but they still decide what each place means: row 1 is shop A, row 2 is shop B, column 1 is pens and column 2 is pads.

The prices go in a column

A pen costs 3 and a pad costs 5. Written as a column, (3; 5), the prices have one row for each item, in the same order as the columns of S.

Now S times the price column is a 2 × 2 times a 2 × 1. The inner numbers match, and they match for a reason: the columns of S are the items, and so are the rows of the price column. The product is 2 × 1, one row for each shop.

Each row is a bill

Row 1 of S times the price column pairs each of shop A’s counts with its own price: 4 pens at 3 and 2 pads at 5 come to 4 × 3 + 2 × 5 = 12 + 10 = 22.

Row 2 does the same for shop B: 3 pens at 3 and 5 pads at 5 come to 3 × 3 + 5 × 5 = 9 + 25 = 34. So the product is the column of takings (22; 34).

Check the total another way. The two shops sold 4 + 3 = 7 pens and 2 + 5 = 7 pads, and 7 × 3 + 7 × 5 = 21 + 35 = 56, which is 22 + 34.

S4235price35takings2234×=

Row 2 of S is shop B’s sales. Paired with the prices it gives 3 × 3 + 5 × 5 = 34, the bottom entry of the takings.

The labels must meet

A product makes sense when the columns of the left matrix and the rows of the right one describe the same things. Here both are items, so every count meets its own price.

Written as a row, (3 5), the prices cannot stand on the right of S: a 2 × 2 times a 1 × 2 has no product. On the left, (3 5)S can be worked out, since a 1 × 2 times a 2 × 2 is a 1 × 2, and it gives (27 31). But its first entry is 3 × 4 + 5 × 3, the pen price times shop A’s pens plus the pad price times shop B’s pens, so it counts nothing.

Two price lists at once

Next year a pen will cost 4 and a pad 6. Put both price lists side by side as the columns of one matrix, P = (3 4; 5 6), with the items in the rows and the years in the columns.

Then SP is a 2 × 2. Its first column is this year’s takings, 22 and 34, as before. Its second column prices the same sales at next year’s prices: 4 × 4 + 2 × 6 = 16 + 12 = 28 for shop A and 3 × 4 + 5 × 6 = 12 + 30 = 42 for shop B. So SP = (22 28; 34 42), with one row for each shop and one column for each year.

S4235P3456SP22283442×=

The bottom right entry of SP is shop B’s sales at next year’s prices: 3 × 4 + 5 × 6 = 42.

Adding up with a row of ones

A row of ones adds up a column. (1 1) times the takings (22; 34) is 1 × 22 + 1 × 34 = 56, the total for both shops. In the same way (1 1)S = (7 7), the total sales of each item.

The usual mistakes

Giving each count the other item’s price. 4 × 5 + 2 × 3 = 26 charges shop A’s pens at the pad price; each count is multiplied by the price of its own item.

Charging for one item only. 4 × 3 = 12 is shop A’s pens alone, and the row has both items in it.

Writing the prices as a row on the right. The prices must be stacked in a column, so that each one meets its own count.

Reading a number in the product as a count. The 34 is not the number of pads shop B sold; it is the value of everything shop B sold.

Orders, parts and prices

In the first application below, a café’s orders at two branches times a column of prices gives one total for each branch. In the second, the parts in a bicycle and a tricycle are priced by two suppliers at once, as two columns, and then an order for both is costed with a row matrix.

Worked example: A Café's Takings as Its Orders Times Its Prices

Question On Saturday the Station branch of a café sells 50 coffees, 30 teas and 20 slices of cake, and the Park branch sells 40 coffees, 45 teas and 25 slices of cake. A coffee costs $3, a tea $2 and a slice of cake $4. The sales are the matrix Q = 503020404525 and the prices are the column P = 324. (a) Explain why the product QP can be found, and state its order. Why can PQ not be found? (b) Find QP, and hence the takings at each branch and in total.

  1. 1.Q is 2 × 3 and P is 3 × 1. The inner numbers are both 3, one for each item, so each quantity has a price to meet and QP can be found.

    sold on Saturday, and the price of eachcoffee $3tea $2cake $4Station503020Park404525503020404525×3242 × 3 times 3 × 1: the inner 3s match
    sold on Saturday, and the price of eachcoffee $3tea $2cake $4Station503020Park404525503020404525×3242 × 3 times 3 × 1: the inner 3s match
    Q = 503020404525 is 2 × 3 and P = 324 is 3 × 1: the columns of Q and the rows of P are both the three items.
  2. 2.(a) The outer numbers give the order: QP is 2 × 1, one total for each branch. PQ would be 3 × 1 times 2 × 3: P has 1 column and Q has 2 rows, and 1 ≠ 2, so PQ cannot be found.

    sold on Saturday, and the price of eachcoffee $3tea $2cake $4Station503020Park404525QP is 2 × 1: one total for each branchPQ: 3 × 1 times 2 × 3, and 1 is not 2
    sold on Saturday, and the price of eachcoffee $3tea $2cake $4Station503020Park404525QP is 2 × 1: one total for each branchPQ: 3 × 1 times 2 × 3, and 1 is not 2
    (a) QP is 2 × 1, one total for each branch. PQ cannot be found: P has 1 column and Q has 2 rows.
  3. 3.Row 1 of Q times the column P: 50 × 3 + 30 × 2 + 20 × 4 = 150 + 60 + 80 = 290.

    sold on Saturday, and the price of eachcoffee $3tea $2cake $4Station503020Park404525503020404525×324=290?50 × 3 + 30 × 2 + 20 × 4 = 290
    sold on Saturday, and the price of eachcoffee $3tea $2cake $4Station503020Park404525503020404525×324=290?50 × 3 + 30 × 2 + 20 × 4 = 290
    Row 1 of Q times the column of prices: 50 × 3 + 30 × 2 + 20 × 4 = 290.
  4. 4.Row 2 of Q times the column P: 40 × 3 + 45 × 2 + 25 × 4 = 120 + 90 + 100 = 310. So QP = 290310.

    sold on Saturday, and the price of eachcoffee $3tea $2cake $4Station503020Park404525503020404525×324=29031040 × 3 + 45 × 2 + 25 × 4 = 310
    sold on Saturday, and the price of eachcoffee $3tea $2cake $4Station503020Park404525503020404525×324=29031040 × 3 + 45 × 2 + 25 × 4 = 310
    Row 2 times the column: 40 × 3 + 45 × 2 + 25 × 4 = 310, so QP = 290310.
  5. 5.(b) The Station branch takes $290 and the Park branch takes $310, which is $600 in total. Check: together the branches sold 90 coffees, 75 teas and 45 slices of cake, and 90 × 3 + 75 × 2 + 45 × 4 = 270 + 150 + 180 = 600.

    sold on Saturday, and the price of eachcoffee $3tea $2cake $4Station503020Park404525503020404525×324=290310Station $290, Park $310: $600 in allcheck: 90 × 3 + 75 × 2 + 45 × 4 = 600
    sold on Saturday, and the price of eachcoffee $3tea $2cake $4Station503020Park404525503020404525×324=290310Station $290, Park $310: $600 in allcheck: 90 × 3 + 75 × 2 + 45 × 4 = 600
    (b) Station takes $290 and Park takes $310, $600 in total.

Answer: (a) Q has 3 columns and P has 3 rows, so QP can be found, and it is 2 × 1; PQ cannot, as P has 1 column and Q has 2 rows; (b) QP = 290310: $290 at Station and $310 at Park, $600 in total

Common mistakes

  • Multiplying entry by entry, 50 × 3, 30 × 2 and so on, and stopping with six numbers. A matrix product adds along the row, so each branch gives one sum.
  • Trying to find PQ because both matrices are there. In a product the order matters: PQ needs P to have as many columns as Q has rows, and it does not.

More matrix arithmetic problems, worked step by step →

Worked example: The Parts for Bicycles and Tricycles Priced by Two Suppliers

Question A workshop builds bicycles and tricycles. A bicycle needs 1 frame, 2 wheels and 1 seat, and a tricycle needs 1 frame, 3 wheels and 1 seat. Supplier X charges $40 for a frame, $15 for a wheel and $10 for a seat; supplier Y charges $45, $12 and $8. (a) Write the parts as a 2 × 3 matrix N and the costs as a 3 × 2 matrix C, with one column for each supplier, and find NC. What does each entry mean? (b) The workshop has an order for 20 bicycles and 10 tricycles. Use the row matrix 2010 to find the cost of the parts from each supplier. Which supplier is cheaper, and by how much?

  1. 1.N = 121131, with bicycles and tricycles in the rows and frames, wheels and seats in the columns. C = 40451512108, with the parts in the rows and suppliers X and Y in the columns. The inner numbers of 2 × 3 and 3 × 2 match, so NC is 2 × 2.

    parts in each productframeswheelsseatsbicycle121tricycle131cost of each part, $from Xfrom Yframe4045wheel1512seat108N × C =121131×404515121082 × 3 times 3 × 2 gives 2 × 2
    parts in each productframeswheelsseatsbicycle121tricycle131cost of each part, $from Xfrom Yframe4045wheel1512seat108N × C =121131×404515121082 × 3 times 3 × 2 gives 2 × 2
    N = 121131 goes from products to parts and C = 40451512108 from parts to suppliers, so the parts meet in NC, a 2 × 2 matrix.
  2. 2.Row 1 of N times column 1 of C prices a bicycle's parts at supplier X: 1 × 40 + 2 × 15 + 1 × 10 = 80. Row 1 times column 2 prices them at Y: 1 × 45 + 2 × 12 + 1 × 8 = 77.

    parts in each productframeswheelsseatsbicycle121tricycle131cost of each part, $from Xfrom Yframe4045wheel1512seat108121131×40451512108=8077??1 × 40 + 2 × 15 + 1 × 10 = 801 × 45 + 2 × 12 + 1 × 8 = 77
    parts in each productframeswheelsseatsbicycle121tricycle131cost of each part, $from Xfrom Yframe4045wheel1512seat108121131×40451512108=8077??1 × 40 + 2 × 15 + 1 × 10 = 801 × 45 + 2 × 12 + 1 × 8 = 77
    Row 1 of N times column 1 of C is a bicycle priced at X: $80. Priced at Y it is $77.
  3. 3.Row 2 times column 1: 1 × 40 + 3 × 15 + 1 × 10 = 95. Row 2 times column 2: 1 × 45 + 3 × 12 + 1 × 8 = 89.

    parts in each productframeswheelsseatsbicycle121tricycle131cost of each part, $from Xfrom Yframe4045wheel1512seat108121131×40451512108=807795891 × 45 + 3 × 12 + 1 × 8 = 891 × 40 + 3 × 15 + 1 × 10 = 95
    parts in each productframeswheelsseatsbicycle121tricycle131cost of each part, $from Xfrom Yframe4045wheel1512seat108121131×40451512108=807795891 × 45 + 3 × 12 + 1 × 8 = 891 × 40 + 3 × 15 + 1 × 10 = 95
    Row 2 of N times column 2 of C is a tricycle priced at Y: $89. Priced at X it is $95.
  4. 4.(a) NC = 80779589. Each entry is the cost in dollars of the parts for one product from one supplier: a bicycle costs $80 from X and $77 from Y, and a tricycle costs $95 from X and $89 from Y.

    cost of the parts for one product, $from Xfrom Ybicycle8077tricycle9589NC =80779589bicycle: $80 from X, $77 from Ytricycle: $95 from X, $89 from Y
    cost of the parts for one product, $from Xfrom Ybicycle8077tricycle9589NC =80779589bicycle: $80 from X, $77 from Ytricycle: $95 from X, $89 from Y
    (a) NC = 80779589: the cost in dollars of one product's parts from each supplier.
  5. 5.Multiply the order by NC: 201080779589 = 20 × 80 + 10 × 9520 × 77 + 10 × 89 = 25502430.

    cost of the parts for one product, $from Xfrom Ybicycle8077tricycle95892010×80779589=2550243020 × 80 + 10 × 95 = 255020 × 77 + 10 × 89 = 2430
    cost of the parts for one product, $from Xfrom Ybicycle8077tricycle95892010×80779589=2550243020 × 80 + 10 × 95 = 255020 × 77 + 10 × 89 = 2430
    The order times NC: 201080779589 = 25502430.
  6. 6.(b) The parts cost $2550 from X and $2430 from Y, so supplier Y is cheaper by 2550 − 2430 = $120. Check: the order needs 30 frames, 70 wheels and 30 seats, and at Y that costs 30 × 45 + 70 × 12 + 30 × 8 = 1350 + 840 + 240 = 2430.

    cost of the parts for one product, $from Xfrom Ybicycle8077tricycle9589X: $2550, Y: $2430Y is cheaper by $120check: 30 × 45 + 70 × 12 + 30 × 8 = 2430
    cost of the parts for one product, $from Xfrom Ybicycle8077tricycle9589X: $2550, Y: $2430Y is cheaper by $120check: 30 × 45 + 70 × 12 + 30 × 8 = 2430
    (b) The parts cost $2550 from X and $2430 from Y: supplier Y is cheaper by $120.

Answer: (a) NC = 80779589: the cost in dollars of the parts for a bicycle (row 1) and a tricycle (row 2) from supplier X (column 1) and supplier Y (column 2); (b) $2550 from X and $2430 from Y: Y is cheaper by $120

Common mistakes

  • Choosing supplier X because its frames are cheaper. A tricycle uses three wheels, and Y's cheaper wheels and seats outweigh its more expensive frame, which only the whole product shows.
  • Writing C with one row for each supplier and then finding NC anyway. N is 2 × 3 and that C would be 2 × 3 too, so the product cannot be found: the parts must run down the rows of C to meet the parts across the columns of N.

More matrix arithmetic problems, worked step by step →

Practice Combining Data with a Matrix Product in the app