01 / 21

Matrix
Operations

Master the fundamentals of matrix addition, scalar multiplication, and matrix multiplication: the building blocks of linear algebra and data science.

Finite Mathematics

What Is a Matrix?

A matrix is a rectangular array of numbers arranged in rows and columns. We describe its size using the notation \( m \times n \), where \( m \) is the number of rows and \( n \) is the number of columns.

3 7 1 5 2 9 4 8 6 \( 3 \times 3 \) matrix Row 1 Row 2 Row 3

Dimensions & Notation

We write a matrix \( A \) with \( m \) rows and \( n \) columns as \( A_{m \times n} \). The entry in row \( i \), column \( j \) is denoted \( a_{ij} \).

Row Vector
A matrix with one row: \( 1 \times n \)
Column Vector
A matrix with one column: \( m \times 1 \)
Square Matrix
Equal rows and columns: \( n \times n \)

Why Do Matrices Matter?

Matrices let us organize and manipulate large sets of data in a compact form. They appear across many fields:

Systems of Equations
Solve \( n \) equations with \( n \) unknowns simultaneously
Computer Graphics
Rotate, scale, and transform images using matrix multiplication
Economics
Model input-output relationships in supply chains and markets

Matrix Addition

To add two matrices \( A \) and \( B \), add their corresponding entries. Both matrices must have the same dimensions.

1 3 5 7 + 2 4 6 8 = 3 7 11 15

Scalar Multiplication

Multiply every entry of matrix \( A \) by a single number (a scalar) \( k \). The result has the same dimensions as \( A \).

3 · 2 4 1 5 = 6 12 3 15

Matrix Multiplication Rule

To multiply \( A_{m \times n} \) by \( B_{n \times p} \), the number of columns in \( A \) must equal the number of rows in \( B \). The result \( C = AB \) is an \( m \times p \) matrix.

A \( m \times n \) × B \( n \times p \) = C \( m \times p \) must match

The Dot Product in Action

To find entry \( c_{11} \), take row 1 of \( A \) and column 1 of \( B \): multiply corresponding elements, then sum them.

1 2 3 4 5 6 A × 7 8 9 10 11 12 B = \( (1)(7) + (2)(9) + (3)(11) \) \( = 7 + 18 + 33 \) \( = 58 \) \( c_{11} = 58 \)

Addition vs. Multiplication

Addition / Subtraction Multiplication
Dimension Rule Must be same \( m \times n \) Columns of \( A \) = Rows of \( B \)
Result Size \( m \times n \) (unchanged) \( m \times p \) (can change)
Commutative? Yes: \( A + B = B + A \) No: \( AB \neq BA \) in general
Entry Formula \( c_{ij} = a_{ij} + b_{ij} \) \( c_{ij} = \sum a_{ik} b_{kj} \)

Properties of Matrix Operations

1
Associative Addition: \( (A + B) + C = A + (B + C) \)
2
Commutative Addition: \( A + B = B + A \)
3
Scalar Distributive: \( k(A + B) = kA + kB \)
4
Associative Multiplication: \( (AB)C = A(BC) \)
5
Distributive: \( A(B + C) = AB + AC \)

How to Multiply Matrices

1
Check dimensions: Confirm that the number of columns in \( A \) equals the number of rows in \( B \).
2
Determine result size: The product \( AB \) will have dimensions \( m \times p \) (rows of \( A \), columns of \( B \)).
3
Compute each entry: For entry \( c_{ij} \), take the dot product of row \( i \) of \( A \) with column \( j \) of \( B \).
4
Fill the matrix: Repeat step 3 for every row-column combination to complete \( C \).

Example: Matrix Addition

Compute \( A + B \) where:

A = 4 -2 7 1 B = 3 5 -1 6 → A + B = 7 3 6 7

Example: Scalar Multiplication

Compute \( -2A \) where $$ A = \begin{bmatrix} 3 & -1 \\ 0 & 4 \\ 2 & 7 \end{bmatrix} $$.

-2 · 3 -1 0 4 2 7 = -6 2 0 -8 -4 -14

Example: Matrix Multiplication

Compute \( AB \) where \( A = \begin{bmatrix} 2 & 3 \\ 1 & 4 \end{bmatrix} \) and \( B = \begin{bmatrix} 5 & 1 \\ 0 & 2 \end{bmatrix} \).

2 3 1 4 × 5 1 0 2 = 10 8 5 9
\( c_{11} = 2{\cdot}5 + 3{\cdot}0 = 10 \)
\( c_{12} = 2{\cdot}1 + 3{\cdot}2 = 8 \)
\( c_{21} = 1{\cdot}5 + 4{\cdot}0 = 5 \)
\( c_{22} = 1{\cdot}1 + 4{\cdot}2 = 9 \)

Order Matters: \( AB \neq BA \)

Using the same \( A \) and \( B \) from the last slide, let us compute \( BA \):

BA = 11 19 2 8 vs. AB = 10 8 5 9 ≠

Common Mistakes

✕ Adding Mismatched Sizes
You cannot add a \( 2 \times 3 \) matrix to a \( 3 \times 2 \) matrix. Dimensions must be identical.
✕ Multiplying Entry by Entry
Matrix multiplication is not element-wise. You must use the dot product of rows and columns.
✕ Swapping Order
Assuming \( AB = BA \). Matrix multiplication is not commutative: order always matters.

Question 1 of 5

If \( A \) is a \( 3 \times 4 \) matrix and \( B \) is a \( 4 \times 2 \) matrix, what are the dimensions of \( AB \)?

Question 2 of 5

Compute: $$ \begin{bmatrix}1 & -3\\2 & 5\end{bmatrix} + \begin{bmatrix}4 & 0\\-1 & 3\end{bmatrix} $$

Question 3 of 5

If \( k = -3 \) and \( A = \begin{bmatrix}2 & -1\\0 & 4\end{bmatrix} \), what is \( kA \)?

Question 4 of 5

Compute entry \( c_{12} \) of \( AB \) where \( A = \begin{bmatrix}3 & 1\\2 & 5\end{bmatrix} \) and \( B = \begin{bmatrix}4 & 0\\-2 & 6\end{bmatrix} \).

Question 5 of 5

Which of the following statements about matrix multiplication is true?