 GeeksforGeeks App
Open App Browser
Continue

# How to Multiply Matrices?

The knowledge of matrices is necessary for various branches of mathematics. Matrices are one of the most powerful tools in mathematics. In linear algebra, matrix multiplication is one of the binary operations that can be performed on matrices. The multiplication of any two matrices A and B is possible only if both matrices are compatible.  A “matrix” is referred to as a rectangular array of numbers that are arranged in rows and columns. The horizontal lines are said to be rows, while the vertical lines are said to be columns. If a matrix has “m” rows and “n” columns, then it is said to be an “m by n” matrix and is written as an “m × n” matrix. We can perform different binary operations on matrices, like addition, subtraction, multiplication, etc. In this article, we will learn about matrix multiplication in detail.

## Multiplication of Matrices

Matrix multiplication is a very simple thing in mathematics. If do multiply with a number, then just multiply the number with all the elements present in the matrix. But if we multiply a matrix with another matrix then we must see some rules. The multiplication of any two matrices gives a single matrix, and it is possible only if the number of columns in the 1st matrix is equal to the number of rows in the 2nd matrix. If “A = [aij]m×n” and “B = [bij]n×p” are two matrices, then the product of A and B is denoted as AB, whose order is “m × p.” Usually, matrix multiplication is not commutative, i.e., AB ≠ BA, or, in simple words, the product of A and B matrices is AB but not BA.

### Conditions for Multiplication of Matrices

Note that the multiplication of any two matrices is possible only if both matrices are compatible. We can multiply two matrices if the number of columns in the 1st matrix is equal to the number of rows in the 2nd matrix, otherwise, the given matrices cannot be multiplied.

1. Let’s say a matrix of size 2×3 and another matrix of size 3×2, then we can apply the multiplication between those matrices because the number of columns and rows are the same in both the matrices. And the resultant matrix will be 2×2
2. Let’s say a matrix of size 3×3 and another matrix of size 4×2, then we cannot apply the multiplication between those matrices because the number of columns and rows are not the same in both the matrices.

### Multiplying Matrices by Matrices

Let’s consider 2 matrices of 3 × 3 have elements [aij] and [bij] respectively. The multiplication will be like the below image: There is some rule,

1. Take the first matrix’s 1st row and multiply the values with the second matrix’s 1st column. Don’t multiply the rows with the rows or columns with the columns.
2. In 1st iteration, multiply the row value by the column value and sum those values. Here in this picture, [a00] is multiplying with [b00], then the 2nd value of the 1st column of 1st matrix [a10] is multiplying with the 2nd value of the 1st row of the 2nd matrix [b01].  Similarly, all the values are multiplying.
3. Then after one iteration all the production values are summed up together and placed as the elements of the resultant matrix as the picture shows.

### Matrix Multiplication formula for “2 × 2” Matrices

The process of multiplication is the same for matrices for any order. We must multiply each element of each row of the first matrix by the elements of each column in the second matrix and add all the products to obtain the resultant matrix. Let us consider two matrices “2 × 2” matrices A and B.   ### Matrix Multiplication formula for “3 × 3” Matrices

Let us consider two matrices “3 × 3” matrices P and Q. Now, the matrix multiplication formula of “3 × 3” matrices are shown as follows:   Example: Multiply the matrices given below. Solution:   ### Matrix multiplication by a Scalar Value

A matrix can be multiplied by a scalar value, which is called scalar multiplication, and also by a matrix, which is called matrix multiplication. Scalar multiplication is the multiplication of a matrix by a scalar value. When a matrix “A = [aij]” is multiplied by a scalar value “k,” every element of the given matrix is multiplied by the scalar value. The resultant matrix is expressed as kA, where kA = k[aij] = [kaij], for all the values of i and j.

Example:  ## Properties of Multiplication of Matrices

The following are some important properties of the multiplication of matrices:

• Commutative Property: The matrix multiplication is usually not commutative. If A and B are two matrices, then AB ≠ BA.
• Associative Property: The matrix multiplication is associative in nature. If A, B, and C are three matrices, then A(BC) = (AB)C if the products A(BC) and (AB)C are defined.
• Distributive Property: If A, B, and C are three matrices, then by applying the distributive property, we get A (B + C) = AB + BC, if and only if A, B, and C are compatible.
• Product with a Scalar: If A and B are two matrices and AB is defined, then k(AB) = (kA)B = A(Bk), where k is a scalar value.
• Determinant: If A and B are two matrices and AB is defined, then the determinant of the matrix “AB” is equal to the product of the determinants of matrices A and B, i.e., det (AB) = det A × det B.
• Transpose: If A and B are two matrices and AB is defined, then (AB)T = BTAT, where T represents the transpose of a matrix.
• Complex Conjugate: If A and B are two complex matrices, then (AB)* = B*A*.
The product of any two non-zero matrices may result in a zero matrix, i.e., if AB = O, then that doesn’t mean that A = O or B = O.

## Solved Examples

Example 1. Let and Find A×B?

Solution:   Example 2. Let and . Find A×B?

Solution:  Example 3. Let , and . Find (AB + AC)?

Solution:    Now calculate (AB + AC)  Example 4. Let , and , then find the value of p?

Solution:

First, calculate A2,   Given By placing the value of A2 in the equation, we get  Now, we can write,

8 = 2p and, -8 = -2p

So, p = 4

The value of p is 4.

Example 5: Find the value of 3P if .

Solution:   ## FAQs on Multiplication of Matrices

Question 1: What is matrix multiplication?

In linear algebra, matrix multiplication is one of the binary operations that can be performed on matrices. The multiplication of any two matrices is possible only when the number of columns in the first matrix is equal to the number of rows in the second matrix.

Question 2: Can a “3 × 2” matrix be multiplied with a “3 × 3” matrix?