Guozhen AIGlobal AI field notes and model intelligence

English translation

Matrix Multiplication and Its Properties

Published:

Category: Linear Algebra for AI Beginners

Read time: 5 min

Reads: 0

Lesson #7Views are counted together with the original Chinese articleImages are preserved from the source page

Concept Map: Matrix Multiplication and Its Properties

Matrix multiplication is not element-wise multiplication—it computes dot products between rows and columns. It models feature weighting, coordinate transformations, and multi-layer neural network propagation.

Matrix Multiplication and Properties Checklist

I’ll start by writing (m × n) @ (n × p) = (m × p). This dimensional rule is more reliable than memorizing formulas.

In previous chapters, we covered the fundamentals of matrix addition and scalar multiplication. Matrix multiplication is a core operation in linear algebra—and especially critical in machine learning and computer science. In this chapter, we will delve deeply into the definition, properties, and practical applications of matrix multiplication.

Definition of Matrix Multiplication

Matrix multiplication is an operation that multiplies two matrices—but not all matrices can be multiplied. Suppose we have two matrices AA and BB, of dimensions m×nm \times n and n×pn \times p, respectively. Their product C=ABC = AB yields an m×pm \times p matrix. Formally, matrix multiplication is defined as:

Matrix Multiplication Properties Quick-Check Card

When learning matrix multiplication, first verify that the number of columns in the left matrix matches the number of rows in the right matrix; then confirm the resulting dimensions and associativity. Do not confuse element-wise multiplication with matrix multiplication.

Cij=k=1nAikBkjC_{ij} = \sum_{k=1}^{n} A_{ik} B_{kj}

This means the entry CijC_{ij}—located in row ii, column jj of matrix CC—is the sum of the products of corresponding elements from row ii of matrix AA and column jj of matrix BB.

Example

Consider two matrices:

A=(1234),B=(5678)A = \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}, \quad B = \begin{pmatrix} 5 & 6 \\ 7 & 8 \end{pmatrix}

We compute C=ABC = AB:

  1. Compute C11C_{11}: C11=15+27=5+14=19C_{11} = 1 \cdot 5 + 2 \cdot 7 = 5 + 14 = 19
  2. Compute C12C_{12}: C12=16+28=6+16=22C_{12} = 1 \cdot 6 + 2 \cdot 8 = 6 + 16 = 22
  3. Compute C21C_{21}: C21=35+47=15+28=43C_{21} = 3 \cdot 5 + 4 \cdot 7 = 15 + 28 = 43
  4. Compute C22C_{22}: C22=36+48=18+32=50C_{22} = 3 \cdot 6 + 4 \cdot 8 = 18 + 32 = 50

Thus, matrix CC is:

C=(19224350)C = \begin{pmatrix} 19 & 22 \\ 43 & 50 \end{pmatrix}

Properties of Matrix Multiplication

Matrix multiplication possesses several important properties—widely used in theory and practice. Here are key ones:

Matrix Operations: Matrix Multiplication and Properties — Application Checklist

When reviewing Matrix Operations: Matrix Multiplication and Properties, you need not tackle large projects at once. Start with one simple example to verify whether the core logic is clear.

Matrix Operations: Matrix Multiplication and Properties — Application Retrospective Card

If Matrix Operations: Matrix Multiplication and Properties hasn’t yet been fully internalized, revisit the four actions on this card to retrace your learning path.

Linear Algebra Reading Roadmap Card

After finishing Matrix Operations: Matrix Multiplication and Properties, treat the flowchart in this figure as a checklist: Is the problem well-defined? Are operations concretely implemented? Can the evaluation criteria be reused?

  1. Associativity: Matrix multiplication is associative: (AB)C=A(BC)(AB)C = A(BC).
  2. Distributivity: Matrix multiplication distributes over addition:
    A(B+C)=AB+ACA(B + C) = AB + AC and (A+B)C=AC+BC(A + B)C = AC + BC.
  3. Non-commutativity: In general, matrix multiplication is not commutative: ABBAAB \neq BA.
  4. Identity Matrix: There exists an identity matrix InI_n such that for any n×nn \times n matrix AA, AIn=InA=AAI_n = I_n A = A.

Associativity Example

Consider three matrices:

A=(1234),B=(5678),C=(9101112)A = \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}, \quad B = \begin{pmatrix} 5 & 6 \\ 7 & 8 \end{pmatrix}, \quad C = \begin{pmatrix} 9 & 10 \\ 11 & 12 \end{pmatrix}

We compute both (AB)C(AB)C and A(BC)A(BC) to verify equality.

  1. Compute ABAB:
AB=(15+2716+2835+4736+48)=(19224350)AB = \begin{pmatrix} 1 \cdot 5 + 2 \cdot 7 & 1 \cdot 6 + 2 \cdot 8 \\ 3 \cdot 5 + 4 \cdot 7 & 3 \cdot 6 + 4 \cdot 8 \end{pmatrix} = \begin{pmatrix} 19 & 22 \\ 43 & 50 \end{pmatrix}
  1. Compute (AB)C(AB)C:
