---
title: Functions and Mathematical Models
module: Limits and Continuity
moduleNumber: 1
lessonNumber: 1
order: 101
summary: >
  A function assigns exactly one output to each input and can be presented four
  ways: verbally, numerically, graphically, or by a formula. The elementary
  families — linear, polynomial, power, rational, trigonometric, exponential —
  model most elementary phenomena, and transformation, combination, and
  composition build every other function from them.
topics: [Limits and Continuity]
sources:
  - book: Stewart
    ref: "Ch. 1 — Functions and Limits; §1.1 Four Ways to Represent a Function"
  - book: Stewart
    ref: "§1.2 Mathematical Models: A Catalog of Essential Functions; §1.3 New Functions from Old Functions"
draft: false
---

Calculus studies how one quantity changes with another, so its basic object is a
rule that ties the two together. That rule is a **function**. Before differentiating
or integrating anything, we need a precise account of what a function is, which
functions occur often enough to name, and how to assemble complicated functions
from simple parts.

## Definition of a function

> **Definition (Function).** A function $f$ is a rule that assigns to each element
> $x$ in a set $D$ exactly one element, denoted $f(x)$, in a set $E$. The set $D$ is
> the **domain**; the number $f(x)$ is the **value** of $f$ at $x$; and the
> **range** is the set of all values $f(x)$ as $x$ ranges over $D$.[^stewart-def]

The one-output-per-input requirement is the whole content of the definition. A
symbol standing for an arbitrary element of the domain is the **independent
variable**; a symbol standing for a value in the range is the **dependent
variable**. When a function is given by a formula with no stated domain, the
convention is that the domain is the set of all inputs for which the formula
produces a real number. For $f(x) = \sqrt{x+2}$ that forces $x + 2 \ge 0$, so the
domain is $[-2, \infty)$; for $g(x) = 1/(x^2 - x)$ the excluded inputs are the roots
of the denominator, giving domain $(-\infty, 0) \cup (0, 1) \cup (1, \infty)$.

A function admits four representations, and switching among them is routine:

