Skip to contentSkip to lesson map

Introduction to Functions

Reading
MMAC Ch 1.1, pp 2-10, and Ch 1.5, pp 71-85
Practice
Optional HW 3 Q2.2, Q9.1, and Q13.2.
Lesson map

Objectives

  1. Determine if a mapping between inputs and outputs is a function.
  2. Given a function, identify the output variable, the input variable(s), and the domain.
  3. Evaluate a function at a given input, by hand and using R.
  4. Given a function, determine whether its inverse exists, and if so, find it.

1. Functions

Objective. Determine if a mapping between inputs and outputs is a function.

In a mapping diagram, an arrow runs from each input to its output.

Figure

(a) A function

Figure

(b) Not a function

Diagram (a) is a function, because every input has exactly one arrow leaving it. Inputs 1 and 2 share the output aa, and a shared output is allowed. No arrow reaches the output cc, and an unused output is allowed too. Diagram (b) is not a function, because input 1 has two arrows leaving it.

Definition 1 (Function).

A function is a rule assigning every input to exactly one output.

In symbols, y=f(x)y = f(x) means the input xx is assigned to the output yy.

The pairs (1,2)(1, 2) and (1,5)(1, 5), read as input and output, are not a function, because the input 1 is assigned to two outputs. The definition assigns every input to exactly one output.

Example 1

Determine whether each rule is a function.

  • (a) Given a cadet, what squadron is the cadet in?
  • (b) Given a number, what is twice that number?
  • (c) Given a temperature, at what time today was it that hot?
  • (d) Given a number, what is its square root?
ShowHide solution

By the definition of a function, a rule is a function when it assigns every input to exactly one output.

  • (a) The rule is a function, because every cadet belongs to exactly one squadron.
  • (b) The rule is a function, because every number has exactly one double.
  • (c) The rule is not a function, because the same temperature can occur at two times in one day.
  • (d) The rule is not a function, because the input 9 has two square roots, 3 and −3-3. The radical sign names only the non-negative one, 9=3\sqrt{9} = 3, and the rule “given a number, what is x\sqrt{x}?” is a function on the non-negative numbers.

Tables. A table lists the inputs in the top row and the outputs in the bottom row. A table defines a function when no input appears with two different outputs. An input listed twice with the same output both times still has exactly one output.

Example 2

Determine whether each table defines a function.

(a) 1.15

Input25759
Output38381

(c) 1.15

Input−2-2−1-1012
Output41014

(b) 1.15

Input12427
Output56592

(d) 

Input666
Output258

ShowHide solution
  • (a) Table (a) defines a function, because every input has one output. Input 5 appears twice, with output 8 both times. Output 3 comes from the two inputs 2 and 7.
  • (b) Table (b) does not define a function, because input 2 gives two outputs, 6 and 9.
  • (c) Table (c) defines a function, because each input appears once.
  • (d) Table (d) does not define a function, because input 6 gives the three outputs 2, 5, and 8.

As in the textbook, a curve that is the graph of a function is itself called a function.

Criterion 2 (Vertical line test).

A curve in the xyxy-plane is a function if and only if every vertical line intersects the curve at most once.

A vertical line x=ax = a intersects the curve at one point for each output paired with the input aa. A vertical line that intersects the curve twice shows that the input aa has two outputs. The test also allows a vertical line that misses the curve, because “at most once” includes zero times.

Example 3

Use the vertical line test to determine whether each curve is a function.

Figure

(a)

Figure

(b)

Figure

(c)

Figure

(d)

Figure

(e)

Figure

(f)

ShowHide solution
  • (a) Curve (a) is a function, because every vertical line intersects the parabola at most once.
  • (b) Curve (b) is not a function, because the dashed vertical line intersects the curve twice.
  • (c) Curve (c) is not a function, because the dashed vertical line intersects the circle twice.
  • (d) Curve (d) is a function, because the vertical line through the jump intersects the curve once, at the filled dot. The open dot marks a point left off the curve.
  • (e) Curve (e) is not a function, because the curve lies on one vertical line, which intersects the curve at every point.
  • (f) Curve (f) is a function, because every vertical line intersects the curve at most once.

