Matrices: addition, scalar and matrix multiplication
A matrix is a rectangular table of numbers. Add matrices of the same order; multiply A by B only when the columns of A equal the rows of B.
Types of matrix
| Type | Description | Example |
|---|---|---|
| Row matrix | One row (1 × n) | [3 1 4] |
| Column matrix | One column (m × 1) | [2; 5] |
| Square matrix | Same number of rows and columns | [2 5; 1 3] |
| Zero matrix O | All entries 0 | [0 0; 0 0] |
| Identity matrix I | 1s on the main diagonal, 0s elsewhere; AI = IA = A | [1 0; 0 1] |
| Transpose Aᵀ | Rows become columns | [1 2; 3 4]ᵀ = [1 3; 2 4] |
Rules of matrix arithmetic
Addition, subtraction and scalar multiples
A = [2 5; 1 3] and B = [4 0; −2 6]. Find A + B, A − B and 3A.
- A + B = [2 + 4, 5 + 0; 1 + (−2), 3 + 6] = [6 5; −1 9].
- A − B = [2 − 4, 5 − 0; 1 − (−2), 3 − 6] = [−2 5; 3 −3].
- 3A = [3 × 2, 3 × 5; 3 × 1, 3 × 3] = [6 15; 3 9].
A + B = [6 5; −1 9]; A − B = [−2 5; 3 −3]; 3A = [6 15; 3 9]
Matrix multiplication
With A = [2 5; 1 3] and B = [4 0; −2 6], find AB and BA.
- Both are 2 × 2, so AB and BA exist and are 2 × 2.
- AB row 1: 2 × 4 + 5 × (−2) = −2; 2 × 0 + 5 × 6 = 30.
- AB row 2: 1 × 4 + 3 × (−2) = −2; 1 × 0 + 3 × 6 = 18.
- BA row 1: 4 × 2 + 0 × 1 = 8; 4 × 5 + 0 × 3 = 20.
- BA row 2: (−2) × 2 + 6 × 1 = 2; (−2) × 5 + 6 × 3 = 8.
AB = [−2 30; −2 18] but BA = [8 20; 2 8], so AB ≠ BA.
Branch revenue with a matrix product
A retailer's two Kurunegala branches sold, in one day: Branch 1: 20 packets of tea, 15 kg of sugar, 30 kg of rice; Branch 2: 25, 10 and 40. Prices are Rs. 450 a packet of tea, Rs. 280 a kg of sugar and Rs. 320 a kg of rice. Find each branch's revenue with one matrix product.
- Quantity matrix Q (2 × 3) = [20 15 30; 25 10 40]; price matrix P (3 × 1) = [450; 280; 320].
- Columns of Q (3) = rows of P (3), so QP exists and is 2 × 1.
- Branch 1: 20 × 450 + 15 × 280 + 30 × 320 = 9,000 + 4,200 + 9,600 = 22,800.
- Branch 2: 25 × 450 + 10 × 280 + 40 × 320 = 11,250 + 2,800 + 12,800 = 26,850.
- Total = 22,800 + 26,850 = 49,650.
QP = [22,800; 26,850]: Branch 1 Rs. 22,800, Branch 2 Rs. 26,850, total Rs. 49,650.
A retail chain such as Cargills or Keells can store branch-by-product sales as a matrix. Multiplying the quantity matrix by a price column gives every branch's revenue in one step, which is exactly how spreadsheets do it.
Short answer: “When can two matrices be multiplied? State the order of the product.” When the columns of the first equal the rows of the second; (m × n)(n × p) gives m × p.
Short answer: “A = [2 5; 1 3], B = [4 0; −2 6]. Find 2A − B.” 2A = [4 10; 2 6]; 2A − B = [0 10; 4 0].
Essay: “Two branches' quantities of three goods and the goods' prices are given. Write the matrices, find the revenue of each branch by matrix multiplication and the total.” QP = [22,800; 26,850]; total Rs. 49,650.
Row into column: for AB, run along a row of A and down a column of B, multiply in pairs and add. Check the orders first: inside numbers must match, outside numbers give the answer's order.