# Matrix Multiplication

In linear algebra, matrices play an important role in dealing with different concepts. A matrix is a rectangular array or table of numbers, symbols, or expressions, arranged in rows and columns in mathematics. We can perform various operations on matrices such as addition, subtraction, multiplication and so on. In this article, you will learn how to multiply a matrix by another matrix, its algorithm, formula, 2×2 and 3×3 matrix multiplication with examples in detail.

## Matrix Multiplication Definition

Matrix multiplication, also known as matrix product and the multiplication of two matrices, produces a single matrix. It is a type of binary operation

If A and B are the two matrices, then the product of the two matrices A and B are denoted by:

X = AB

Hence, the product of two matrices is the dot product of the two matrices.

### Matrix multiplication by Scalar

Multiplication of an integer with a matrix is simply a scalar multiplication.

We know that a matrix is an array of numbers. It consists of rows and columns. If you multiply a matrix by a scalar value, then it is known as scalar multiplication. Another case is that it is possible to multiply a matrix by another matrix. Let’s have a look at the example given below for the same.

We may define multiplication of a matrix by a scalar mathematically as:

If A = [aij]m × n is a matrix and k is a scalar, then kA is another matrix obtained by multiplying each element of A by the scalar k.

In other words, kA = k [aij]m × n = [k (aij)]m × n, that is, (i, j)th element of kA is kaij for all possible values of i and j.

Example: Multiply the matrix $$A=\begin{bmatrix} 3 &4 &-1 \\ 0 &9 & 5 \end{bmatrix}$$ by 4.

Solution:

Given,

$$A=\begin{bmatrix} 3 &4 &-1 \\ 0 &9 & 5 \end{bmatrix}$$

4 × A = $$4\times \begin{bmatrix} 3 &4 &-1 \\ 0 &9 & 5 \end{bmatrix}$$

Now, we have to multiply each element of the matrix A by 4.

$$=\begin{bmatrix} 12 &16 &-4 \\ 0 &36 & 20 \end{bmatrix}$$

This is the required matrix after multiplying the given matrix by the constant or scalar value, i.e. 4.

### Matrix multiplication Condition

To perform multiplication of two matrices, we should make sure that the number of columns in the 1st matrix is equal to the rows in the 2nd matrix. Therefore, the resulting matrix product will have a number of rows of the 1st matrix and a number of columns of the 2nd matrix. The order of the resulting matrix is the matrix multiplication order.

Now, let’s understand how to do matrix multiplication with different orders or different types of matrices.

## How to Multiply Matrices?

Let’s learn how to multiply matrices.

Consider matrix A which is a × b matrix and matrix B, which is a b ×c matrix.

Then, matrix C = AB is defined as the A × B matrix.

An element in matrix C, Cxy is defined as Cxy = Ax1By1 +….. + AxbBby =  $$\sum_{k=1}^{b}$$  AxkBky  for x = 1…… a  and y= 1…….c

This is one of the most important topics in class 12. Matrices for class 12 explains the types of matrices in detail.

### Notation

If A is a m×n matrix and B is a p×q matrix, then the matrix product of A and B is represented by:

X = AB

Where X is the resulting matrix of m×q dimension.

## Matrix Multiplication Formula

Let’s take an example to understand this formula.

Let’s say A and B are two matrices, such that,

$$A =\begin{bmatrix} A_{11} &A_{12} & \cdots & A_{1n}\\ A_{21} & A_{22} &\cdots & A_{2n} \\ &…………. &\\ A_{m1} & A_{m2} &\cdots & A_{mn} \end{bmatrix},$$   $$B= \begin{bmatrix} B_{11} &B_{12} & \cdots & B_{1n}\\ B_{21} &B_{22} &\cdots & B_{2n} \\ &………….& \\ B_{m1} & B_{m2} &\cdots & B_{mn} \end{bmatrix}$$

Then Matrix C = AB is denoted by

