Open In App

Matrix Multiplication

Improve
Improve
Like Article
Like
Save
Share
Report

Matrix Multiplication is the product of two matrices that result in the formation of one matrix. It is a binary operation performed on two matrices to get a new matrix called the product matrix. Two matrices can only be multiplied if the number of columns of the first matrix is equal to the number of rows of the second matrix.

In this article, we will learn about, Matrix Multiplication, How to Multiply Matrices, Rules for Matrix Multiplication, Examples of Matrix Multiplication, and others in detail.

What is Matrix Multiplication?

Matrix multiplication is the mathematical operation that is performed on two matrices which when multiplied gives a singular matrix. As we can perform multiplication on any two numbers we can not perform multiplication on any two matrices. We have to follow specific rules to perform matrix multiplication and the matrices obeying a certain relation are the matrices that can be multiplied.

Suppose we take two matrices A and B such that the number of columns in the first matrix is equal to the number of rows in the second matrix then we can multiply these two matrices to get a new matrix of the same order that is called the multiplication of the two matrices A and B.

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.” this condition is represented as,

Condition for matrix multiplication

Matrix multiplication is not commutative, i.e., AB ≠ BA, or, in simple words, the product of A and B matrices is AB and AB is not equal to BA it is even possible that AB exists but BA does not exist.

Note: French mathematician Jacques Philippe Marie Binet was the first to perform matrix multiplication in 1812.

How to Multiply Matrices?

Multiplication of the matrix follows a special rule to find the product. Suppose we have to find the multiplication of two matrices A and B where the number of columns in A is equal to the number of rows in B such that the multiplication of A and B is obtained in such a way that we multiply the first row of the first matrix with the first column of the second matrix to get the first element of the multiplied matrix. We follow the steps discussed below to find the matrix multiplication.

Step 1: Check the compatibility of the matrix by checking that the number of columns in the 1st matrix equals the number of rows in the 2nd matrix.

Step 2: Multiply the elements in the first row of the first matrix with the elements in the first column of the matrix and find the sum of all the products. Then multiply the element in the first row of the first matrix with the elements of the second column in the second matrix. Repeat this process till elements of all the positions are not obtained.

Step 3: Substitute all the elements obtained in Step 2 in their respective position to find the required product matrix.

Rules for Matrix Multiplication

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.

  • Let’s take 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 in the first matrix is similar to the number of rows in the second matrix. The order of the resultant matrix is 2×2.
  • Now let’s take another matrix of size 3×3 and other matrices of size 4×2, then we cannot multiply these two matrices as the number of columns in the first matrix is not equal to the number of rows in the second matrix.

Matrix Multiplication Notation

We represent a multiplication matrix as the multiplication of two matrices A and B such that the order of A is m×p and the order of B is p×n then the order of the multiplied matrix is m×n. The

X = AB

where,

  • X is Resulting Matrix of m×n Order
  • A and B are Given Matrix of Order m×p and p×n

Matrix Multiplication Formula

Let’s take two matrices A and B of order 3×3 such that A = [aij] and B = [bij]. Then the multiplication of A and B is obtained in the image such that,

Matrix Multiplication

The resultant multiplication matrix X is represented as,

X = [Tex]\left[\begin{array}{cc} X_{11} & X_{12}…..X_{1n}\\ X_{21} & X_{22}…..X_{2n} \\……….\\X_{m1} & X_{m2}…..X_{mn}\end{array}\right] [/Tex]

where,

Xxy = Ax1By1 + …..+ AxbBby = Σk= 1b AxkBky

Algorithm for Matrix Multiplication

There are various matrix multiplication algorithms that are widely used for finding matrix multiplication and some of the most common matrix multiplication algorithms are,

  • Iterative Algorithm
  • Divide and Conquer Algorithm
  • Sub-Cubic Algorithms
  • Parallel and Distributed Algorithms

These algorithms are widely used in computer programing to find the multiplication of two matrices such that the results are efficient and take lesser memory and time. They are used to find 2×2, 3×3, and 4×4, multiplication of matrices.

We use these matrix multiplication algorithms for a variety of purposes and the method to multiply matrics is similar for any order of matrix for a particular algorithm.

Matrix multiplication Rules

Some rules for matrix multiplication are,

  • 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 multiplication of matrix is defined, then BA multiplication matrix may or may not be defined.
  • Both AB and BA matrix multiplication are defined if both A and B are square matrix.
  • It is not necessary that one of the matrices is a zero matrix if the product of two matrix A and B is zero.

2×2 Matrix Multiplication Formula

Let us consider two matrices A and B of order “2 × 2”. Then its multiplication is achieved using the formula.

