Functions

In many situations, one quantity depends on another. The area of a circle depends on its radius. The cost of a taxi ride depends on its distance. A function is the mathematical name for this idea.

What is a function?

A function ${f}$ is a rule that assigns to each input ${x}$ exactly one output, written ${f(x)}$. The set of all allowed inputs is the domain. The set of all outputs is the range.

For example, the area of a circle is a function of its radius: ${A(r)=\pi r^2}$. Each radius gives exactly one area. The domain is all ${r>0}$.

The key words are "exactly one". The equation ${y^2=x}$ does not define ${y}$ as a function of ${x}$. When ${x=4}$, both ${y=2}$ and ${y=-2}$ work: one input gives two outputs.

Function notation

The symbol ${f(x)}$ is read "${f}$ of ${x}$". It means the output of ${f}$ when the input is ${x}$. It does not mean ${f}$ times ${x}$.

To evaluate a function, replace ${x}$ everywhere by the input. Use parentheses around the input, especially when it is negative or has more than one term.

Example 1: Let ${f(x)=x^2-3x+1}$. Find each value.

(a) ${f(2)}$

(b) ${f(-1)}$

(c) ${f(a+1)}$

Solution:

(a) ${f(2)=2^2-3(2)+1=4-6+1=-1}$

(b) The parentheses keep the sign right: ${(-1)^2=1}$.

$\begin{align*}&f(-1)\\&=(-1)^2-3(-1)+1\\&=1+3+1=5\end{align*}$

(c) Replace every ${x}$ by ${(a+1)}$. Then expand, and combine like terms:

$\begin{align*}&f(a+1)\\&=(a+1)^2-3(a+1)+1\\&=a^2+2a+1-3a-3+1\\&=a^2-a-1\end{align*}$

Watch out: ${f(a+1)}$ is not ${f(a)+1}$. In Example 1, ${f(a)+1=a^2-3a+2}$, which is different from ${f(a+1)=a^2-a-1}$.

The difference quotient

The expression

${\dfrac{f(x+h)-f(x)}{h}}$,   ${h\ne 0}$

is called the difference quotient. It is the slope of the line through the points ${(x,f(x))}$ and ${(x+h,f(x+h))}$ on the graph. It is the starting point of calculus: see the derivative at a point.

Example 2: Find and simplify the difference quotient for ${f(x)=x^2-3x+1}$.

Solution:

First find ${f(x+h)}$:

$\begin{align*}&f(x+h)\\&=(x+h)^2-3(x+h)+1\\&=x^2+2xh+h^2-3x-3h+1\end{align*}$

Subtract ${f(x)=x^2-3x+1}$. The terms ${x^2}$, ${-3x}$, and ${1}$ cancel:

${f(x+h)-f(x)=2xh+h^2-3h}$

Divide by ${h}$. Every term has a factor ${h}$:

$\begin{align*}&\dfrac{2xh+h^2-3h}{h}\\&=\dfrac{h(2x+h-3)}{h}\\&=2x+h-3\end{align*}$

Finding the domain

When a function is given by a formula and nothing else is said, its domain is every real number for which the formula makes sense. So leave out every ${x}$ that would:

Example 3: Find the domain of each function. Write it in interval notation.

(a) ${f(x)=\dfrac{1}{x^2-4}}$

(b) ${g(x)=\sqrt{6-2x}}$

(c) ${h(x)=\dfrac{\sqrt{x+1}}{x-3}}$

Solution:

(a) The denominator is ${0}$ when ${x^2=4}$, so when ${x=\pm 2}$. Leave these out:

${(-\infty,-2)\cup(-2,2)\cup(2,\infty)}$

(b) The radicand must not be negative:

$\begin{align*}6-2x&\ge 0\\-2x&\ge -6\\x&\le 3\end{align*}$

(We divided by ${-2}$, so the sign reversed.) The domain is ${(-\infty,3]}$.

(c) Two conditions: the radicand ${x+1\ge 0}$, so ${x\ge -1}$. And the denominator ${x-3\ne 0}$, so ${x\ne 3}$. Together:

${[-1,3)\cup(3,\infty)}$

Graphs of functions

The graph of ${f}$ is the graph of the equation ${y=f(x)}$: all the points ${(x,f(x))}$. On a graph,

The vertical line test

A function has exactly one output for each input. On a graph, that means each vertical line meets the graph at most once:

A curve is the graph of a function if and only if no vertical line meets it more than once.

xy
(a) ${y=x^2-2}$: every vertical line meets it once. A function.
xy
(b) ${x^2+y^2=4}$: some vertical lines meet it twice. Not a function.

Example 4: The graph of a function ${f}$ is shown. Find ${f(1)}$, ${f(3)}$, the domain, and the range.

(−1, 2)(3, 2)(1, −2)xy
The graph of ${f}$. The solid dots at the ends mean the endpoints are part of the graph.

Solution:

  • At ${x=1}$, the graph is at height ${-2}$. So ${f(1)=-2}$.
  • At ${x=3}$, the graph is at height ${2}$. So ${f(3)=2}$.
  • The graph covers the ${x}$-values from ${-1}$ to ${3}$, including both ends. So the domain is ${[-1,3]}$.
  • The lowest height is ${-2}$, and the highest is ${2}$. So the range is ${[-2,2]}$.

Piecewise functions

A piecewise function uses different formulas on different parts of its domain. For example,

$f(x)=\begin{cases}x+1, & x<1\\4-x, & x\ge 1\end{cases}$

This says: if ${x}$ is less than ${1}$, use ${x+1}$. If ${x}$ is ${1}$ or more, use ${4-x}$. The absolute value function is a familiar piecewise function: ${|x|=x}$ for ${x\ge 0}$, and ${|x|=-x}$ for ${x<0}$.

Example 5: For the function ${f}$ above, find ${f(-2)}$, ${f(1)}$, and ${f(3)}$. Then sketch its graph.

Solution:

For each input, first decide which piece applies:

  • ${-2<1}$, so use ${x+1}$: ${f(-2)=-2+1=-1}$.
  • ${1\ge 1}$, so use ${4-x}$: ${f(1)=4-1=3}$.
  • ${3\ge 1}$, so use ${4-x}$: ${f(3)=4-3=1}$.

Each piece is part of a line. The first piece stops just before ${x=1}$, at height ${1+1=2}$: draw an open circle there. The second piece starts at ${(1,3)}$: draw a solid dot.

123xy
The open circle at ${(1,2)}$ is not on the graph. The solid dot at ${(1,3)}$ is: ${f(1)=3}$.

An application

Example 6: A rectangle has a perimeter of ${20}$ cm. Write its area ${A}$ as a function of its width ${w}$, and give the domain.

Solution:

Let the length be ${l}$. The perimeter is ${2l+2w=20}$, so ${l+w=10}$, and ${l=10-w}$. The area is length times width:

${A(w)=w(10-w)}$

The width must be positive, and so must the length: ${10-w>0}$, so ${w<10}$. The domain is ${(0,10)}$.

For example, ${A(3)=3\cdot 7=21}$ cm${^2}$. In the section on quadratic functions, we will find the width that gives the largest area.

Summary