C = $$\begin{bmatrix} C_{11} C_{12} ……. C_{1c}\\ C_{21} C_{22} …….C_{2c}&\\ …………… &\\ C_{a1} C_{a2}…….C_{ac}\end{bmatrix}$$

An element in matrix C where C is the multiplication of Matrix A X B.

C = Cxy = Ax1By1 +….. + AxbBby =  $$\sum_{k=1}^{b}$$  AxkBky  for x = 1…… a  and y= 1…….c

## Algorithm for Matrix Multiplication

There has been a significant amount of work in recent years in the field of matrix multiplication algorithms as it has found its application in many areas. There are four types of algorithms:

• Iterative Algorithm
• Divide and conquer algorithm
• Sub-cubic algorithms
• Parallel and distributed algorithms

This is majorly used in various programming languages such as C, Java, etc., for online multiplication. The most common are 2×2, 3×3 and 4×4, multiplication of matrices.

The operation is binary with entries in a set on which the operations of addition, subtraction, multiplication, and division are defined. These operations are the same as the corresponding operations on real and rational numbers.

Although there are many applications of matrices, essentially,  multiplication of matrices is an operation in linear algebra. The linear mapping, which includes scalar addition and multiplication, is represented by matrix multiplication.

One can also find a wide range of algorithms on meshes. This type of algorithm is designed to minimize the inherent inefficiency of standard array algorithms where there can be a delay in the arrival of data from 2 different matrices.

### Matrix multiplication Rules

From the above defined formula and procedure, we can write the following rules and properties for matrix multiplication.

• The product of two matrices A and B is defined if the number of columns of A is equal to the number of rows of B.
• If AB is defined, then BA need not be defined
• If both A and B are square matrices of the same order, then both AB and BA are defined.
• If AB and BA are both defined, it is not necessary that AB = BA.
• If the product of two matrices is a zero matrix, it is not necessary that one of the matrices is a zero matrix.

## 2×2 Matrix Multiplication

Let’s consider a simple 2 × 2 matrix multiplication A = $$\begin{bmatrix} 3 & 7\\ 4 & 9 \end{bmatrix}$$ and another matrix B = $$\begin{bmatrix} 6 & 2\\ 5 & 8 \end{bmatrix}$$

Now each of the elements of product matrix AB can be calculated as follows:

• AB11 = 3 × 6 + 7 ×5 = 53
• AB12 = 3 × 2 + 7 × 8 = 62
• AB21 = 4 × 6 + 9 × 5 = 69
• AB22 = 4 × 2 + 9 × 8 = 80

Therefore matrix AB = $$\begin{bmatrix} 53&62 \\ 69 & 80 \end{bmatrix}$$

## 3×3 Matrix Multiplication

To understand the multiplication of two 3 × 3 matrices, let us consider two 3 × 3 matrices A and B.

Matrix A = $$\begin{bmatrix} 12 &8 &4 \\ 3&17 &14 \\ 9 & 8& 10 \end{bmatrix}$$,  Matrix B = $$\begin{bmatrix} 5 & 19 &3 \\ 6 &15 &9 \\ 7& 8 & 16 \end{bmatrix}$$

Each element of the Product matrix AB can be calculated as follows:

• AB11 = 12×5 + 8×6 + 4×7 = 136
• AB12 = 12×19 + 8×15 + 4×8 = 380
• AB13 = 12×3 + 8×9+4×16 = 172
• AB21 = 3×5 + 17×6 + 14×7 = 215
• AB22 = 3×19 + 17×15 + 14×8 = 424
• AB23 = 3×3 + 17×9 + 14×16 = 386
• AB31 = 9×5 + 8×6 + 10×7 = 163
• AB32 = 9×19 + 8×15 + 10×8 = 371
• AB33 = 9×3 + 8×9 + 10×16 = 259

Therefore, Matrix AB = $$\begin{bmatrix} 136 & 380 &172 \\ 215 &424 &386 \\ 163& 371 & 259 \end{bmatrix}$$