[Tex]A = \left[\begin{array}{cc} a & b\\ c & d \end{array}\right] and B = \left[\begin{array}{cc} p & q\\ r & s \end{array}\right] [/Tex]

[Tex]AB = \left[\begin{array}{cc} a & b\\ c & d \end{array}\right] \times \left[\begin{array}{cc} p & q\\ r & s \end{array}\right] [/Tex]

[Tex]AB = \left[\begin{array}{cc} (ap+br) & (aq+bs)\\ (cp+dr) & (cq+ds) \end{array}\right] [/Tex]

3×3 Matrix Multiplication Formula

Let us consider two matrices P and Q of order “3 × 3”. Now, the matrix multiplication formula of “3 × 3” matrices is,

[Tex]X = \left[\begin{array}{ccc} x_{11} & x_{12} & x_{13}\\ x_{21} & x_{22} & x_{23}\\ x_{31} & x_{32} & x_{33} \end{array}\right] [/Tex]

[Tex]Y = \left[\begin{array}{ccc} y_{11} & y_{12} & y_{13}\\ y_{21} & y_{22} & y_{23}\\ y_{31} & y_{32} & y_{33} \end{array}\right] [/Tex]

[Tex]XY = \left[\begin{array}{ccc} (x_{11}y_{11}+x_{12}y_{21}+x_{13}y_{31}) & (x_{11}y_{12}+x_{12}y_{22}+x_{13}y_{32}) & (x_{11}y_{13}+x_{12}y_{23}+x_{13}y_{33})\\ (x_{21}y_{11}+x_{22}y_{21}+x_{23}y_{31}) & (x_{21}y_{12}+x_{22}y_{22}+x_{23}y_{32}) & (x_{21}y_{13}+x_{22}y_{23}+x_{23}y_{33})\\ (x_{31}y_{11}+x_{32}y_{21}+x_{33}y_{31}) & (x_{31}y_{12}+x_{32}y_{22}+x_{33}y_{32}) & (x_{31}y_{13}+x_{32}y_{23}+x_{33}y_{33}) \end{array}\right] [/Tex]

We can understand this using the example of matrix multiplication discussed below.

Example: Multiply the matrices given below.

[Tex]\left[\begin{array}{ccc} 3 & -5 & 1\\ -2 & 0 & 4\\ -1 & 6 & 5 \end{array}\right]\left[\begin{array}{ccc} 7 & 2 & 4\\ 0 & 1 & -5\\ 1 & 3 & 2 \end{array}\right] [/Tex]

[Tex]\left[\begin{array}{ccc} 3 & -5 & 1\\ -2 & 0 & 4\\ -1 & 6 & 5 \end{array}\right]\times\left[\begin{array}{ccc} 7 & 2 & 4\\ 0 & 1 & -5\\ 1 & 3 & 2 \end{array}\right] [/Tex]

[Tex]=\left[\begin{array}{ccc} (21-0+1) & (6-5+3) & (12-25+2)\\ (-14+0+4) & (-4+0+12) & (-8-0+10)\\ (-7+0+5) & (-2+6+15) & (-4-30+10) \end{array}\right] [/Tex]

[Tex]=\left[\begin{array}{ccc} 22 & 4 & -11\\ -10 & 8 & 2\\ -2 & 19 & -24 \end{array}\right] [/Tex]

Matrix Multiplication by Scalar

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: 

[Tex]A = \left[\begin{array}{cc} a & b\\ c & d \end{array}\right] [/Tex]

[Tex]kA = k \times\left[\begin{array}{cc} a & b\\ c & d \end{array}\right]= \left[\begin{array}{cc} ka & kb\\ kc & kd \end{array}\right] [/Tex]

Properties of Matrix Multiplication

The following are some important properties of matrix multiplication:

Commutative Property

The matrix multiplication is usually not commutative i.e. the multiplication of the first matrix with the second matrix is not similar to the multiplication of the second matrix with the first. 

  • 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

This property holds true if the products A(BC) and (AB)C are defined.

Distributive Property

Distributive property also holds true for matrix multiplication. If A, B, and C are three matrices, then by applying the distributive property, we get 

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

This property is only true 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 the product of the matrix with the scaler(k) is defined as,

k(AB) = (kA)B = A(Bk)

Determinant of Matrix Multiplication

If A and B are two matrices and AB is defined as the multiplication product of A and B, 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 of Matrix Multiplication

If A and B are two matrices and AB is defined as the multiplication of the two matrices then,

(AB)T = BTAT

Multiplicative Identity Property

Matrix multiplication has an identity property that states that, if we multiply a matrix A by an Identity matrix of the same order then, it results in the same matrix.

A.I = I. A = A

Multiplicative Property of Zero

Matrix multiplication has the property of zero which states that, If a matrix is multiplied by a zero matrix, then the resultant matrix is a zero matrix(O).

