01 / 21

Matrix
Operations

Learn how to add matrices, multiply by scalars, and multiply matrices together: the building blocks of linear algebra.

Linear Algebra

What Is a Matrix?

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

2 5 1 3 7 4 2 × 3 matrix (2 rows, 3 columns) rows columns

Why Do Matrices Matter?

Matrices are the language of data. They let us organize, transform, and solve complex systems in a compact form. Three core operations unlock nearly all of linear algebra.

Addition
Combine two datasets element by element.
Scalar Mult.
Scale every entry by a single number.
Multiplication
Compose transformations or solve systems.

Notation and Dimensions

We write a matrix with a capital letter and denote its size by rows × columns. The entry in row \( i \), column \( j \) of matrix \( A \) is written \( a_{ij} \).

Row Vector
\( 1 \times n \) matrix: a single row.
Column Vector
\( m \times 1 \) matrix: a single column.
Square Matrix
\( n \times n \): same number of rows and columns.

Matrix Addition

To add two matrices, add their corresponding entries. Both matrices must have the same dimensions.

1 3 2 4 + 5 7 6 8 = 6 10 8 12

Scalar Multiplication

To multiply a matrix by a scalar (a single number), multiply every entry in the matrix by that scalar.

3 · 2 -1 0 4 = 6 -3 0 12

Matrix Multiplication

To multiply \( A \) (size \( m \times n \)) by \( B \) (size \( n \times p \)), the number of columns in \( A \) must equal the number of rows in \( B \). The result is an \( m \times p \) matrix.

A m × n × B n × p = AB m × p must match

Row-by-Column Dot Product

Each entry in the product matrix is computed by pairing a row of \( A \) with a column of \( B \), multiplying element-wise, then summing.

A 1 2 3 4 5 6 × B 7 8 9 10 11 12 (1)(7) + (2)(8) + (3)(9) = 50 Entry (1,1) of AB

Addition vs. Multiplication: Order Matters

Matrix addition is commutative: \( A + B = B + A \). But matrix multiplication is NOT commutative: in general, \( AB \neq BA \).

Addition Multiplication
Commutative? ✓ Yes ✕ No
Associative? ✓ Yes ✓ Yes
Distributive? ✓ \( A(B + C) = AB + AC \)
Size requirement Same dimensions Cols of \( A \) = Rows of \( B \)

Step-by-Step Checklist

1
Identify the operation. Are you adding, scaling, or multiplying?
2
Check dimensions. For addition: same size. For multiplication: inner dimensions must match.
3
Determine result size. Addition: same as inputs. Multiplication: outer dimensions \( m \times p \).
4
Compute each entry. Add/scale element-wise, or take row-column dot products.
5
Verify. Double-check dimensions and a few sample entries.

Example 1: Addition

Compute \( A + B \) where:

3 -1 0 5 + 2 4 -3 1 = 5 3 -3 6

Example 2: Scalar Multiplication

Compute \( -2C \) where:

-2 · 4 0 -3 1 -2 5 = -8 0 6 -2 4 -10

Example 3: Multiplication

Compute \( AB \) where:

1
Entry (1,1): \( (1)(5) + (2)(7) = 5 + 14 = \) 19
2
Entry (1,2): \( (1)(6) + (2)(8) = 6 + 16 = \) 22
3
Entry (2,1): \( (3)(5) + (4)(7) = 15 + 28 = \) 43
4
Entry (2,2): \( (3)(6) + (4)(8) = 18 + 32 = \) 50

Example 4: Non-Square Product

Compute \( PQ \) where \( P \) is \( 2 \times 3 \) and \( Q \) is \( 3 \times 1 \):

Result is \( 2 \times 1 \):

1
Row 1 · Q: \( (1)(4) + (0)(-2) + (2)(5) = 4 + 0 + 10 = \) 14
2
Row 2 · Q: \( (3)(4) + (1)(-2) + (-1)(5) = 12 - 2 - 5 = \) 5

Common Mistakes

✕ Adding different sizes
A \( 2 \times 3 \) and a \( 3 \times 2 \) cannot be added. Dimensions must be identical.
✕ Assuming \( AB = BA \)
Matrix multiplication is not commutative. Always respect the stated order.
✕ Wrong dimension check
For \( AB \): columns of \( A \) must equal rows of \( B \). Mixing this up makes the product undefined.
✕ Element-wise multiply
Matrix multiplication is not entry-by-entry. You must use the dot product rule.

Summary of Operations

Addition Scalar Mult. Matrix Mult.
Rule \( a_{ij} + b_{ij} \) \( c \cdot a_{ij} \) \( \sum a_{ik}b_{kj} \)
Size needed Same \( m \times n \) Any size Inner dims match
Result size \( m \times n \) \( m \times n \) \( m \times p \)
Commutative? ✓ ✓ ✕

Question 1 of 5

If \( A \) is a \( 3 \times 2 \) matrix and \( B \) is a \( 3 \times 2 \) matrix, what is the size of \( A + B \)?

Question 2 of 5

Compute: \( 4 \begin{bmatrix} 2 & -1 \\ 3 & 0 \end{bmatrix} \). What is the entry in row 2, column 1?

Question 3 of 5

If \( A \) is \( 2 \times 3 \) and \( B \) is \( 3 \times 4 \), what is the size of \( AB \)?

Question 4 of 5

Compute the entry in row 1, column 1 of the product:
$$\begin{bmatrix} 2 & 1 \\ 0 & 3 \end{bmatrix} \begin{bmatrix} 4 & -1 \\ 2 & 5 \end{bmatrix}$$

Question 5 of 5

Which of the following statements is always true?