Try out:   Matrix Multiplication Calculator

## Properties of Matrix Multiplication

The following are the properties of the matrix multiplication:

### Commutative Property

The matrix multiplication is not commutative.

Assume that, if A and B are the two 2×2 matrices,

AB ≠ BA

In matrix multiplication, the order matters a lot.

For example,

If $$A = \begin{bmatrix} 1 & 2\\ 3 & 4 \end{bmatrix}$$ and $$B = \begin{bmatrix} 3 & 2\\ 1 & 4 \end{bmatrix}$$ are the two matrices, then

$$A\times B = \begin{bmatrix} 1 & 2\\ 3 & 4 \end{bmatrix}\times \begin{bmatrix} 3 & 2\\ 1 & 4 \end{bmatrix}$$

$$A\times B = \begin{bmatrix} 5 & 10\\ 13 & 22 \end{bmatrix}$$

But,

$$B\times A = \begin{bmatrix} 3 & 2\\ 1 & 4 \end{bmatrix}\times \begin{bmatrix} 1 & 2\\ 3 & 4 \end{bmatrix}$$

$$B\times A = \begin{bmatrix} 9 & 14\\ 13 & 18 \end{bmatrix}$$

This shows that the matrix AB BA.

Hence, the multiplication of two matrices is not commutative.

### Associative Property

If A, B and C are the three matrices, the associative property of matrix multiplication states that,

(AB) C = A(BC)

Let  $$A =\begin{bmatrix} 1 & 2\\ 1& 1 \end{bmatrix}$$

$$B =\begin{bmatrix} 3 & 2\\ 1& 2 \end{bmatrix}$$

$$C =\begin{bmatrix} 0 & 1\\ 2& 3 \end{bmatrix}$$

LHS = (AB) C

$$A\times B = \begin{bmatrix} 1 & 2\\ 1 & 1 \end{bmatrix} \times \begin{bmatrix} 3 & 2 \\ 1 & 2 \end{bmatrix}$$

$$A\times B = \begin{bmatrix} 5 & 6\\ 4 & 4 \end{bmatrix}$$

$$(AB)C = \begin{bmatrix} 5 & 6\\ 4 & 4 \end{bmatrix} \times \begin{bmatrix} 0 & 1\\ 2 & 3 \end{bmatrix}$$

$$(AB)C = \begin{bmatrix} 12 & 23\\ 8 & 16 \end{bmatrix}$$

RHS =  A(BC)

$$BC = \begin{bmatrix} 3 & 2\\ 1 & 2 \end{bmatrix}\times \begin{bmatrix} 0 & 1\\ 2 & 3 \end{bmatrix}$$

$$BC = \begin{bmatrix} 4 & 9\\ 4 & 7 \end{bmatrix}$$

$$A(BC)= \begin{bmatrix} 1 & 2\\ 1 & 1 \end{bmatrix}\times \begin{bmatrix} 4 & 9\\ 4 & 7 \end{bmatrix}$$

$$A(BC)= \begin{bmatrix} 12 & 23\\ 8 & 16 \end{bmatrix}$$

Hence, the associative property of matrix multiplication is proved.

### Distributive Property

If A, B and C are the three matrices, the distributive property of matrix multiplication states that,

• (B+C)A = BA +CA
• A(B+C) = AB + AC

### Multiplicative Identity Property

The identity property of matrix multiplication states that,

1. I = I. A = A

Where A is an n× n matrix and “I” is an identity matrix of order n.

Let $$A = \begin{bmatrix} 2 & 3\\ 1 & 6 \end{bmatrix}$$ and $$I = \begin{bmatrix} 1 & 0\\ 0 & 1 \end{bmatrix}$$

$$A . I = \begin{bmatrix} 2 & 3\\ 1 & 6 \end{bmatrix}\times \begin{bmatrix} 1 & 0\\ 0 & 1 \end{bmatrix}$$

