Tuesday, October 27, 2026

MATRIX - BASIC OPERATIONS

 

1: Matrices and Basic Operations

What: A matrix is a rectangular array of numbers with m rows and n columns (an m×n matrix). The entry in row i, column j is written aᵢⱼ.

Why: Matrices organize data and represent linear transformations (rotations, scaling) and systems of equations compactly. Computer graphics, machine learning, engineering, and economics all rely on them.

How:

  • Addition/subtraction: same size only, entry by entry.
  • Scalar multiplication: multiply every entry.
  • Matrix multiplication: (AB)ᵢⱼ = row i of A · column j of B. This needs columns of A = rows of B.
  • Transpose Aᵀ: swap rows and columns.

Worked example:
A = [[1, 2], [3, 4]], B = [[0, 1], [1, 0]]

AB = [[1·0+2·1, 1·1+2·0], [3·0+4·1, 3·1+4·0]] = [[2, 1], [4, 3]]
BA = [[3, 4], [1, 2]]

So AB ≠ BA. Matrix multiplication is generally not commutative. Students must understand this early.

Common mistakes: multiplying entry by entry, ignoring size compatibility, assuming AB = BA.

Examples of the Four Basic Operations

1. Addition and Subtraction (same size only)

Add or subtract the entries in the same position.

A = [1  2]     B = [5  6]
    [3  4]         [7  8]

A + B = [1+5  2+6]  =  [ 6   8]
        [3+7  4+8]     [10  12]

A − B = [1−5  2−6]  =  [−4  −4]
        [3−7  4−8]     [−4  −4]

Not allowed: a 2×2 matrix plus a 2×3 matrix. The sizes differ, so some entries have no partner. Show this to your student as a “defined or undefined?” question.


2. Scalar Multiplication

Multiply every entry by the number.

3A = 3 [1  2]  =  [3·1  3·2]  =  [3   6]
       [3  4]     [3·3  3·4]     [9  12]

−2B = −2 [5  6]  =  [−10  −12]
         [7  8]     [−14  −16]

A useful extension: 3A − 2B combines both operations, entry by entry.


3. Matrix Multiplication

Rule: the entry in row i, column j of AB is (row i of A) · (column j of B). Multiply matching entries, then add.

Size check first: (m×n)(n×p) gives an m×p result. The two inner numbers must match.

A = [1  2  3]  (2×3)      B = [ 7   8]  (3×2)
    [4  5  6]                 [ 9  10]
                              [11  12]

Inner numbers are 3 and 3, so AB is defined, and the result is 2×2.

Row 1 · Col 1:  1·7 + 2·9 + 3·11  =  7 + 18 + 33  =  58
Row 1 · Col 2:  1·8 + 2·10 + 3·12 =  8 + 20 + 36  =  64
Row 2 · Col 1:  4·7 + 5·9 + 6·11  = 28 + 45 + 66  = 139
Row 2 · Col 2:  4·8 + 5·10 + 6·12 = 32 + 50 + 72  = 154

AB = [ 58   64]
     [139  154]

Now try BA. This is (3×2)(2×3), which is also defined, but the result is 3×3:

BA = [39  54   69]
     [49  68   87]
     [59  82  105]

This is a powerful lesson: AB and BA can even have different sizes, so they cannot be equal.

Not allowed: (2×3)(2×3). The inner numbers are 3 and 2, which do not match.


4. Transpose

Rows become columns. Row 1 becomes column 1, row 2 becomes column 2, and so on.

C = [1  2  3]   (2×3)
    [4  5  6]

Cᵀ = [1  4]     (3×2)
     [2  5]
     [3  6]

Notice the size flips from 2×3 to 3×2. For a square matrix:

D = [1  2]     Dᵀ = [1  3]
    [3  4]          [2  4]

The diagonal stays fixed, and the other entries swap across it.

Rule to teach next: (AB)ᵀ = BᵀAᵀ. The order reverses, just like with inverses.

No comments:

Post a Comment