freeCodeCamp/guide/english/mathematics/how-to-multiply-matrices/index.md

1.8 KiB

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.

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:

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
  • Step 2
  • Step 3
  • Step 4

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

Properties of matrix multiplication