math111_logo Composition and Matrix Multiplication

2. Multiplication of matrices

The composition of two linear transformations is also linear. The geometrical reason is clear: if parallelograms and scalings are preserved by each transformation, then they are preserved by the combined transformation. See here for a rigorous proof.

Since linear transformations between euclidean spaces are equivalent to matrices, the composition of linear transformations should have corresponding operation on matrices.

Let A and B be the matrices for linear transformations T: RnRm and S: RkRn. Then the matrix for the composition TS: RkRm is the product AB of A and B

Example Consider linear transformations

T: R2R2, (y1, y2) → (z1, z2) = (a11y1 + a12y2, a21y1 + a22y2)
S: R2R2, (x1, x2) → (y1, y2) = (b11x1 + b12x2, b21x1 + b22x2)

By substituting the formulae of y1, y2 in terms of x1, x2 into the formulae of z1, z2 in terms of y1, y2, we find the composition TS: R2R2, (x1, x2) → (z1, z2) is given by

z1 = a11(b11x1 + b12x2) + a12(b21x1 + b22x2) = (a11b11 + a12b21)x1 + (a11b12 + a12b22)x2
z2 = a21(b11x1 + b12x2) + a22(b21x1 + b22x2) = (a21b11 + a22b21)x1 + (a21b12 + a22b22)x2

In terms of the product of matrices, we have

[ a11 a12 ][ b11 b12 ] = [ a11b11 + a12b21 a11b12 + a12b22 ]
a21 a22 b21 b22 a21b11 + a22b21 a21b12 + a22b22

Note that in the example above, the first entry a11b11 + a12b21 of the matrix AB is obtained by "multiplying" the first row (a11 a12) of A with the first column (b11 b21) of B. Similar observation can be made to the other entries. In fact, we have the following general rule for multiplying an m by n matrix A and an m by k matrix B together.

(i, j)-entry of AB = (i-th row of A) • (j-th row of B)

The result AB is an m by k matrix. The rigorous proof of the rule can be found in the next section.

Example Let

A = [ 1 2 ]
3 4
B = [ -1 0 2 ]
0 1 3
C = [ 0 1 -1 ]
2 0 3
-1 1 2
D = [ 1 2 ]
2 3
3 4

Then

AB = [ 1×(-1) + 2×0 1×0 + 2×1 1×2 + 2×3 ] = [ -1 2 8 ]
3×(-1) + 4×0 3×0 + 4×1 3×2 + 4×3 -3 4 18
A2 = AA = [ 1×1 + 2×3 1×2 + 2×4 ] = [ 7 10 ]
3×1 + 4×3 3×2 + 4×4 15 22
DA = [ 1×1 + 2×3 1×2 + 2×4 ] = [ 7 10 ]
2×1 + 3×3 2×2 + 3×4 11 16
3×1 + 4×3 3×2 + 4×4 15 22
BC = [ (-1)×0 + 0×2 + 2×(-1) (-1)×1 + 0×0 + 2×1 (-1)×(-1) + 0×3 + 2×2 ] = [ -2 1 5 ]
0×0 + 1×2 + 3×(-1) 0×1 + 1×0 + 3×1 0×(-1) + 1×3 + 3×2 -1 3 9
(AB)C = [ (-1)×0 + 2×2 + 8×(-1) (-1)×1 + 2×0 + 8×1 (-1)×(-1) + 2×3 + 8×2 ] = [ -4 7 23 ]
(-3)×0 + 4×2 + 18×(-1) (-3)×1 + 4×0 + 18×1 (-3)×(-1) + 4×3 + 18×2 -10 15 51
A(BC) = [ 1×(-2) + 2×(-1) 1×1 + 2×3 1×5 + 2×9 ] = [ -4 7 23 ]
3×(-2) + 4×(-1) 3×1 + 4×3 3×5 + 4×9 -10 15 51

On the other hand, the products such as AD, AC, BA, CB, B2 are meaningless.

Example According to an earlier example, the matrix for the rotation by angle α is

Rα = [ cosα - sinα ]
sinα cosα

Since rotation by β and then rotation by α is the same as rotation by α + β, we must have RαRβ = Rα+β, i.e.,

[ cosα - sinα ] [ cosβ - sinβ ] = [ cos(α + β) - sin(α + β) ]
sinα cosα sinβ cosβ sin(α + β) cos(α + β)

If we compute matrix multiplication on the left side in the usual way, we get the following familiar formulae in trigonometry.

cosαcosβ - sinαsinβ = cos(α + β)
sinαcosβ + cosαsinβ = sin(α + β)


[previous topic] [part 1] [part 2] [part 3] [part 4] [next topic]
[Extra: Composition of linear transformations is linear]