A.O = O.A = O

Also, the product of any two non-zero matrices may result in a zero matrix, i.e.,

AB = O

Then that doesn’t mean that A = O or B = O.

Read More,

Examples on Matrix Multiplication

Some examples on Matrix Multiplication are,

Example 1. Let [Tex]A~=~\begin{bmatrix} 1 & 8 & 3\\ 9 & 4 & 5 \\ 6 & 2 & 7 \end{bmatrix} [/Tex] and [Tex]B =\begin{bmatrix} 6 & 7 & 4\\ 1 & 3 & 2 \\ 5 & 9 & 8 \end{bmatrix} [/Tex] Find A×B?

Solution: 

[Tex]A \times B =\begin{bmatrix} 1 & 8 & 3\\ 9 & 4 & 5 \\ 6 & 2 & 7 \end{bmatrix} \times \begin{bmatrix} 6 & 7 & 4\\ 1 & 3 & 2 \\ 5 & 9 & 8 \end{bmatrix}              [/Tex] 

=[Tex]\begin{bmatrix} (1×6 + 8×1 + 3×5) & (1×7 + 8×3 + 3×9) & (1×4 + 8×2 + 3×8)\\ (9×6 + 4×1 + 5×5) & (9×7 + 4×3 + 5×9) & (9×4 + 4×2 + 5×8) \\ (6×6 + 2×1 + 7×5) & (6×7 + 2×3 + 7×9) & (6×4 + 2×2 + 7×8) \end{bmatrix} [/Tex]

[Tex]=\begin{bmatrix} 29 & 58 & 44\\ 83 & 120 & 84 \\ 73 & 111 & 84 \end{bmatrix} [/Tex]

Example 2. Let  [Tex]A =\begin{bmatrix} 1 & 5 & 4\\ 9 & 3 & 8 \end{bmatrix}          [/Tex] and [Tex]B =\begin{bmatrix} 6 & 7 \\ 1 & 3   \\ 5 & 9 \end{bmatrix}          [/Tex]. Find A×B?

Solution:

[Tex]A \times B =\begin{bmatrix} (1×6 + 5×1 + 4×5) & (1×7 + 5×3 + 4×9) \\ (9×6 + 3×1 + 8×5) & (9×7 + 3×3 + 8×9)\end{bmatrix} [/Tex]

[Tex] =\begin{bmatrix} 31 & 58 \\ 97 & 144\end{bmatrix} [/Tex]

Example 3. Let [Tex]A=\begin{bmatrix} 2 & 0 & -3\\ 1 & 4 & 5 \end{bmatrix}          [/Tex],  [Tex]B=\begin{bmatrix} 3 & 1\\ -1 & 0 \\ 4 & 2\end{bmatrix}          [/Tex]  and [Tex]C=\begin{bmatrix} 4 & 7\\ 2 & 1 \\ 1 & -1\end{bmatrix}          [/Tex]. Find (AB + AC)?

Solution:

[Tex]A \times B = \begin{bmatrix} 2 & 0 & -3\\ 1 & 4 & 5 \end{bmatrix}\times \begin{bmatrix} 3 & 1\\ -1 & 0 \\ 4 & 2\end{bmatrix} \\ = \begin{bmatrix} (2×3 + 0×(-1) + (-3)×4) & (2×1 + 0×0 + (-3)×2) \\ (1×3 + 4×(-1) + 5×4) & (1×1 + 4×0 + 5×2)\end{bmatrix} [/Tex]

[Tex]=\begin{bmatrix} -6 & -4 \\ 19 & 11\end{bmatrix} [/Tex]

[Tex]A \times C = \begin{bmatrix} 2 & 0 & -3\\ 1 & 4 & 5 \end{bmatrix}\times \begin{bmatrix} 4 & 7\\ 2 & 1 \\ 1 & -1\end{bmatrix} \\ = \begin{bmatrix} (2×4 + 0×2 + (-3)×1) & (2×7 + 0×1 + (-3)×(-1)) \\ (1×4 + 4×2 + 5×1) & (1×7 + 4×1 + 5×(-1))\end{bmatrix} [/Tex]

[Tex]=\begin{bmatrix} 5 & 17 \\ 17 & 6\end{bmatrix} [/Tex]

Now calculate (AB + AC)

[Tex]= \begin{bmatrix} -6 & -4 \\ 19 & 11\end{bmatrix} + \begin{bmatrix} 5 & 17 \\ 17 & 6\end{bmatrix} [/Tex]

[Tex](AB +BC)= \begin{bmatrix} -1 & 13 \\ 36 & 17\end{bmatrix} [/Tex]

Example 4. Let [Tex]A=\begin{bmatrix} 2  & -2\\ -2 & 2\end{bmatrix}      [/Tex], and A2 = pA, then find the value of p?