Next: 2. Input, Output, and DomainLesson map

2. Input, Output, and Domain

Objective. Given a function, identify the output variable, the input variable(s), and the domain.

Definition 3 (Input variable).

The input variable is the variable whose values are the inputs of a function.

In y=f(x)y = f(x) the input variable is xx, the variable inside the parentheses. In position(time)=a⋅time2+b⋅time+c\text{position}(\text{time}) = a \cdot \text{time}^{2} + b \cdot \text{time} + c, the letters aa, bb, and cc are not input variables, because they are constants: their values stay fixed while the input time varies.

Definition 4 (Output variable).

The output variable is the variable whose values are the outputs of a function.

In y=f(x)y = f(x) the output variable is yy, also written f(x)f(x). The letter ff is not the output variable, because it names the function rather than its output values.

Definition 5 (Domain).

The domain is the set of input values of a function y=f(x)y = f(x).

The number 1 is not in the domain of s(x)=x−2s(x) = \sqrt{x - 2}, because 1−2=−11 - 2 = -1 and −1\sqrt{-1} is not a real number. The function has no output at 1.

The range is the set of output values of a function y=f(x)y = f(x).

Example 4

The table gives the number of Twitter users, in millions, by quarter. Year counts years since 2000.

Year1111.2511.511.7512.75
Users (millions)6885101117185

Identify the domain and range of the function the table defines.

ShowHide solution

By the definition of the domain, the domain is the set of inputs in the top row,

{11, 11.25, 11.5, 11.75, 12.75}, \{11,\ 11.25,\ 11.5,\ 11.75,\ 12.75\},

and the range is the set of outputs in the bottom row,

{68, 85, 101, 117, 185}. \{68,\ 85,\ 101,\ 117,\ 185\}.

The domain excludes 12, because the table gives no output for 12.

Example 5

Identify the input variable and the output variable of each function:

g(r)=sin⁡(2r)+cos⁡(3r),position(time)=a⋅time2+b⋅time+c,h(z)=40e−3z.\begin{gather*} g(r) = \sin(2r) + \cos(3r), \qquad\qquad \text{position}(\text{time}) = a \cdot \text{time}^{2} + b \cdot \text{time} + c, \\[3pt] h(z) = 40e^{-3z}. \end{gather*}
ShowHide solution
  • For g(r)g(r), the input variable is rr and the output variable is g(r)g(r).
  • For position(time)\text{position}(\text{time}), the input variable is time and the output variable is position.
  • For h(z)h(z), the input variable is zz and the output variable is h(z)h(z).

Domain of a formula. When no domain is given, the domain of a function given by a formula is the set of real numbers at which the formula gives a real output.

Interval notation.

x≥2x \geq 2[2,∞)[2, \infty)
x>4x > 4(4,∞)(4, \infty)
every real number(−∞,∞)(-\infty, \infty)
x≠5x \neq 5(−∞,5)∪(5,∞)(-\infty, 5) \cup (5, \infty)
x≤−3x \leq -3 or x≥3x \geq 3(−∞,−3 ]∪[ 3,∞)(-\infty, -3\,] \cup [\,3, \infty)

A square bracket includes the endpoint, and a parenthesis leaves the endpoint out. Because no real number equals ∞\infty, an infinite end always takes a parenthesis. To join two intervals into one set, write the union symbol ∪\cup between them.

Finding a domain.

  1. Start from every real number.
  2. For each denominator, solve denominator=0\text{denominator} = 0 and remove those inputs.
  3. For each even root, keep only the inputs for which the expression under the root is non-negative.
  4. For each logarithm, keep only the inputs for which its argument is positive.
  5. Write the inputs that remain in interval notation.

Example 6

Identify the input variable, the output variable, and the domain of each function:

