Matrix Multiplication

In matrix algebra, there are two kinds of matrix multiplication: multiplication of a matrix by a number and multiplication of a matrix by another matrix.

How to Multiply a Matrix by a Number

When you multiply a matrix by a number, you multiply every element in the matrix by the same number. This operation produces a new matrix, which is called a scalar multiple.

For example, if x is 5, and the matrix A is:

A =    
100 200
300 400


xA   =   5A   =    5  
100 200
300 400
5 * 100 5 * 200
5 * 300 5 * 400
500 1000
1500 2000
    =    B

In the example above, every element of A is multiplied by 5 to produce the scalar multiple, B.

Note: Some texts refer to this operation as multiplying a matrix by a scalar. (A scalar is a real number or a symbol representing a real number.)

How to Multiply a Matrix by a Matrix

The matrix product AB is defined only when the number of columns in A is equal to the number of rows in B. Similarly, the matrix product BA is defined only when the number of columns in B is equal to the number of rows in A.

Suppose that A is an i x j matrix, and B is a j x k matrix. Then, the matrix product AB results in a matrix C, which has i rows and k columns; and each element in C can be computed according to the following formula.

Cik = Σj AijBjk


Cik = the element in row i and column k from matrix C
Aij = the element in row i and column j from matrix A
Bjk = the element in row j and column k from matrix B
Σj = summation sign, which indicates that the aijbjk terms should be summed over j

Let's work through an example to show how the above formula works. Suppose we want to compute AB, given the matrices below.

A =    
0 1 2
3 4 5
  B =    
6 7
8 9
10 11

Let AB = C. Because A has 2 rows, we know that C will have two rows; and because B has 2 columns, we know that C will have 2 columns. To compute the value of every element in the 2 x 2 matrix C, we use the formula Cik =  Σj AijBjk, as shown below.

  • C11 = Σ A1jBj1 = 0*6 + 1*8 +2*10 = 0 + 8 + 20 = 28
  • C12 = Σ A1jBj2 = 0*7 + 1*9 +2*11 = 0 + 9 + 22 = 31
  • C21 = Σ A2jBj1 = 3*6 + 4*8 +5*10 = = 18 + 32 + 50 = 100
  • C22 = Σ A2jBj2 = 3*7 + 4*9 +5*11 = 21 + 36 +55 = 112

Based on the above calculations, we can say

AB   =   C =    
28 31
100 112

What we did to compute Matrix C was not complicated. All we did was to multiply row elements in Matrix A by corresponding column elements in Matrix B.

Multiplication Order

As we have already mentioned, in some cases, matrix multiplication is defined for AB, but not for BA; and vice versa. However, even when matrix multiplication is possible in both directions, results may be different. That is, AB is not always equal to BA.

Because order is important, matrix algebra jargon has evolved to clearly indicate the order in which matrices are multiplied.

  • To describe the matrix product AB, we can say A is postmultiplied by B; or we can say that B is premultiplied by A.

  • Similarly, to describe the matrix product BA, we can say B is postmultiplied by A; or we can say that A is premultiplied by B.

The bottom line: when you multiply two matrices, order matters.

Identity Matrix

The identity matrix is an n x n diagonal matrix with 1's in the diagonal and zeros everywhere else. The identity matrix is denoted by I or In. Two identity matrices appear below.

I2 =    
1 0
0 1
I3 =    
1 0 0
0 1 0
0 0 1

The identity matrix has a unique talent. Any matrix that can be premultiplied or postmultiplied by I remains the same; that is:

AI = IA = A

Test Your Understanding

Problem 1

Consider the matrices shown below - A, B, and C

A =    
a b
c d
B =    
e f
g h
C =    
w x
y z

Assume that AB = C. Which of the following statements are true?

(A) w = a*e + b*h
(B) x = a*f + b*h
(C) y = c*g + d*h
(D) All of the above
(E) None of the above


The correct answer is (B). To compute the value of any element in matrix C, we use the formula Cik = Σj AijBjk.

In matrix C, x is the element in row 1 and column 2, which is represented in the formula by C12. Therefore, to find x, we use the formula to calculate C12, as shown below.

x = C12 = Σj A1jBj2 = A11B12 + A12B22 = a*f + b*h

All of the other answers are incorrect.