matrix multiplication

Precalculus Notes: Matrix Multiplication


1. What is Matrix Multiplication?

Matrix multiplication combines two matrices to produce a new matrix.

Unlike scalar multiplication, you do NOT multiply every entry directly.

Instead:

  • Multiply rows of the first matrix by columns of the second matrix.

  • Add the products.


2. When is Matrix Multiplication Possible?

Suppose

[
A_{m\times n}
]

and

[
B_{p\times q}
]

The product

[
AB
]

is defined only if

[
\boxed{n=p}
]

Meaning:

Columns of the first matrix = Rows of the second matrix


Easy Memory Trick

Inside numbers must match.

Example

[
(2\times3)(3\times4)
]

Inside numbers

[
3=3
]

Multiplication is possible.

Result

[
2\times4
]


Example

[
(2\times3)(4\times2)
]

Inside numbers

[
3\neq4
]

Cannot multiply.


3. Size of the Product Matrix

After multiplication,

keep the outside numbers.

Example

[
(4\times2)(2\times5)
]

Result

[
4\times5
]


Summary

Matrix A

Matrix B

Can Multiply?

Result

2×3

3×4

Yes

2×4

3×5

5×2

Yes

3×2

2×2

2×2

Yes

2×2

2×3

4×2

No

Undefined


4. Rule for Matrix Multiplication

Each entry comes from

Row × Column

Multiply corresponding entries.

Then add.


Formula

[
c_{ij}

a_{i1}b_{1j}
+
a_{i2}b_{2j}
+\cdots
]

Think

Row • Column

(dot product)


5. Example: Row × Column

[
A=
\begin{bmatrix}
1&3
\end{bmatrix}
]

[
B=
\begin{bmatrix}
2\
4
\end{bmatrix}
]

Multiply

[
AB
]

Step 1

Multiply corresponding entries

[
1(2)+3(4)
]

Step 2

Compute

[
2+12=14
]

Answer

[
\boxed{
\begin{bmatrix}
14
\end{bmatrix}}
]


6. Multiplying Two 2×2 Matrices

Example

[
A=
\begin{bmatrix}
0&1\
2&3
\end{bmatrix}
]

[
B=
\begin{bmatrix}
4&5\
6&7
\end{bmatrix}
]


Find Entry (1,1)

Row 1 × Column 1

[
0(4)+1(6)=6
]


Find Entry (1,2)

Row 1 × Column 2

[
0(5)+1(7)=7
]


Find Entry (2,1)

Row 2 × Column 1

[
2(4)+3(6)
]

[
8+18=26
]


Find Entry (2,2)

Row 2 × Column 2

[
2(5)+3(7)
]

[
10+21=31
]


Final Answer

[
AB=
\begin{bmatrix}
6&7\
26&31
\end{bmatrix}
]


7. Step-by-Step Algorithm

Suppose

[
A=
\begin{bmatrix}
a&b\
c&d
\end{bmatrix}
]

[
B=
\begin{bmatrix}
e&f\
g&h
\end{bmatrix}
]

Step 1

Top-left

Row 1 × Column 1

[
ae+bg
]


Step 2

Top-right

Row 1 × Column 2

[
af+bh
]


Step 3

Bottom-left

Row 2 × Column 1

[
ce+dg
]


Step 4

Bottom-right

Row 2 × Column 2

[
cf+dh
]


8. Matrix Multiplication is NOT Commutative

For real numbers

[
ab=ba
]

For matrices

[
\boxed{AB\neq BA}
]

Usually

they give different answers.

Sometimes

one exists while the other doesn't.


Example

[
A=
\begin{bmatrix}
2&1\
3&2
\end{bmatrix}
]

[
B=
\begin{bmatrix}
1&0\
4&3
\end{bmatrix}
]

[
AB=
\begin{bmatrix}
6&3\
11&6
\end{bmatrix}
]

But

[
BA=
\begin{bmatrix}
2&1\
17&10
\end{bmatrix}
]

Since

[
AB\neq BA
]

Matrix multiplication is not commutative.


9. Example of Different Sizes

[
A=
\begin{bmatrix}
3&2&8\
4&1&6
\end{bmatrix}
]

Order

[
2\times3
]

[
B=
\begin{bmatrix}
2&4\
3&1\
2&3
\end{bmatrix}
]

Order

[
3\times2
]

Can multiply?

Yes

because

[
3=3
]

Result size

[
2\times2
]


Entry (1,1)

[
3(2)+2(3)+8(2)
]

[
6+6+16=28
]


Entry (1,2)

[
3(4)+2(1)+8(3)
]

[
12+2+24=38
]


Entry (2,1)

[
4(2)+1(3)+6(2)
]

[
8+3+12=23
]


Entry (2,2)

[
4(4)+1(1)+6(3)
]

[
16+1+18=35
]


Answer

[
AB=
\begin{bmatrix}
28&38\
23&35
\end{bmatrix}
]


10. Applications

Matrix multiplication is used in

  • Economics

  • Finance

  • Engineering

  • Computer graphics

  • Artificial Intelligence

  • Data science

  • Physics

  • Robotics

  • Cryptography

  • Population models


11. Restaurant Revenue Example

Matrix A

Prices

[
2\times3
]

Matrix B

Items sold

[
3\times2
]

Multiply

[
AB
]

Result

[
2\times2
]

Rows

Restaurants

Columns

Days

Example result

[
\begin{bmatrix}
28&38\
23&35
\end{bmatrix}
]

Means

Restaurant

Monday

Tuesday

Y

$28,000

$38,000

Z

$23,000

$35,000


12. Vehicle Survey Example

Matrix A

People by

  • Gender

  • Age

Matrix B

Vehicle preference percentages

Multiply

[
AB
]

Result

Expected buyers by

  • Gender

  • Vehicle type


13. Cryptography

Matrices can encrypt messages.

Steps

  1. Assign numbers to letters.

Example

A = 1

B = 2

...

Z = 26

Space = 0


  1. Create a square encryption matrix.

Example

[
\begin{bmatrix}
1&2\
2&1
\end{bmatrix}
]


  1. Convert letters into numbers.


  1. Arrange numbers into matrices.


  1. Multiply by the secret matrix.

Encrypted message produced.


  1. Receiver multiplies by the inverse matrix.

Original message returns.


14. Common Mistakes

Mistake 1

Trying to multiply incompatible matrices.

Always check

Columns of first = Rows of second.


Mistake 2

Multiplying entry-by-entry.

Wrong.

Always use

Row × Column.


Mistake 3

Wrong size of answer.

Keep

Outside numbers.

Example

[
(2\times4)(4\times6)
]

Answer is

[
2\times6
]


Mistake 4

Thinking

[
AB=BA
]

Usually false.


15. Quick Reference

Matrix Multiplication Rule

Columns of first = Rows of second


Product Size

Keep outside numbers.


Entry Formula

[
\boxed{\text{Row}\times\text{Column}}
]

Multiply corresponding entries.

Add.


Commutative?

[
\boxed{AB\neq BA}
]

Generally false.


Formula Sheet

Condition

[
A_{m\times n}B_{p\times q}
]

Possible only if

[
n=p
]


Product Size

[
(m\times n)(n\times p)

m\times p
]


Entry Formula

[
c_{ij}

a_{i1}b_{1j}
+
a_{i2}b_{2j}
+\cdots
+
a_{in}b_{nj}
]


Memory Tricks

  • Inside numbers match → Multiplication is possible.

  • Outside numbers stay → Product size.

  • Row × Column → Every entry.

  • Multiply, then add → Dot product.

  • AB ≠ BA → Matrix multiplication is not commutative.