# Matrix Multiplication Tutorial

## Matrix Multiplication Tutorial

##### Multiplication Matrices :

In the first part we will look in to the multiplication of square matrices. In the next part you will learn to multiply different order matrices (e.g: 2x3 to 3x3). Here we will multiply a 3x3 matrix (3 rows, 3 columns) to another 3x3 matrix (3 rows, 3 columns).

Matrix A Matrix B
 a11 a12 a13 a21 a22 a23 a31 a32 a33
x
 b11 b12 b13 b21 b22 b23 b31 b32 b33

The resulting matrix will be a 3x3 matrix. We will have to calculate each cell of the result matrix separately. Let us assume the result to be X.

###### Step 1:

To calculate x11 x11 is the cell where first row merges with first column. So in order to calculate the result we will use the first row of Matrix A and first column of Matrix B.

Result X Matrix A Matrix B
 x11 x12 x13 x21 x22 x23 x31 x32 x33
=
 a11 a12 a13 a21 a22 a23 a31 a32 a33
x
 b11 b12 b13 b21 b22 b23 b31 b32 b33

Now x11 can be calculated as x11 = a11xb11 + a12xb21 + a13xb31

###### Step 2:

To calculate x12 x12 is the cell where first row merges with second column. So in order to calculate the result we will use the first row of Matrix A and second column of Matrix B.

Result X Matrix A Matrix B
 x11 x12 x13 x21 x22 x23 x31 x32 x33
=
 a11 a12 a13 a21 a22 a23 a31 a32 a33
x
 b11 b12 b13 b21 b22 b23 b31 b32 b33

Now x12 can be calculated as x12 = a11xb12 + a12xb22 + a13xb32 Following the same procedure we will have to calculate values for all cells.

Result Matrix
 a11xb11 + a12xb21 + a13xb31 a11xb12 + a12xb22 + a13xb32 a11xb13 + a12xb23 + a13xb33 a21xb11 + a22xb21 + a23xb31 a21xb12 + a22xb22 + a23xb32 a21xb13 + a22xb23 + a23xb33 a31xb11 + a32xb21 + a33xb31 a31xb12 + a32xb22 + a33xb32 a31xb13 + a32xb23 + a33xb33