f(x)=2x2−3x+1,height(t)=10cos⁡ ⁣(315t),q(a)=1(a−5)2. f(x) = 2x^{2} - 3x + 1, \qquad\qquad \text{height}(t) = 10\cos\!\left(\tfrac{3}{15}t\right), \qquad\qquad q(a) = \frac{1}{(a - 5)^{2}}.
ShowHide solution
  • For f(x)f(x), the input variable is xx and the output variable is f(x)f(x). The domain is (−∞,∞)(-\infty, \infty), because the formula has no denominator, root, or logarithm.
  • For height(t)\text{height}(t), the input variable is tt and the output variable is height. The domain is (−∞,∞)(-\infty, \infty), because cosine is defined for every real number.
  • For q(a)q(a), the input variable is aa and the output variable is q(a)q(a). The domain is (−∞,5)∪(5,∞)(-\infty, 5) \cup (5, \infty), because the denominator (a−5)2(a - 5)^{2} is 0 at a=5a = 5.

Example 7

Identify the input variable, the output variable, and the domain of each function:

s(x)=x−2,L(x)=ln⁡(x−4). s(x) = \sqrt{x - 2}, \qquad\qquad L(x) = \ln(x - 4).
ShowHide solution
  • For s(x)s(x), the input variable is xx and the output variable is s(x)s(x). A square root is an even root, and the expression under it must satisfy x−2≥0x - 2 \geq 0, that is, x≥2x \geq 2. The domain is [2,∞)[2, \infty), and 2 is included because 0=0\sqrt{0} = 0.
  • For L(x)L(x), the input variable is xx and the output variable is L(x)L(x). The argument of the logarithm must satisfy x−4>0x - 4 > 0, that is, x>4x > 4. The domain is (4,∞)(4, \infty), and 4 is left out because ln⁡(0)\ln(0) is undefined.

Example 8

Find the domain of the function

k(t)=(6−2t)1/4+1. k(t) = (6 - 2t)^{1/4} + 1.
ShowHide solution

The power 1/41/4 is a fourth root, an even root. The expression under it must be non-negative:

6−2t≥06≥2tt≤3.\begin{align*} 6 - 2t &\geq 0 \\ 6 &\geq 2t \\ t &\leq 3. \end{align*}

The domain is (−∞,3 ](-\infty, 3\,], and 3 is included because the fourth root of 0 is 0.

Next: 3. Function EvaluationLesson map

3. Function Evaluation

Objective. Evaluate a function at a given input, by hand and using R.

To evaluate ff at the input 2 by hand, replace every xx in the formula with 2. A negative input goes in parentheses: for f(x)=2x+3f(x) = 2x + 3, the value at −1-1 is f(−1)=2(−1)+3f(-1) = 2(-1) + 3.

To evaluate f(2)f(2) in R, define ff with makeFun and type f(2) (Lesson 2 sheet, sections 4 and 5). Inside makeFun, the expressions ln⁡(x)\ln(x), exe^{x}, ∣x∣|x|, and xn\sqrt[n]{x} are written log(x), exp(x), abs(x), and x^(1/n). For a negative xx, R returns NaN for x^(1/n), even when nn is odd (Lesson 1 sheet, section 2).

Example 9

For the function

f(x)=2x+3, f(x) = 2x + 3,

evaluate f(−1)f(-1), f(0)f(0), and f(2)f(2) by hand and in R, then plot ff on −2≤x≤4-2 \leq x \leq 4.

ShowHide solution

Substituting each input into the formula gives

f(−1)=2(−1)+3=1,f(0)=2(0)+3=3,f(2)=2(2)+3=7.\begin{gather*} f(-1) = 2(-1) + 3 = 1, \\ f(0) = 2(0) + 3 = 3, \\ f(2) = 2(2) + 3 = 7. \end{gather*}

R defines ff, evaluates it at the same inputs, and plots it:

f = makeFun(2*x + 3 ~ x)
f(-1)
f(0)
f(2)
plotFun(f(x) ~ x, xlim = c(-2, 4))

The three evaluations print [1] 1, [1] 3, and [1] 7, the same values as by hand. On the graph of ff, each evaluation is a point on the line: the input on the horizontal axis and the output above it, (−1,1)(-1, 1), (0,3)(0, 3), and (2,7)(2, 7).

Figure

Example 10

For the function

