# Matrices as functions

> AP Precalculus · Unit 4: Functions Involving Parameters, Vectors, and Matrices
> Source: https://www.owlsprep.com/study/ap-precalculus-u4-matrices-as-functions/

This subtopic covers interpreting matrices as linear functions, including domain and codomain identification, matrix-vector multiplication as function evaluation, composition of matrix functions, and 2D geometric transformations.

**Prerequisites:** Matrix dimension rules for multiplication; Inverse calculation for 2×2 matrices; Basic vector notation

## Learning objectives

- Interpret matrices as linear functions mapping input vectors to output vectors
- Identify domain and codomain of matrix functions from matrix dimensions
- Compose matrix functions via matrix multiplication following order rules
- Represent 2D geometric transformations as matrix functions
- Apply matrix functions to solve evaluation and transformation problems

## Core Definition of Matrix Functions

In AP Precalculus Unit 4, matrices are framed not just as static arrays of numbers, but as linear functions that map input vectors to output vectors. Note: Unit 4 is not assessed on the AP Precalculus Exam — the College Board Course and Exam Description limits the exam to Units 1–3, so this topic is taught at teacher discretion for enrichment and as a foundation for later STEM courses.

**Matrix Function** — A linear function that maps $n$-dimensional input vectors to $m$-dimensional output vectors via matrix-vector multiplication. Also called a linear transformation or linear map.

*Notation:* $f(\mathbf{v}) = A\mathbf{v}$, where $A$ is an $m \times n$ matrix, $\mathbf{v}$ is an $n \times 1$ column vector

*Example:* A $2 \times 3$ matrix defines a function from $\mathbb{R}^3$ to $\mathbb{R}^2$

Unlike general non-linear functions, all matrix functions satisfy two core linearity properties: $f(a\mathbf{v}) = a f(\mathbf{v})$ for any scalar $a$, and $f(\mathbf{v} + \mathbf{w}) = f(\mathbf{v}) + f(\mathbf{w})$ for any input vectors $\mathbf{v}, \mathbf{w}$. This framework unifies many geometric and algebraic operations, turning scaling, rotation, and reflection into easily computed matrix products.

## Matrix-Vector Multiplication as Function Evaluation

When treating a matrix as a function, evaluating the function at a vector input is exactly matrix-vector multiplication. Dimension rules for multiplication align directly with function domain and codomain rules: an $m \times n$ matrix accepts $n \times 1$ vectors, so its domain is all of $\mathbb{R}^n$, and outputs $m \times 1$ vectors, so its codomain is all of $\mathbb{R}^m$.

$$A = \begin{bmatrix} a_{11} & a_{12} & \dots & a_{1n} \\ a_{21} & a_{22} & \dots & a_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ a_{m1} & a_{m2} & \dots & a_{mn} \end{bmatrix}, \quad \mathbf{v} = \begin{bmatrix} v_1 \\ v_2 \\ \vdots \\ v_n \end{bmatrix}$$

The output is calculated by taking the dot product of each row of $A$ with $\mathbf{v}$:

$$A\mathbf{v} = \begin{bmatrix} a_{11}v_1 + a_{12}v_2 + \dots + a_{1n}v_n \\ a_{21}v_1 + a_{22}v_2 + \dots + a_{2n}v_n \\ \vdots \\ a_{m1}v_1 + a_{m2}v_2 + \dots + a_{mn}v_n \end{bmatrix}$$

**Worked example:** Given the matrix function $f\left(\begin{bmatrix} x \\ y \\ z \end{bmatrix}\right) = \begin{bmatrix} 2 & -1 & 0 \\ 3 & 0 & 2 \end{bmatrix} \begin{bmatrix} x \\ y \\ z \end{bmatrix}$, (a) state the domain and codomain of $f$, (b) find $f\left(\begin{bmatrix} 1 \\ 4 \\ -2 \end{bmatrix}\right)$.

1. Identify matrix dimensions: the given matrix has 2 rows and 3 columns, so it is a $2 \times 3$ matrix.
2. Apply the domain/codomain rule: an $m \times n$ matrix has domain $\mathbb{R}^n$ and codomain $\mathbb{R}^m$, so domain of $f$ is $\mathbb{R}^3$ (all 3-dimensional input vectors) and codomain is $\mathbb{R}^2$ (all 2-dimensional output vectors).
3. Evaluate the first entry of the output as the dot product of the first row and input vector: $(2)(1) + (-1)(4) + (0)(-2) = 2 - 4 + 0 = -2$.
4. Evaluate the second entry as the dot product of the second row and input vector: $(3)(1) + (0)(4) + (2)(-2) = 3 + 0 - 4 = -1$.
5. Combine entries to get the output:
6. $$f\left(\begin{bmatrix} 1 \\ 4 \\ -2 \end{bmatrix}\right) = \begin{bmatrix} -2 \\ -1 \end{bmatrix}$$