- **Verbal** — a description in words ("the cost of mailing an envelope of weight
  $w$").
- **Numerical** — a table of input-output pairs, as from an experiment.
- **Visual** — a graph, the set $\{(x, f(x)) : x \in D\}$ of points in the plane.
- **Algebraic** — an explicit formula.

The graph is the most common picture, and it carries the domain and range directly:
the domain is the shadow of the graph on the $x$-axis, the range its shadow on the
$y$-axis. Reading a value off a graph amounts to measuring the height of the curve
above a point $x$.

> **Definition (Vertical Line Test).** A curve in the $xy$-plane is the graph of a
> function of $x$ if and only if no vertical line meets the curve more than once.

Two vertical intersections at $x = a$ would be two outputs assigned to the same
input, which the definition forbids. The parabola $x = y^2 - 2$ fails the test; it
splits into the two functions $y = \sqrt{x+2}$ and $y = -\sqrt{x+2}$, its upper and
lower halves.

A function need not be given by a single formula. A **piecewise defined** function
uses different formulas on different parts of its domain. The absolute value is the
standard case,

$$
|x| = \begin{cases} x & \text{if } x \ge 0, \\ -x & \text{if } x < 0, \end{cases}
$$

and step functions such as postage cost jump from one constant value to the next.

### The difference quotient

One combination built from a single function is common enough to name. For
$f$ and a nonzero increment $h$, the **difference quotient**

$$
\frac{f(a + h) - f(a)}{h}
$$

is the average rate of change of $f$ between $x = a$ and $x = a + h$. For
$f(x) = 2x^2 - 5x + 1$ a direct expansion gives

$$
\frac{f(a+h) - f(a)}{h}
= \frac{\bigl(2a^2 + 4ah + 2h^2 - 5a - 5h + 1\bigr) - \bigl(2a^2 - 5a + 1\bigr)}{h}
= 4a + 2h - 5.
$$

Letting $h$ shrink toward $0$ turns this average rate into an instantaneous one;
that passage to the limit defines [the derivative](/calculus/derivatives/the-derivative-and-rates-of-change).

## A catalog of essential functions

A few function families model most elementary phenomena, and their graphs form a
useful reference set.

$$
% caption: Six elementary families on a common frame: a line, a parabola, a square
% root, a reciprocal, the sine, and a growing exponential.
\begin{tikzpicture}[scale=1.0, font=\footnotesize]
\definecolor{acc}{HTML}{4A6FA5}
% row of three small axes
\foreach \dx/\lab in {0/{y = mx + b}, 4.2/{y = x^2}, 8.4/{y = x^{\frac{1}{2}}}} {
  \begin{scope}[xshift=\dx cm]
    \draw[black, ->] (-1.4,0) -- (1.7,0);
    \draw[black, ->] (0,-1.4) -- (0,1.7);
    \node[anchor=south, font=\scriptsize] at (0.15,1.7) {$\lab$};
  \end{scope}
}
\draw[very thick] (-1.2,-0.9) -- (1.5,1.35);
\begin{scope}[xshift=4.2cm]
  \draw[very thick] plot[domain=-1.25:1.25, samples=40] (\x, {0.95*\x*\x});
\end{scope}
\begin{scope}[xshift=8.4cm]
  \draw[very thick] plot[domain=0:1.55, samples=40] (\x, {1.25*sqrt(\x)});
\end{scope}
% second row
\foreach \dx/\lab in {0/{y = \frac{1}{x}}, 4.2/{y = \sin x}, 8.4/{y = 2^x}} {
  \begin{scope}[xshift=\dx cm, yshift=-4cm]
    \draw[black, ->] (-1.6,0) -- (1.8,0);
    \draw[black, ->] (0,-1.4) -- (0,1.7);
    \node[anchor=south, font=\scriptsize] at (0.2,1.7) {$\lab$};
  \end{scope}
}
\begin{scope}[xshift=0cm, yshift=-4cm]
  \draw[very thick] plot[domain=0.32:1.5, samples=40] (\x, {0.48/\x});
  \draw[very thick] plot[domain=-1.5:-0.32, samples=40] (\x, {0.48/\x});
\end{scope}
\begin{scope}[xshift=4.2cm, yshift=-4cm]
  \draw[very thick] plot[domain=-1.55:1.55, samples=60] (\x, {1.2*sin(\x*114.59)});
\end{scope}
\begin{scope}[xshift=8.4cm, yshift=-4cm]
  \draw[very thick] plot[domain=-1.5:0.85, samples=40] (\x, {0.42*pow(2,\x*1.6)});
\end{scope}
\end{tikzpicture}
$$

The families divide by the algebra used to build them:

- **Linear:** $f(x) = mx + b$. The graph is a line; the defining feature is a
  constant rate of change $m$, so equal steps in $x$ produce equal steps in $y$.
- **Polynomial:** $P(x) = a_n x^n + \cdots + a_1 x + a_0$ with $a_n \ne 0$ of
  **degree** $n$. Domain $(-\infty, \infty)$. Degree $1$ is linear, degree $2$
  quadratic (a parabola), degree $3$ cubic.
- **Power:** $f(x) = x^a$. Integer $a$ gives the monomials; $a = 1/n$ gives root
  functions $\sqrt[n]{x}$; $a = -1$ gives the reciprocal $1/x$, whose graph is a
  hyperbola.
- **Rational:** a ratio $P(x)/Q(x)$ of polynomials, defined wherever
  $Q(x) \ne 0$.
- **Trigonometric:** $\sin x$, $\cos x$, $\tan x$, and their reciprocals; periodic,
  with $\sin$ and $\cos$ bounded in $[-1, 1]$.
- **Exponential and logarithmic:** $f(x) = b^x$ with base $b > 0$, and its inverse
  $\log_b x$. Exponentials model growth and decay and are examined in
  [their own module](/calculus/exponential-logarithmic-and-inverse-functions/inverse-functions-logarithms-and-exponentials).

| Family | Form | Domain | Distinguishing trait |
| --- | --- | --- | --- |
| Linear | $mx + b$ | $\mathbb{R}$ | constant rate of change |
| Polynomial | $\sum a_k x^k$ | $\mathbb{R}$ | finitely many turning points |
| Power | $x^a$ | depends on $a$ | roots, reciprocals as special cases |
| Rational | $P/Q$ | $Q \ne 0$ | vertical asymptotes at zeros of $Q$ |
| Trigonometric | $\sin x, \cos x, \dots$ | $\mathbb{R}$ (some restricted) | periodic |
| Exponential | $b^x$ | $\mathbb{R}$ | constant _ratio_ per unit step |

The distinction between polynomial and exponential growth is worth stating precisely.
A linear function adds a fixed amount per unit step; an exponential multiplies by a
fixed ratio per unit step. The multiplicative rule wins in the long run: an exponential
eventually overtakes every polynomial, a fact made quantitative by
[l'Hospital's Rule](/calculus/exponential-logarithmic-and-inverse-functions/lhospitals-rule).

### Fitting a model to data

A **mathematical model** is a function chosen to describe a real phenomenon. Given
a scatter of data points, one selects a family whose shape matches the trend and
then fits its parameters. Points falling near a line call for a linear model; a
parabolic arc calls for a quadratic. For carbon-dioxide concentration measured
yearly, the points lie close to a line, and the least-squares fit
$C \approx 1.71262\,t - 3054.14$ (with $t$ the year) reproduces the record: it
returns $348.8$ ppm for $1987$, against a measured $348.9$. Reading a model inside
the observed range is **interpolation** and is reliable; reading it outside is
**extrapolation** and is not, since nothing guarantees the trend continues.

## New functions from old

Three operations generate the endless variety of functions in calculus from the
catalog above: transforming one function, combining two arithmetically, and
composing one inside another.

### Transformations

Adding or multiplying constants shifts, stretches, or reflects a graph in
predictable ways. Take a base function $y = f(x)$ and a constant $c > 0$.

$$
% caption: The parabola $y = x^2$ shifted up by $c$, shifted right by $c$, and
% reflected across the $x$-axis; each constant acts on one coordinate.
\begin{tikzpicture}[scale=1.0, font=\footnotesize]
\definecolor{acc}{HTML}{4A6FA5}
\draw[black, ->] (-2.4,0) -- (2.6,0) node[right] {$x$};
\draw[black, ->] (0,-1.6) -- (0,3.0) node[above] {$y$};
% base parabola
\draw[black, very thick] plot[domain=-1.55:1.55, samples=50] (\x, {\x*\x});
\node[black, anchor=west, font=\scriptsize] at (1.45,2.25) {$y = x^2$};
% shifted up
\draw[acc, very thick, dashed] plot[domain=-1.35:1.35, samples=50] (\x, {\x*\x + 0.9});
\node[acc, anchor=south, font=\scriptsize] at (-1.35,2.7) {shifted up};
% shifted right
\draw[acc, very thick] plot[domain=-0.2:2.4, samples=50] (\x, {(\x-1.1)*(\x-1.1)});
\node[acc, anchor=west, font=\scriptsize] at (1.7,1.1) {shifted right};
% reflected down
\draw[black, very thick, dotted] plot[domain=-1.25:1.25, samples=50] (\x, {-\x*\x});
\node[black, anchor=north, font=\scriptsize] at (1.15,-1.45) {mirrored};
\end{tikzpicture}
$$

The rules split cleanly by whether the constant touches the output or the input:

| Operation | Effect on the graph |
| --- | --- |
| $f(x) + c$ | shift up by $c$ |
| $f(x) - c$ | shift down by $c$ |
| $f(x - c)$ | shift right by $c$ |
| $f(x + c)$ | shift left by $c$ |
| $c\,f(x)$, $c > 1$ | stretch vertically by $c$ |
| $f(cx)$, $c > 1$ | compress horizontally by $c$ |
| $-f(x)$ | reflect across the $x$-axis |
| $f(-x)$ | reflect across the $y$-axis |

Constants applied to the output act as expected; constants applied to the input act
in reverse, because $f(x - c)$ reaches a given height only once $x$ has advanced to
$x - c = $ the point where $f$ had it. A factor $c$ inside the argument compresses the
graph horizontally by $c$: $y = \sin 2x$ runs through a full cycle in half the span of
$y = \sin x$.

$$
% caption: Horizontal compression: $y = \sin 2x$ completes a cycle in half the run
% of $y = \sin x$ because the input advances twice as fast.
\begin{tikzpicture}[scale=1.0, font=\footnotesize]
\definecolor{acc}{HTML}{4A6FA5}
\draw[black, ->] (-0.3,0) -- (6.9,0) node[right] {$x$};
\draw[black, ->] (0,-1.7) -- (0,1.9) node[above] {$y$};
\draw[black, very thick] plot[domain=0:6.6, samples=90] (\x, {1.2*sin(\x*57.2958)});
\node[black, anchor=south, font=\scriptsize] at (1.9,1.35) {$y = \sin x$};
\draw[acc, very thick] plot[domain=0:6.6, samples=120] (\x, {1.2*sin(2*\x*57.2958)});
\node[acc, anchor=south, font=\scriptsize] at (4.3,1.35) {$y = \sin 2x$};
\end{tikzpicture}
$$

Completing the square rewrites any quadratic as a shifted parabola, exposing the
transformations directly.

> **Worked example (completing the square).** Graph $f(x) = x^2 + 6x + 10$.
>
> Group the $x$-terms and complete the square:
> $$
> x^2 + 6x + 10 = (x^2 + 6x + 9) + 1 = (x + 3)^2 + 1.
> $$
> The graph is $y = x^2$ shifted $3$ units left and $1$ unit up, a parabola with
> vertex $(-3, 1)$ opening upward.[^stewart-transf]

A related operation reflects part of a graph rather than the whole. Taking the absolute
value of a function leaves the part above the $x$-axis fixed and flips the part below it
upward, since $|f(x)| = f(x)$ where $f(x) \ge 0$ and $|f(x)| = -f(x)$ where $f(x) < 0$.

$$
% caption: The dashed parabola $y = x^2 - 1$; taking the absolute value reflects its
% below-axis arch upward, giving the solid graph of $y = |x^2 - 1|$.
\begin{tikzpicture}[scale=1.1, font=\footnotesize]
\definecolor{acc}{HTML}{4A6FA5}
\draw[black, ->] (-2.1,0) -- (2.2,0) node[right] {$x$};
\draw[black, ->] (0,-1.5) -- (0,3.0) node[above] {$y$};
\draw[black, very thick, dashed] plot[domain=-1.8:1.8, samples=70] (\x, {\x*\x - 1});
\draw[acc, very thick] plot[domain=-1.8:-1.0, samples=30] (\x, {\x*\x - 1});
\draw[acc, very thick] plot[domain=-1.0:1.0, samples=45] (\x, {1 - \x*\x});
\draw[acc, very thick] plot[domain=1.0:1.8, samples=30] (\x, {\x*\x - 1});
\node[acc, anchor=west, font=\scriptsize] at (1.15,2.3) {solid: absolute value};
\node[black, anchor=west, font=\scriptsize] at (0.55,-0.6) {dashed: original};
\end{tikzpicture}
$$

> **Worked example (absolute value of a function).** Graph $y = |x^2 - 1|$.
>
> Start with the parabola $y = x^2 - 1$, which is $y = x^2$ shifted down one unit; it
> lies below the $x$-axis exactly for $-1 < x < 1$. Reflect that arch across the
> $x$-axis and leave the rest fixed. The result is
> $$
> |x^2 - 1| = \begin{cases} x^2 - 1 & \text{if } |x| \ge 1, \\ 1 - x^2 & \text{if } |x| < 1, \end{cases}
> $$
> a curve that dips to touch the axis at $x = \pm 1$ and peaks at $(0, 1)$.

### Combinations

Two functions $f$ and $g$ combine pointwise under the arithmetic operations, on the
intersection of their domains (and away from zeros of the denominator for the
quotient):

$$
(f + g)(x) = f(x) + g(x), \quad (fg)(x) = f(x)\,g(x), \quad
\left(\frac{f}{g}\right)(x) = \frac{f(x)}{g(x)}.
$$

### Composition

The operation with no counterpart in ordinary arithmetic feeds the output of one
function into the input of another.

> **Definition (Composite function).** Given $f$ and $g$, the composite $f \circ g$
> is defined by $(f \circ g)(x) = f(g(x))$, with domain the set of $x$ in the domain
> of $g$ for which $g(x)$ lies in the domain of $f$.

Read $f \circ g$ right to left: apply $g$ first, then $f$. The order matters, since
$f \circ g$ and $g \circ f$ are generally different functions.

$$
% caption: Composition as two machines in series: $x$ enters $g$, its output
% $g(x)$ becomes the input to $f$, and the final output is $f(g(x))$.
\begin{tikzpicture}[scale=1.0, font=\footnotesize,
  box/.style={draw, thick, minimum width=16mm, minimum height=13mm, align=center}]
\definecolor{acc}{HTML}{4A6FA5}
\node (x) at (0,0) {$x$};
\node[box] (g) at (2.4,0) {$g$};
\node[box] (f) at (6.4,0) {$f$};
\node (out) at (9.0,0) {$f(g(x))$};
\draw[->, thick] (x) -- (g);
\draw[->, thick] (g) -- node[above, font=\scriptsize] {$g(x)$} (f);
\draw[->, thick] (f) -- (out);
\end{tikzpicture}
$$

For $f(x) = \sqrt{x}$ and $g(x) = x^2 + 1$,

$$
(f \circ g)(x) = \sqrt{x^2 + 1}, \qquad (g \circ f)(x) = (\sqrt{x})^2 + 1 = x + 1,
$$

with domains $(-\infty, \infty)$ and $[0, \infty)$ respectively. Composition is the
structure the [Chain Rule](/calculus/derivatives/differentiation-rules-and-the-chain-rule)
differentiates.

The domain of a composite is not the whole real line by default; each stage imposes its
own restriction, and both must hold.

> **Worked example (composite domains).** For $f(x) = \sqrt{x}$ and
> $g(x) = \sqrt{2 - x}$, find the four composites and their domains.
>
> $$
> (f \circ g)(x) = \sqrt{\sqrt{2 - x}} = \sqrt[4]{2 - x}.
> $$
> This needs $2 - x \ge 0$, so the domain is $(-\infty, 2]$.
> $$
> (g \circ f)(x) = \sqrt{2 - \sqrt{x}}.
> $$
> Here $\sqrt{x}$ needs $x \ge 0$, and $2 - \sqrt{x} \ge 0$ needs $\sqrt{x} \le 2$,
> i.e. $x \le 4$; the domain is $[0, 4]$.
> $$
> (f \circ f)(x) = \sqrt{\sqrt{x}} = \sqrt[4]{x}, \qquad \text{domain } [0, \infty).
> $$
> $$
> (g \circ g)(x) = \sqrt{2 - \sqrt{2 - x}}.
> $$
> The inner root needs $x \le 2$; the outer needs $2 - \sqrt{2 - x} \ge 0$, i.e.
> $\sqrt{2 - x} \le 2$, i.e. $2 - x \le 4$, i.e. $x \ge -2$. The domain is $[-2, 2]$.

Recognizing a function as a composite runs the machine backward: given a formula,
name the stages applied in order.

> **Worked example (decomposition).** Write $F(x) = \cos^2(x + 9)$ as
> $f \circ g \circ h$.
>
> Read the formula as three operations in sequence: add $9$, take the cosine, then
> square. So
> $$
> h(x) = x + 9, \qquad g(x) = \cos x, \qquad f(x) = x^2,
> $$
> and $f(g(h(x))) = f(g(x + 9)) = f(\cos(x + 9)) = [\cos(x + 9)]^2 = F(x)$.

## Symmetry

Two symmetry conditions simplify graphing and, later, integration.

> **Definition (Even and odd functions).** A function $f$ is **even** if
> $f(-x) = f(x)$ for every $x$ in its domain, and **odd** if $f(-x) = -f(x)$. An
> even function's graph is symmetric across the $y$-axis; an odd function's graph is
> symmetric through the origin.

$$
% caption: An even function reflects across the $y$-axis (left); an odd function
% carries to itself under a half-turn about the origin (right).
\begin{tikzpicture}[scale=1.0, font=\footnotesize]
\definecolor{acc}{HTML}{4A6FA5}
% even
\begin{scope}
  \draw[black, ->] (-1.9,0) -- (2.0,0) node[right] {$x$};
  \draw[black, ->] (0,-0.6) -- (0,2.2) node[above] {$y$};
  \draw[acc, very thick] plot[domain=-1.55:1.55, samples=50] (\x, {0.72*\x*\x});
  \fill (1.2,{0.72*1.44}) circle (1.6pt);
  \fill (-1.2,{0.72*1.44}) circle (1.6pt);
  \draw[black, dashed] (-1.2,{0.72*1.44}) -- (1.2,{0.72*1.44});
  \node[anchor=north, font=\scriptsize] at (0,-0.65) {even: symmetric in $y$-axis};
\end{scope}
% odd
\begin{scope}[xshift=6.2cm]
  \draw[black, ->] (-1.9,0) -- (2.0,0) node[right] {$x$};
  \draw[black, ->] (0,-2.0) -- (0,2.0) node[above] {$y$};
  \draw[acc, very thick] plot[domain=-1.32:1.32, samples=50] (\x, {0.85*\x*\x*\x});
  \fill (1.1,{0.85*1.331}) circle (1.6pt);
  \fill (-1.1,{-0.85*1.331}) circle (1.6pt);
  \draw[black, dashed] (-1.1,{-0.85*1.331}) -- (1.1,{0.85*1.331});
  \node[anchor=north, font=\scriptsize] at (0,-2.05) {odd: symmetric about origin};
\end{scope}
\end{tikzpicture}
$$

The power functions supply the archetypes and the naming: $f(x) = x^n$ is even
exactly when $n$ is even and odd exactly when $n$ is odd. Most functions are neither;
$h(x) = 2x - x^2$ satisfies neither identity. Knowing a function is even or odd
halves the work of graphing it, since one side determines the other.

[^stewart-def]: Stewart, §1.1 — the rule-based definition of a function, its domain, range, and the four representations (verbal, numerical, visual, algebraic).

[^stewart-transf]: Stewart, §1.3 — shifts, stretches, and reflections; completing the square to graph a quadratic; the absolute value of a function; and composition with its domain.