w(x)=ln⁡(x2+1)+2x, w(x) = \ln(x^{2} + 1) + 2x,

evaluate w(1.7)w(1.7) in R.

ShowHide solution

Define ww, writing ln⁡\ln as log, then evaluate it at 1.7:

w = makeFun(log(x^2 + 1) + 2*x ~ x)
w(1.7)

The last line prints [1] 4.758409, which gives w(1.7)≈4.758w(1.7) \approx 4.758. By hand with a calculator, the evaluation agrees:

w(1.7)=ln⁡(1.72+1)+2(1.7)=ln⁡(3.89)+3.4≈1.358+3.4=4.758. w(1.7) = \ln(1.7^{2} + 1) + 2(1.7) = \ln(3.89) + 3.4 \approx 1.358 + 3.4 = 4.758.

Example 11

For the function

v(t)=t3  e−t/4, v(t) = \sqrt[3]{t}\; e^{-t/4},

evaluate v(5.2)v(5.2) in R.

ShowHide solution

Define vv with makeFun as in Example 10, writing the cube root as the 13\frac{1}{3} power, then evaluate it at 5.2:

v = makeFun(t^(1/3)*exp(-t/4) ~ t)
v(5.2)

The last line prints [1] 0.4721554, which gives v(5.2)≈0.472v(5.2) \approx 0.472.

The number ee in makeFun. Inside makeFun, a bare e becomes a second input, and a call with one input stops with an error:

> f = makeFun(e^x ~ x)
> f(1)
Error in f(1) : argument "e" is missing, with no default

Write exe^x as exp(x) in the definition.

Inputs outside the domain. R prints Inf, -Inf, or NaN at an input outside the domain, as the Lesson 1 sheet, section 2, and the Lesson 2 sheet, section 5, show.

Plotting window and domain. The xx range of the plotting window is the interval set with xlim, and the domain is the set of inputs the formula allows. A wider window on q(a)=1/(a−5)2q(a) = 1/(a - 5)^{2} shows more of the graph, and the domain stays (−∞,5)∪(5,∞)(-\infty, 5) \cup (5, \infty) for every window. These two lines define qq and plot it on −2≤a≤12-2 \leq a \leq 12:

q = makeFun(1/(a - 5)^2 ~ a)

plotFun(q(a) ~ a, xlim = c(-2, 12))

Next: 4. Inverse FunctionsLesson map

4. Inverse Functions

Objective. Given a function, determine whether its inverse exists, and if so, find it.

The squadron rule of Example 1(a) run backwards asks, given a squadron, which cadet is in it. The reversed rule is not a function, because one squadron has many cadets.

Definition 6 (Inverse function).

The inverse function of f(x)f(x) maps each output from f(x)f(x) back to its corresponding input.

The rule that takes each output of f(x)=x2f(x) = x^2 back to an input is not an inverse function, because the output 4 has two corresponding inputs, 2 and −2-2. The definition maps each output back to one input.

Notation. The inverse of f(x)f(x) is written f−1(x)f^{-1}(x). The reciprocal is written [f(x)]−1=1/f(x)\bigl[f(x)\bigr]^{-1} = 1/f(x), a different function from f−1(x)f^{-1}(x).

Existence. An inverse interchanges inputs and outputs. A function has an inverse function only if every output comes from exactly one input.

Criterion 7 (Horizontal line test).

A function y=f(x)y = f(x) has an inverse function if and only if every horizontal line intersects its graph at most once.

A function f(x)f(x) is monotonic if f(c)<f(d)f(c) < f(d) for every pair of inputs cc and dd with c<dc < d, or if f(c)>f(d)f(c) > f(d) for every such pair.

In a definition, the word “if” means “if and only if”.

A monotonic function passes the horizontal line test and has an inverse.

Graph of an inverse. Interchanging inputs and outputs moves the point (a,b)(a, b) on the graph of ff to the point (b,a)(b, a) on the graph of f−1f^{-1}. The graph of f−1f^{-1} is the graph of ff reflected across the line y=xy = x.

Example 12

Determine whether the function each table defines has an inverse.

(a) The function ff takes a year to its sales.

