Matrix
Operations
Master the fundamentals of matrix addition, scalar multiplication, and matrix multiplication: the building blocks of linear algebra and data science.
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.
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} \).
Why Do Matrices Matter?
Matrices let us organize and manipulate large sets of data in a compact form. They appear across many fields:
Matrix Addition
To add two matrices \( A \) and \( B \), add their corresponding entries. Both matrices must have the same dimensions.
Scalar Multiplication
Multiply every entry of matrix \( A \) by a single number (a scalar) \( k \). The result has the same dimensions as \( A \).
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.
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.
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
How to Multiply Matrices
Example: Matrix Addition
Compute \( A + B \) where:
Example: Scalar Multiplication
Compute \( -2A \) where $$ A = \begin{bmatrix} 3 & -1 \\ 0 & 4 \\ 2 & 7 \end{bmatrix} $$.
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} \).
Order Matters: \( AB \neq BA \)
Using the same \( A \) and \( B \) from the last slide, let us compute \( BA \):
Common Mistakes
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?