(AB)C=(19224350)(9101112)=(199+22111910+2212439+50114310+5012)(AB)C = \begin{pmatrix} 19 & 22 \\ 43 & 50 \end{pmatrix} \begin{pmatrix} 9 & 10 \\ 11 & 12 \end{pmatrix} = \begin{pmatrix} 19 \cdot 9 + 22 \cdot 11 & 19 \cdot 10 + 22 \cdot 12 \\ 43 \cdot 9 + 50 \cdot 11 & 43 \cdot 10 + 50 \cdot 12 \end{pmatrix}

Carrying out the arithmetic yields:

(AB)C=(209244553640)(AB)C = \begin{pmatrix} 209 & 244 \\ 553 & 640 \end{pmatrix}
  1. Compute BCBC:
BC=(59+611510+61279+811710+812)=(99108119140)BC = \begin{pmatrix} 5 \cdot 9 + 6 \cdot 11 & 5 \cdot 10 + 6 \cdot 12 \\ 7 \cdot 9 + 8 \cdot 11 & 7 \cdot 10 + 8 \cdot 12 \end{pmatrix} = \begin{pmatrix} 99 & 108 \\ 119 & 140 \end{pmatrix}
  1. Compute A(BC)A(BC):
A(BC)=(1234)(99108119140)=(199+21191108+2140399+41193108+4140)A(BC) = \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix} \begin{pmatrix} 99 & 108 \\ 119 & 140 \end{pmatrix} = \begin{pmatrix} 1 \cdot 99 + 2 \cdot 119 & 1 \cdot 108 + 2 \cdot 140 \\ 3 \cdot 99 + 4 \cdot 119 & 3 \cdot 108 + 4 \cdot 140 \end{pmatrix}

Computing gives:

A(BC)=(337388603712)A(BC) = \begin{pmatrix} 337 & 388 \\ 603 & 712 \end{pmatrix}

Wait—this contradicts associativity! Let’s double-check our arithmetic.

Actually, the earlier calculation of (AB)C(AB)C contains an error. Correct computation:

  • C11=199+2211=171+242=413C_{11} = 19 \cdot 9 + 22 \cdot 11 = 171 + 242 = 413
  • C12=1910+2212=190+264=454C_{12} = 19 \cdot 10 + 22 \cdot 12 = 190 + 264 = 454
  • C21=439+5011=387+550=937C_{21} = 43 \cdot 9 + 50 \cdot 11 = 387 + 550 = 937
  • C22=4310+5012=430+600=1030C_{22} = 43 \cdot 10 + 50 \cdot 12 = 430 + 600 = 1030

So (AB)C=(4134549371030)(AB)C = \begin{pmatrix} 413 & 454 \\ 937 & 1030 \end{pmatrix}.

Now recompute A(BC)A(BC) correctly:

  • BC=(59+611510+61279+811710+812)=(45+6650+7263+8870+96)=(111122151166)BC = \begin{pmatrix} 5\cdot9+6\cdot11 & 5\cdot10+6\cdot12 \\ 7\cdot9+8\cdot11 & 7\cdot10+8\cdot12 \end{pmatrix} = \begin{pmatrix} 45+66 & 50+72 \\ 63+88 & 70+96 \end{pmatrix} = \begin{pmatrix} 111 & 122 \\ 151 & 166 \end{pmatrix}

Then:

  • A(BC)=(1234)(111122151166)=(1111+21511122+21663111+41513122+4166)=(111+302122+332333+604366+664)=(4134549371030)A(BC) = \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix} \begin{pmatrix} 111 & 122 \\ 151 & 166 \end{pmatrix} = \begin{pmatrix} 1\cdot111 + 2\cdot151 & 1\cdot122 + 2\cdot166 \\ 3\cdot111 + 4\cdot151 & 3\cdot122 + 4\cdot166 \end{pmatrix} = \begin{pmatrix} 111+302 & 122+332 \\ 333+604 & 366+664 \end{pmatrix} = \begin{pmatrix} 413 & 454 \\ 937 & 1030 \end{pmatrix}

✅ Indeed, (AB)C=A(BC)=(4134549371030)(AB)C = A(BC) = \begin{pmatrix} 413 & 454 \\ 937 & 1030 \end{pmatrix}. This confirms associativity.

Real-World Application Example

In machine learning, matrix multiplication underpins numerous algorithms. For instance, consider a simple linear regression model:

YY

Continue

Keep reading from here

Browse English site

Reader Messages

Reader messages

Questions, corrections, extra sources, or hands-on results can be left here. No login is required.

Max 800 characters

To reduce spam, each message is checked for length, link count, and posting frequency.

0/800

Messages

0 messages
Loading messages...