$$A . I = \begin{bmatrix} 2 & 3\\ 1 & 6 \end{bmatrix} = A$$

### Dimension Property

In matrix multiplication, the product of m × n matrix and n×a matrix is the m× a matrix.

For example, matrix A is a 2 × 3 matrix and matrix B is a 3 × 4 matrix, then AB is a 2 × 4 matrices.

### Multiplicative property of Zero

If a matrix is multiplied by a zero matrix, the result matrix is a zero matrix.

If $$A = \begin{bmatrix} 2 & 1\\ 1 & 2 \end{bmatrix}$$ is multiplied by zero matrix (i.e.,)$$\begin{bmatrix} 0 & 0\\ 0 & 0 \end{bmatrix}$$, the product becomes $$\begin{bmatrix} 0 & 0\\ 0 & 0 \end{bmatrix}$$

## Solved Example

Multiplication of 4×4 matrices is explained below with two 4×4 matrices A and B.

A = $$\begin{bmatrix} 7 & 14 & 15 &6 \\ 4 &8 & 12 &3 \\ 14 & 21 & 6 &9 \\ 13 & 7 &6 & 4 \end{bmatrix}$$,  B = $$\begin{bmatrix} 5& 7 & 14 & 2\\ 8& 16 & 4 & 9\\ 13 & 6& 8 & 4\\ 6& 3 & 2 & 4 \end{bmatrix}$$

Following the same steps as in the previous 2 examples, we can construct an AB matrix.

AB = $$\begin{bmatrix} 378 &381 & 286 &224 \\ 258 & 237 & 190 & 140\\ 370 & 497& 346 & 277\\ 223& 251& 266 & 129 \end{bmatrix}$$

### Practice Problems on Matrix Multiplication

Solve the following problems:

1. Find the product: $$3\begin{bmatrix} 7 & 5\\ 2 & 1 \end{bmatrix}$$
2. Simplify the following 3×3 matrix: $$\begin{bmatrix} 1 & 6 & 2 \\ 2 & 3 & 1\\ 1 & 1 & 5 \end{bmatrix}\times \begin{bmatrix} 1 & 8 & 7 \\ 4 & 2 & 3 \\ 2 & 6 & 1 \end{bmatrix}$$
3. Find the product of AB, if $$A =\begin{bmatrix} 5 & 3\\ 9 & 1 \end{bmatrix}$$ and $$B =\begin{bmatrix} 1 & 0\\ 6 & 12 \end{bmatrix}$$
4. Find the product of the matrix, if $$A = \begin{bmatrix} 4\\ 2\\ 1 \end{bmatrix}$$ and $$\begin{bmatrix} 2 & 4 & 6 \end{bmatrix}$$
5. Calculate: $$\frac{-4}{7}\begin{bmatrix} -22\\ 49\\ 35 \end{bmatrix}$$

## Frequently Asked Questions – FAQs

### What is matrix multiplication?

Matrix multiplication is a method of finding the product of two matrices to get the result as one matrix. It is a type of binary operation.

### How to multiply two given matrices?

To multiply one matrix with another, we need to check first, if the number of columns of the first matrix is equal to the number of rows of the second matrix. Now multiply each element of the column of the first matrix with each element of rows of the second matrix and add them all. We need to do the dot product of columns and rows here.

### What is the result of multiplication of (2×3) matrix and (3×3) matrix?

The result of multiplication of (2×3) matrix and (3×3) matrix will be 2×3 matrix only.

### How to multiply 3×3 matrix?

Multiply each row of the first matrix with each column of the second matrix and add all to get the first element. Similarly, multiply and add the elements of the two matrices, column and row-wise, to get the elements of the product of two 3×3 matrices.

### How do we find the multiplication of two matrices?

If A is a m×n matrix and B is a p×q matrix, then the multiplication of A and B is denoted by dot matrix, such as:
C = AB
Thus, C will be an m×q matrix.