Matrix and vector multiplication examples

Example 1

Compute Ax where x = (2,1, 0)

A = 1 2 3 4 5 6 7 8 910 11 12 .

Solution:

Ax = 1 2 3 4 5 6 7 8 910 11 12 2 1 0 = 2 1 + 1 2 + 0 3 2 4 + 1 5 + 0 6 2 7 + 1 8 + 0 9 2 10 + 1 11 + 0 12 = 0 3 6 9 = (0,3,6,6).

Example 2

Compute Ay where y = (3,2,1, 0) and A is as in Example 1.

Solution: The matrix-vector product is not defined. A is 4 × 3 and y is 4 × 1 (viewed as column vector).

Example 3

Compute BC, where

B = 123 4 5 6  andC = 12 3 4 56 .

Solution:

BC = 123 4 5 6 12 3 4 56 = 1 1 + 2 3 + 3 51 2 + 2 4 + 3 6 4 1 + 5 3 + 6 5 4 2 + 5 4 + 6 6 = 2228 49 64

Example 4

Using B and C as defined in Example 3, calculate CB.

Solution:

CB = 12 3 4 56 123 4 5 6 = 1 1 + 2 41 2 + 2 51 3 + 2 6 3 1 + 4 4 3 2 + 4 5 3 3 + 4 6 5 1 + 6 4 5 2 + 6 55 3 + 6 6 = 9121519 26 33 294051

Clearly, one can see that matrix multiplication is not commutative, i.e., BCCB. In the case of examples 3 and 4, BC isn’t even the same size matrix as CB. In some other cases, BC might be defined but CB won’t be defined (for example, when B is a 3 × 2 matrix and C is a 2 × 4 matrix). It is even true that when B and C are square matrices, matrix multiplication is not commutative. You can try yourself and see that BCCB if

B = 12 3 4  andC = 56 7 8 .