Year2009201020112012
Sales ($ billions)121143168192

(b) 1.15

Input−2-2−1-1012
Output41014

ShowHide solution
  • (a) By the definition of the inverse function, f−1f^{-1} maps each sales figure back to its year. The function ff has an inverse, because each sales figure appears once and so comes from one year. The inverse takes the sales figure 168 back to its year: f−1(168)=2011f^{-1}(168) = 2011.
  • (b) The function has no inverse, because the output 4 comes from the two inputs −2-2 and 2.

Example 13

Use the horizontal line test to determine whether each function has an inverse.

Figure

(a)

Figure

(b)

Figure

(c)

Figure

(d)

ShowHide solution
  • (a) Function (a) has an inverse, because every horizontal line intersects the line at most once.
  • (b) Function (b) has no inverse, because the dashed horizontal line intersects the parabola twice.
  • (c) Function (c) has an inverse, because every horizontal line intersects the cubic at most once.
  • (d) Function (d) has no inverse, because the dashed horizontal line intersects the sine wave three times.

Finding an inverse.

  1. Check with the horizontal line test that ff has an inverse.
  2. Solve y=f(x)y = f(x) for xx in terms of yy.
  3. Interchange the variables xx and yy.

Example 14

For the function

f(x)=3x+7, f(x) = 3x + 7,

plot ff, determine whether ff has an inverse, and if so, find the inverse.

ShowHide solution

The function ff has an inverse, because ff is monotonic: its graph is a line with slope 3, which rises from left to right. To find the inverse, solve y=f(x)y = f(x) for xx:

y=3x+7y−7=3xx=y−73.\begin{align*} y &= 3x + 7 \\ y - 7 &= 3x \\ x &= \frac{y - 7}{3}. \end{align*}

Interchange xx and yy to write the inverse with input xx:

f−1(x)=x−73. f^{-1}(x) = \frac{x - 7}{3}.
Figure

In R, the plot shows ff, its inverse in red, and the line y=xy = x dashed:

f = makeFun(3*x + 7 ~ x)
f_inverse = makeFun((x - 7)/3 ~ x)
plotFun(f(x) ~ x, xlim = c(-10, 10))
plotFun(f_inverse(x) ~ x, add = TRUE, col = "red")
plotFun(x ~ x, add = TRUE, col = "gray", lty = 2)
f_inverse(f(2))

The last line prints [1] 2, because f(2)=13f(2) = 13 and the inverse takes 13 back to the input 2. On the figure, the point (−1,4)(-1, 4) on ff and the point (4,−1)(4, -1) on f−1f^{-1} mirror each other across the line y=xy = x, because f(−1)=4f(-1) = 4.

Example 15

For the function

g(x)=2x−35, g(x) = \sqrt[5]{2x - 3},

plot gg, determine whether gg has an inverse, and if so, find the inverse.

ShowHide solution

Define gg, with the fifth root written as the 15\frac{1}{5} power, and plot it:

g = makeFun((2*x - 3)^(1/5) ~ x)
plotFun(g(x) ~ x, xlim = c(-2, 4))

R’s plot shows only the right half of the curve, where 2x−3≥02x - 3 \geq 0. The left half is missing because R returns NaN for an odd root of a negative number. The missing half is drawn dashed in the figure.

Figure

Desmos draws odd roots of negative numbers correctly. Check an odd root in Desmos before taking a shape or a domain from an R plot.

The function gg has an inverse, because gg is monotonic: as xx increases, 2x−32x - 3 increases, and so does its fifth root, as the full curve in the figure shows. To find the inverse, solve y=g(x)y = g(x) for xx, starting by raising both sides to the fifth power to undo the fifth root:

y=2x−35y5=2x−3y5+3=2xx=y5+32.\begin{align*} y &= \sqrt[5]{2x - 3} \\ y^{5} &= 2x - 3 \\ y^{5} + 3 &= 2x \\ x &= \frac{y^{5} + 3}{2}. \end{align*}

Interchange xx and yy to write the inverse with input xx:

g−1(x)=x5+32. g^{-1}(x) = \frac{x^{5} + 3}{2}.