Solution:

Calculating, A2

A2 = A×A = [Tex]\begin{bmatrix} 2  & -2\\ -2 & 2\end{bmatrix} \times \begin{bmatrix} 2  & -2\\ -2 & 2\end{bmatrix} [/Tex]

=[Tex]\begin{bmatrix} (2×2 + (-2)×(-2)) & ((2×(-2) + (-2)×2)  \\ ((-2)×2 + 2×(-2)) & ((-2)×(-2) + 2×2)\end{bmatrix} [/Tex]

[Tex]=\begin{bmatrix} 8 & -8\\ -8 & 8\end{bmatrix} [/Tex]

Given,

A2 = pA

Taking A2 in the equation,

[Tex]\begin{bmatrix} 8 & -8\\ -8 & 8\end{bmatrix} = p\begin{bmatrix} 2 & -2\\ -2 & 2\end{bmatrix} [/Tex]

[Tex]\begin{bmatrix} 8 & -8\\ -8 & 8\end{bmatrix} = \begin{bmatrix} 2p & -2p\\ -2p & 2p\end{bmatrix} [/Tex]

Now,

  • 8 = 2p
  • -8 = -2p

p = 4

Thus, the value of p is 4

Example 5: Find the value of 3P if [Tex]P = \left[\begin{array}{ccc} 2 & -3 & 4\\ 1 & 0 & 5\\ 7 & -4 & 6 \end{array}\right]           [/Tex].

Solution:

[Tex]3P = 3 \times\left[\begin{array}{ccc} 2 & -3 & 4\\ 1 & 0 & 5\\ 7 & -4 & 6 \end{array}\right] [/Tex]

[Tex]3P = \left[\begin{array}{ccc} 3\times2 & 3\times-3 & 3\times4\\ 3\times1 & 3\times0 & 3\times5\\ 3\times7 & 3\times-4 & 3\times6 \end{array}\right] [/Tex]

[Tex]3P = \left[\begin{array}{ccc} 6 & -9 & 12\\ 3 & 0 & 15\\ 21 & -12 & 18 \end{array}\right] [/Tex]

Practice Problems on Matrix Multiplication

Solve the following problems:

P1: Find 9P if [Tex]P~=~\left[\begin{array}{ccc} 2 & -3 & 4\\ 1 & 0 & 5\\ 7 & -4 & 6 \end{array}\right] [/Tex].

P2: Multiply, [Tex]P~=~\left[\begin{array}{ccc} 2 & -3 & 4\\ 1 & 0 & 5\\ 7 & -4 & 6 \end{array}\right] [/Tex] and [Tex]Q~=~\left[\begin{array}{ccc} 3 & -6 & 9\\ 7 & 0 & 8\\ 1 & -4 & 1 \end{array}\right] [/Tex]

P3: Find the product of AB [Tex]A~=~\left[\begin{array}{ccc} 1 & -2 & 3\\ 9 & 0 & 6\\ 8 & -4 & 1 \end{array}\right] [/Tex] and [Tex]B~=~\left[\begin{array}{ccc} 0 & -12 & 7\\ 0 & 0 & 3\\ -21 & -6 & 8 \end{array}\right] [/Tex]

Frequently Asked Questions on Matrix Multiplication

Define Matrix Multiplication.

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.

Can you Multiply Matrices of Order 2×3 and 2×2?

Now we can not multiply matrices of order 2×3 and 2×2 as the first matrix of order 2×3 has 2 columns, while the second matrix of order 2×2 has 3 rows. Now the number of columns in the first matrix(3) is not equal to the number of rows in the second matrix(2).

How to find the Multiplication of Two Matrices?

Multiplication of any two matrices is achieved only when the number of columns in the first matrix equals the number of rows in the second matrix. That is the order of the matrices should be like Am×n and Bn×p now if we multiply the matrices A and B we get, A×B = [AB]m×p

What is Result of Multiplication of (2×3) Matrix and (3×3) Matrix?

The result of multiplication of (2×3) matrix and (3×3) matrix is a matrix of order, (2×3).

When is Matrix Multiplication Possible?

Matrix multiplication between 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, i.e. if the given matrices are [A]m×n, [B]n×p then the multiplication of matrix is achieved as, A×B = [AB]m×p

Is Matrix Multiplication always Commutative?

No, matrix multiplication does not hold the commutative property, i.e. If A and B are two matrices the, A×B ≠ B×A

What is Matrix Multiplication Formula?

For matrix A = [aij] of order m×n and matrix B = [bij] of order n×p matrix, the product AB is a matrix of order m×p. where cij = ai1b1j + ai2b2j + …



Last Updated : 05 Mar, 2024
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads