---
title: How to Multiply Matrices
---
## How to Multiply Matrices

The first immportant rule is: the number of columns in matrix A must match number of rows in column B.

The second rule to calculate the product of two matrices is: Line X Column.

<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/e/e1/Matrix_multiplication_principle.svg/320px-Matrix_multiplication_principle.svg.png" width="300" height="150">

The resulting matrix dimension will be rows of first matrix X columns of second matrix.

Let A and B be two matrices of dimension 2, that is, 2 X 2. Their product will be:

<img src="http://www.i-programmer.info/images/stories/News/2011/DEC/A/matrix1.jpg" width="400" height="150">

The rows of the the resuting matrix is the sum of product of first matrix row elements by second matrix column elements.

#### Example

Let A be a 2 X 3 matrix and B be a 3 X 2 matrix. The product AB will be:

* **Step 1**

<img src="http://www.mathportal.org/linear-algebra/matrices/matrix-operations_files/12.gif">

* **Step 2**

<img src="http://www.mathportal.org/linear-algebra/matrices/matrix-operations_files/13.gif">

* **Step 3**

<img src="http://www.mathportal.org/linear-algebra/matrices/matrix-operations_files/14.gif">

* **Step 4**

<img src="http://www.mathportal.org/linear-algebra/matrices/matrix-operations_files/15.gif">

#### Attention!

Differently from real numbers algebra, the product AB is not always equal to BA. Calculate it using the example above and find out.

#### More Information:

![Lecture on matrices multiplication](https://www.khanacademy.org/math/precalculus/precalc-matrices/multiplying-matrices-by-matrices/v/matrix-multiplication-intro)

![Properties of matrix multiplication](https://www.khanacademy.org/math/precalculus/precalc-matrices/properties-of-matrix-multiplication/a/properties-of-matrix-multiplication)




