1.4 - Calculating with matrices
A matrix keeps related numbers in a fixed arrangement, and that arrangement controls which calculations are possible. Learn to recognise matrix dimensions, combine entries and calculate products, including non-square matrices with at most three rows and columns.
Dimensions and special matrices
How can one calculation turn three quantities into two totals? A matrix can record the weights for each total, but first we need a precise way to describe its shape.
For example,
has two horizontal rows and three vertical columns. Its entry in row 2, column 3 is . The order of the numbers matters: moving an entry changes the matrix.
Dimensions
An matrix is a rectangular array with rows and columns. Its dimensions, or order, are rows first, columns second. A matrix is square when . Two matrices are equal exactly when they have the same dimensions and equal corresponding entries.
Thus is , while is and is . A row and a column containing the same numbers are different matrices.
Zero and identity matrices
A zero matrix, written , has every entry zero; it may be rectangular. An identity matrix, or unit matrix, is square, with ones on its main diagonal from top left to bottom right, and zeros elsewhere. For example,
The subscripts identify the size when it is useful. We often write simply or when the dimensions are clear. An all-ones matrix is not an identity matrix: its off-diagonal entries would mix quantities together. Multiplication below explains why the identity leaves quantities unchanged.
Key idea
Read the dimensions before calculating. The shape is part of a matrix's meaning, not just its layout.
Distinguish a zero matrix from an identity matrix in this check.
Addition and scalar multiplication
Matrices with the same dimensions can be combined entry by entry, because each position then has a matching position in the other matrix.
For instance, the top-left entry of is the sum of the two top-left entries. You cannot add a matrix to a matrix, even though both have six entries: their positions do not match.
Scalar multiplication
A scalar is a single number. Multiplying a matrix by a scalar multiplies every entry by that number. Matrix addition and subtraction require equal dimensions and operate on corresponding entries.
Use brackets to keep a negative scalar or a subtraction attached to every entry it affects.
Worked example 1: combining rectangular matrices
Question. Given
find .
Plan. Double every entry of , then subtract corresponding entries of .
Both matrices are , so the subtraction is defined:
In particular, the top-right entry is .
Answer. .
Check. Adding to the answer gives , reversing the subtraction.
Keep the same matrices and change which one is doubled. The scalar belongs to its matrix, not to the whole expression.
Worked example 2: moving the scalar
Question. For the same and , find .
Plan. Double , then subtract it entry by entry from .
The bottom-middle entry is , so a negative entry being subtracted increases the result.
Answer. .
Check. The result plus recovers all six entries of .
These operations preserve the dimensions. Multiplying by zero gives the zero matrix of the same shape.
Watch out
Subtracting a matrix changes the sign of every entry being subtracted. For example, , not .
Apply that sign rule to fresh matrices.
Matrix products
A matrix product combines a row from the left matrix with a column from the right matrix, multiplying matching entries and adding the results.
Suppose two totals use three quantities with weights and . If the quantities are , the totals are and . These are precisely the entries of a matrix-column product.
[DIAGRAM: asset_name: A row meets a column; asset_slug: cam9231-matrix-row-column; caption: A product entry uses one row from the left and one column from the right; description: Exact labelled matrices A with rows 1 2 minus 1 and 0 3 2, and B with rows 2 1, minus 1 0, 3 minus 2. The second row of A and second column of B are highlighted. Their three paired products 0 times 1, 3 times 0 and 2 times minus 2 add to minus 4, the bottom-right entry of AB. A dimension strip shows 2 by 3 times 3 by 2 gives 2 by 2.]

Matrix multiplication
If has dimensions and has dimensions , then has dimensions . Its entry in row , column is
The inner dimensions must match. Not in the formula booklet: learn it.
Each row needs exactly as many entries as the chosen column. Multiplying corresponding positions without adding is a different operation, not the matrix product.
Worked example 3: one column of output
Question. Calculate
Plan. Check times , then take each row against the column.
The result has two rows and one column, as predicted.
Answer. .
Check. Build the same output as a weighted sum of the left matrix's columns:
Now append a second column to the right matrix. The original output remains its first column; only the new column needs new calculations.
Worked example 4: two columns of output
Question. Find , where
Plan. Use each of the two rows against each of the two columns.
For example, row 2 with column 2 gives .
Answer. .
Check. For the new output column, the weighted-column calculation is
; the first column was checked above.
This answers the opening question: two rows of weights turn three inputs into two totals. For this rectangular pair, is also defined, but it is , so it cannot equal . With a matrix and a column, the reverse product is not defined at all.
Watch out
For , use rows of and columns of . Check compatibility afresh for ; neither its existence nor its value follows from .
Calculate a compatible rectangular product without changing its order.
Quick Recap
- Dimensions mean rows then columns; zero matrices may be rectangular, identities are square.
- Add or subtract only matrices with equal dimensions; a scalar multiplies every entry.
- In a product, inner dimensions match and outer dimensions give the result's shape.
- Each output entry is one row-column scalar product.
Two rows of weights can turn three inputs into two totals: a matrix multiplies a column to give a column.