Multiplying Matrices

Multiplying Matrices

How to multiply matrices: examples and their solutions.

Example 1

If A = [1 2 / 3 4] and B = [2 -1 / 0 1], find AB.

A = [1 2 / 3 4]
B = [2 -1 / 0 1]

Then
AB = [1 2 / 3 4][2 -1 / 0 1].

To find the element of row 1, column 1,
multiply row 1 of A [1 2]
and column 1 of B [2 / 0]:
1⋅2 + 2⋅0.

To find the element of row 1, column 2,
multiply row 1 of A [1 2]
and column 2 of B [-1 / 1]:
1⋅(-1) + 2⋅1.

To find the element of row 2, column 1,
multiply row 2 of A [3 4]
and column 1 of B [2 / 0]:
3⋅2 + 4⋅0.

To find the element of row 2, column 2,
multiply row 2 of A [3 4]
and column 2 of B [-1 / 1]:
3⋅(-1) + 4⋅1.

1⋅2 + 2⋅0 = 2 + 0
1⋅(-1) + 2⋅1 = -1 + 2

3⋅2 + 4⋅0 = 6 + 0
3⋅(-1) + 4⋅1 = -3 + 4

2 + 0 = 2
-1 + 2 = 1

6 + 0 = 6
-3 + 4 = 1

So AB = [2 1 / 6 1].

Example 2

If A = [1 2 / 3 4] and B = [2 -1 / 0 1], find BA.

A = [1 2 / 3 4]
B = [2 -1 / 0 1]

Then
BA = [2 -1 / 0 1][1 2 / 3 4].

To find the element of row 1, column 1,
multiply row 1 of B [2 -1]
and column 1 of A [1 / 3]:
2⋅1 + (-1)⋅3.

To find the element of row 1, column 2,
multiply row 1 of B [2 -1]
and column 2 of A [2 / 4]:
2⋅2 + (-1)⋅4.

To find the element of row 2, column 1,
multiply row 2 of B [0 1]
and column 1 of A [1 / 3]:
0⋅1 + 1⋅3.

To find the element of row 2, column 2,
multiply row 2 of B [0 1]
and column 2 of A [2 / 4]:
0⋅2 + 1⋅4.

2⋅1 + (-1)⋅3 = 2 - 3
2⋅2 + (-1)⋅4 = 4 - 4

0⋅1 + 1⋅3 = 0 + 3
0⋅2 + 1⋅4 = 0 + 4

2 - 3 = -1
4 - 4 = 0

0 + 3 = 3
0 + 4 = 4

So BA = [-1 0 / 3 4].

In the previous example,
you got AB = [2 1 / 6 1].

And BA = [-1 0 / 3 4].

As you can see,
ABBA.

For multiplying matrices,
the order matters.