Example 16

For the function

r(z)=5z−37z+4, r(z) = \frac{5z - 3}{7z + 4},

determine whether rr has an inverse. If it does, find the inverse and evaluate r−1(0.5)r^{-1}(0.5).

ShowHide solution

A plot of rr settles the horizontal line test, solving y=r(z)y = r(z) for zz gives the inverse, and R evaluates the inverse at 0.5. Plot rr:

r = makeFun((5*z - 3)/(7*z + 4) ~ z)
plotFun(r(z) ~ z, xlim = c(-3, 3))

The plot has two branches, one on each side of z=−4/7z = -4/7, where the denominator is 0. The function rr has an inverse, because every horizontal line intersects the graph at most once. Solve y=r(z)y = r(z) for zz:

y=5z−37z+4y(7z+4)=5z−37yz+4y=5z−37yz−5z=−3−4yz(7y−5)=−(4y+3)z=−(4y+3)7y−5=4y+35−7y.\begin{align*} y &= \frac{5z - 3}{7z + 4} \\ y(7z + 4) &= 5z - 3 \\ 7yz + 4y &= 5z - 3 \\ 7yz - 5z &= -3 - 4y \\ z(7y - 5) &= -(4y + 3) \\ z &= \frac{-(4y + 3)}{7y - 5} = \frac{4y + 3}{5 - 7y}. \end{align*}

The last step divides by 7y−57y - 5, then multiplies the numerator and the denominator by −1-1. As in the textbook, a divisor that contains a variable is assumed to be nonzero. The algebra confirms the plot: each yy other than 57\frac{5}{7} gives exactly one zz. Interchange zz and yy to write the inverse with input zz:

r−1(z)=4z+35−7z. r^{-1}(z) = \frac{4z + 3}{5 - 7z}.

R defines the inverse and evaluates it at z=0.5z = 0.5:

r_inverse = makeFun((4*z + 3)/(5 - 7*z) ~ z)
r_inverse(0.5)

The last line prints [1] 3.333333, which gives r−1(0.5)≈3.333r^{-1}(0.5) \approx 3.333.

Example 17

For the function

p(x)=x2+1x+3, p(x) = \frac{\frac{x}{2} + 1}{x + 3},

find the inverse of pp and evaluate p−1(0.25)p^{-1}(0.25).

ShowHide solution

Plot pp for the horizontal line test, as in Example 16:

p = makeFun((x/2 + 1)/(x + 3) ~ x)
plotFun(p(x) ~ x, xlim = c(-8, 4))

The function pp has an inverse, because every horizontal line intersects the graph at most once. Multiply the numerator and the denominator by 2 to clear the inner fraction, then solve for xx:

y=x2+1x+3=x+22x+6y(2x+6)=x+22xy+6y=x+22xy−x=2−6yx(2y−1)=2−6yx=2−6y2y−1.\begin{align*} y &= \frac{\frac{x}{2} + 1}{x + 3} = \frac{x + 2}{2x + 6} \\ y(2x + 6) &= x + 2 \\ 2xy + 6y &= x + 2 \\ 2xy - x &= 2 - 6y \\ x(2y - 1) &= 2 - 6y \\ x &= \frac{2 - 6y}{2y - 1}. \end{align*}

The algebra confirms the plot: each yy other than 12\frac{1}{2} gives exactly one xx. Interchange xx and yy to write the inverse with input xx:

p−1(x)=2−6x2x−1. p^{-1}(x) = \frac{2 - 6x}{2x - 1}.

R defines the inverse and evaluates it at x=0.25x = 0.25:

p_inverse = makeFun((2 - 6*x)/(2*x - 1) ~ x)
p_inverse(0.25)

The last line prints [1] -1, which gives p−1(0.25)=−1p^{-1}(0.25) = -1. As a check, at x=−1x = -1 the numerator of pp is −12+1=0.5\frac{-1}{2} + 1 = 0.5, the denominator is −1+3=2-1 + 3 = 2, and p(−1)=0.5/2=0.25p(-1) = 0.5/2 = 0.25.

Lesson map