> **Exam tip:** Always confirm that the input vector dimension matches the number of columns of the matrix before multiplying—if it does not, the function is undefined at that input, a common trick answer for multiple-choice questions.

## Composition of Matrix Functions

Just like any other function, matrix functions can be composed if the output dimension of the inner function matches the input dimension of the outer function. For two functions $f: \mathbb{R}^n \to \mathbb{R}^m$ (defined by $m \times n$ matrix $A_f$) and $g: \mathbb{R}^m \to \mathbb{R}^k$ (defined by $k \times m$ matrix $B_g$), the composition $(g \circ f)(\mathbf{v}) = g(f(\mathbf{v}))$ simplifies to matrix multiplication: $(g \circ f)(\mathbf{v}) = B_g (A_f \mathbf{v}) = (B_g A_f)\mathbf{v}$.

This means composition of matrix functions is exactly equivalent to matrix multiplication, with the same right-to-left order as function composition: the inner (first applied) function’s matrix goes on the right, and the outer (second applied) function’s matrix goes on the left. Unlike scalar function multiplication, matrix composition is not commutative, so order always changes the result for most pairs of matrices.

**Worked example:** Let $f\left(\begin{bmatrix} x \\ y \end{bmatrix}\right) = \begin{bmatrix} 1 & 2 \\ 0 & 1 \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix}$ and $g\left(\begin{bmatrix} a \\ b \end{bmatrix}\right) = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix} \begin{bmatrix} a \\ b \end{bmatrix}$. Find the matrix that defines the composition $g \circ f$.

1. Recall that $g \circ f = g(f(\mathbf{v}))$, so $f$ is the inner function and $g$ is the outer function. The matrix for the composition is the product $B_g A_f$, where $A_f = \begin{bmatrix} 1 & 2 \\ 0 & 1 \end{bmatrix}$ and $B_g = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}$.
2. Calculate the first row of the product: first entry = $(0)(1) + (1)(0) = 0$, second entry = $(0)(2) + (1)(1) = 1$.
3. Calculate the second row of the product: first entry = $(1)(1) + (0)(0) = 1$, second entry = $(1)(2) + (0)(1) = 2$.
4. The resulting matrix for $g \circ f$ is:
5. $$\begin{bmatrix} 0 & 1 \\ 1 & 2 \end{bmatrix}$$

> **Exam tip:** If the question asks for $f \circ g$ (f after g) instead of $g \circ f$, reverse the order of multiplication to $A_f B_g$, not $B_g A_f$. Never assume order does not matter.

## Geometric Transformations as Matrix Functions

All linear 2D geometric transformations can be represented as 2×2 matrix functions that map input position vectors $\begin{bmatrix} x \\ y \end{bmatrix}$ to output transformed position vectors. Common transformations include uniform scaling, reflection over the x-axis, y-axis, or line $y=x$, and rotation around the origin.

Each of these transformations is linear, so they fit the matrix function framework, and all are invertible when their determinants are non-zero. When multiple transformations are applied in sequence, the combined transformation matrix is found by composing the individual matrix functions, following the right-to-left order rule.

**Worked example:** Find the image of the point $(2, 1)$ after a 90° counterclockwise rotation around the origin followed by a reflection over the x-axis.

1. Write the matrix for each transformation: A 90° counterclockwise rotation has $\cos 90^\circ = 0$, $\sin 90^\circ = 1$, so rotation matrix $R = \begin{bmatrix} 0 & -1 \\ 1 & 0 \end{bmatrix}$. Reflection over the x-axis has matrix $S = \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix}$.
2. Rotation is applied first, then reflection, so the composition is reflection $\circ$ rotation, and the combined matrix is $SR$.
3. Calculate the product:
4. $$SR = \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix} \begin{bmatrix} 0 & -1 \\ 1 & 0 \end{bmatrix} = \begin{bmatrix} 0 & -1 \\ -1 & 0 \end{bmatrix}$$
5. Multiply the combined matrix by the input position vector $\begin{bmatrix} 2 \\ 1 \end{bmatrix}$:
6. $$\begin{bmatrix} 0 & -1 \\ -1 & 0 \end{bmatrix} \begin{bmatrix} 2 \\ 1 \end{bmatrix} = \begin{bmatrix} -1 \\ -2 \end{bmatrix}$$
7. The final image of the point is $(-1, -2)$.

> **Exam tip:** Always order transformation matrices with the first applied transformation on the right of the product, because it is the inner function in the composition.

## Concept Check

**Check your understanding**

Test your understanding of core domain and codomain rules:

1. Let $f$ be a matrix function defined by $f(\mathbf{v}) = A\mathbf{v}$, where $A = \begin{bmatrix} 3 & -2 \\ 1 & 0 \\ 0 & 4 \end{bmatrix}$. What is the domain and codomain of $f$?

   - A) Domain: $\mathbb{R}^2$, Codomain: $\mathbb{R}^2$
   - B) Domain: $\mathbb{R}^2$, Codomain: $\mathbb{R}^3$
   - C) Domain: $\mathbb{R}^3$, Codomain: $\mathbb{R}^2$
   - D) Domain: $\mathbb{R}^3$, Codomain: $\mathbb{R}^3$

   *Answer:* B) Domain: $\mathbb{R}^2$, Codomain: $\mathbb{R}^3$

   *Why:* Correct! An $m \times n$ matrix has domain $\mathbb{R}^n$ (number of columns = 2) and codomain $\mathbb{R}^m$ (number of rows = 3).

## Common pitfalls

- **Wrong:** Stating that a $3 \times 2$ matrix function has domain $\mathbb{R}^3$ and codomain $\mathbb{R}^2$
  - Why it fails: Students mix up rows and columns when matching matrix dimensions to domain/codomain
  - Correct: Remember columns = input dimension, rows = output dimension, so domain is $\mathbb{R}^{\text{number of columns}}$ and codomain is $\mathbb{R}^{\text{number of rows}}$
- **Wrong:** Writing the combined transformation matrix for 'rotation first, then reflection' as $RS$ instead of $SR$
  - Why it fails: Students confuse the order of function composition, treating written order as left-to-right
  - Correct: Always write the last applied transformation on the left, first applied on the right
- **Wrong:** Assuming all 2×2 matrix functions are invertible
  - Why it fails: Students incorrectly generalize that all square matrices are invertible
  - Correct: Always check that the determinant of the matrix is non-zero before concluding the inverse function exists
- **Wrong:** Using the counterclockwise rotation matrix for a clockwise rotation by $\theta$
  - Why it fails: Students memorize the rotation matrix but do not account for direction
  - Correct: For clockwise rotation, substitute $-\theta$ into the rotation formula to flip the sign of the sine terms
- **Wrong:** Calculating $A\mathbf{v}$ by taking the dot product of columns of $A$ with $\mathbf{v}$
  - Why it fails: Students confuse matrix-vector multiplication with column combinations when working with column vectors
  - Correct: Always use row times vector for matrix-vector multiplication with column inputs, the standard in AP Precalculus
- **Wrong:** Writing the matrix for $g \circ f$ as $A_f B_g$ instead of $B_g A_f$
  - Why it fails: Students match the written order of $g$ then $f$ to left-to-right matrix order
  - Correct: Read $g \circ f$ as 'g after f', so f is done first and goes on the right

## Cheatsheet

| Category | Formula/Rule | Notes |
| --- | --- | --- |
| Domain/Codomain ($m \times n$ matrix) | Domain: $\mathbb{R}^n$, Codomain: $\mathbb{R}^m$ | $n$ = number of columns (input dimension), $m$ = number of rows (output dimension) |
| Matrix Function Evaluation | $f(\mathbf{v}) = A\mathbf{v}$ | Output entries are dot product of each row of $A$ with $\mathbf{v}$ |
| Composition of Matrix Functions | $g \circ f$ has matrix $B_g A_f$ | $f$ = first applied (inner) function, $g$ = second applied (outer) function |
| 2D Rotation (CCW by $\theta$) | $\begin{bmatrix} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{bmatrix}$ | Use $-\theta$ for clockwise rotation |
| 2D Reflection over x-axis | $\begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix}$ | Flips the sign of the y-coordinate |
| 2D Reflection over y-axis | $\begin{bmatrix} -1 & 0 \\ 0 & 1 \end{bmatrix}$ | Flips the sign of the x-coordinate |
| 2D Reflection over $y=x$ | $\begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}$ | Swaps the x and y coordinates |
| Uniform 2D Scaling by $k$ | $\begin{bmatrix} k & 0 \\ 0 & k \end{bmatrix}$ | Multiplies both coordinates by $k$ |
| Invertibility of Matrix Function | Inverse exists iff $\det(A) \neq 0$ | Inverse function is given by $f^{-1}(\mathbf{v}) = A^{-1}\mathbf{v}$ |

## What's next

This subtopic is the foundational prerequisite for all further work with matrices and linear transformations in AP Precalculus. The framework of matrices as functions underpins all applications of matrices to solving linear systems, modeling transformations, and analyzing vector relationships that you will encounter next in Unit 4. Mastering the order of composition and domain/codomain rules here will prevent common errors on more complex topics like inverse matrix functions and solving systems of linear equations, which come later in Unit 4. Building on this foundation, you will also learn how to use matrix functions to model real-world situations like computer graphics transformations.

- [Unit 4 Overview](https://www.owlsprep.com/study/ap-precalculus-u4-overview/)
- [Matrices Modeling Contexts](https://www.owlsprep.com/study/ap-precalculus-u4-matrices-modeling-contexts/)

---

From [OwlsPrep](https://www.owlsprep.com) — free study guides for A-Level, IB, AP and IGCSE, written against the official syllabus. Canonical page: https://www.owlsprep.com/study/ap-precalculus-u4-matrices-as-functions/
