For introduction on matrices, you can refer the following article: Matrix Introduction

In this article, we will discuss various operations on matrices and their properties:

**Matrices Addition –**

The addition of two matrices A _{m*n} and B_{m*n} gives a matrix C_{m*n}. The elements of C are sum of corresponding elements in A and B which can be shown as:

The algorithm for addition of matrices can be written as:

for i in 1 to m for j in 1 to n c_{ij}= a_{ij}+ b_{ij}

**Key points:**

- Addition of matrices is commutative which means A+B = B+A
- Addition of matrices is associative which means A+(B+C) = (A+B)+C
- The order of matrices A, B and A+B is always same
- If order of A and B is different, A+B can’t be computed
- The complexity of addition operation is O(m*n) where m*n is order of matrices

**Matrices Subtraction –**

The subtraction of two matrices A_{m*n} and B_{m*n} gives a matrix C_{m*n}. The elements of C are difference of corresponding elements in A and B which can be represented as:

The algorithm for subtraction of matrices can be written as:

for i in 1 to m for j in 1 to n c_{ij}= a_{ij}-b_{ij}

**Key points:**

- Subtraction of matrices is non-commutative which means A-B ≠ B-A
- Subtraction of matrices is non-associative which means A-(B-C) ≠ (A-B)-C
- The order of matrices A, B and A-B is always same
- If order of A and B is different, A-B can’t be computed
- The complexity of subtraction operation is O(m*n) where m*n is order of matrices

**Matrices Multiplication –**

The multiplication of two matrices A_{m*n} and B_{n*p} gives a matrix C_{m*p}. It means number of columns in A must be equal to number of rows in B to calculate C=A*B. To calculate element c11, multiply elements of 1st row of A with 1st column of B and add them (5*1+6*4) which can be shown as:

The algorithm for multiplication of matrices A with order m*n and B with order n*p can be written as:

for i in 1 to m for j in 1 to p c_{ij}= 0 for k in 1 to n c_{ij}+= a_{ik}*b_{kj}

**Key points:**

- Multiplication of matrices is non-commutative which means A*B ≠ B*A
- Multiplication of matrices is associative which means A*(B*C) = (A*B)*C
- For computing A*B, the number of columns in A must be equal to number of rows in B
- Existence of A*B does not imply existence of B*A
- The complexity of multiplication operation (A*B) is O(m*n*p) where m*n and n*p are order of A and B respectively
- The order of matrix C computed as A*B is m*p where m*n and n*p are order of A and B respectively

Read next – Determinant of a Matrix, Adjoint and Inverse of a Matrix

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the **DSA Self Paced Course** at a student-friendly price and become industry ready.

## Recommended Posts:

- Count of matrices (of different orders) with given number of elements
- Program for addition of two matrices
- Program for subtraction of matrices
- Program to check if two given matrices are identical
- Mathematics | Representations of Matrices and Graphs in Relations
- Multiplication of two Matrices in Single line using Numpy in Python
- Python program to add two Matrices
- Python program to multiply two matrices
- Count sub-matrices having sum divisible 'k'
- Python List Equality | Program to check if two given matrices are identical
- Kronecker Product of two matrices
- A square matrix as sum of symmetric and skew-symmetric matrices
- Count pairs from two sorted matrices with given sum
- Queries on number of Binary sub-matrices of Given size
- Find the intersection of two Matrices
- Minimum elements to be added so that two matrices can be multiplied
- XOR of XORs of all sub-matrices
- Check if matrix can be converted to another matrix by transposing square sub-matrices
- Properties of Determinants of Matrices
- Number of square matrices with all 1s

This article is contributed by **Sonal Tuteja**. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.