1.2 Functions

Soda Vending Machine Japan Coast, photo by slackrhackr Soda Vending Machine Japan Coast, photo by slackrhackr

Introduction

Each button on a vending machine corresponds to a particular snack inside the machine. The item you get depends on the button you push. When you press the button for a soda the machine should give you that soda, if it is functioning properly.

In this section we'll see that mathematical functions connect things in a similar way.

The Definition of a Function

While no single definition can capture the full extent of the function concept, it is still important to start with one. The following definition was developed in the early 1900's and is stated in terms of sets.

DEFINITION

A function is any rule that matches each element from one set to exactly one element in another set. The set of inputs is called the domain of the function while the range is the set of all its output values.

Notice that this definition has three parts: (1) a set of inputs called the domain, (2) a set of outputs called the range and (3) the rule that links them together.

This is just like a vending machine where there is a set of buttons, a set of snacks, and the internal workings of the machine that link the two.

Perhaps a diagram would help illustrate this. If $x$ is in the domain and $y$ is in the range, then we can draw the function as a mapping diagram, like the one below.

Let's look at a specific example. Suppose three friends went to a deli and each ordered a sandwich, as in the diagram below.

Since each person is linked to just one sandwich, this is a function.

In general, anytime we can match each item from one set to just one item another set, then we have a function.

In the figure below you can change the arrangement of the arrows by moving the blue points. Experiment until you feel confident that you can recognize what is and what is not a function.

To use the interactive figure visit   https://www.geogebra.org/m/tm4yf6r7


QUICK CHECK

  1. Does this diagram represent a function? If so, also identify the domain and range.

    Answer
    YES, this is a function. Even though they all ordered the same thing, each person is only getting one sandwich, so it is a function. The domain is the set of people and the range is the set of sandwiches.

  2. Does this diagram represent a function? If so, also identify the domain and range.

    Answer
    NO, this is not a function because one person, Lisa, is linked to two sandwiches.

Function Notation

When there is a function relationship between $x$ and $y$ it is common practice to replace $y$ with $f(x)$ and say that $y=f(x)$. This is known as function notation.

When said aloud the notation $f(x)$ is read "$f$ of $x$". This notation reminds us that the output $f(x)$ is the result of putting the input $x$ inside of the function $f$.

In fact, it can be helpful to think of a function as a machine that changes an object $x$ into something new $f(x)$.

Suppose, for example, that pressing the button $\text{B4}$ on a vending machine gives you a bag of potato chips. Using function notation we might write $f(\text{B4})=\text{potato chips}$.

With function notation the choice of letters is completely arbitrary. For example, if a function always adds $3$ it makes no difference whether we refer to it as $f(x)=x+3$ or as $g(x)=x+3$ or as $w(t)=t+3$. It is what a function does that matters, not what it is called.

QUICK CHECK


Suppose that the function $C$ gives you the cost in dollars of a Volkswagen Beetle based on its age $t$ in years.

  1. Are the inputs dollars or years?

    Answer
    The inputs are years.

  2. Are the outputs dollars or years?

    Answer
    The outputs are dollars.

  3. Describe the difference in meaning between $C(50)=2000$ and $C(2000)=50$. Which one is more reasonable?

    Answer
    In this example the inputs are always years and the outputs are always dollars. The first equation means that the cost of a 50 year-old Beetle is 2000 dollars. The second would mean that the cost of a 2000 year-old Beetle is just 50 dollars (which is highly unlikely).

Evaluating & Solving

The process of finding the output for a particular input is called evaluating the function. Evaluating is sometimes confused with solving, which is understandable since they are like two sides of a coin. To evaluate we start with an input and find the output. Solving is the reverse process, we are given an output and must find the input.

Perhaps seeing this in the context of our vending machine analogy will help. Evaluating is like choosing a button on the vending machine (the input) and getting a snack (the output). Solving, on the other hand, is like knowing the snack you want and figuring out which button to press to get it.

Consider the function shown in the table below.

$x$ $y=f(x)$
A2 chocolate bar
A3 bubble gum
B4 potato chips
C1 root beer
C2 granola bar
D3 pretzels

To evaluate $f(A2)$ we simply find the value of $y$ when $x=A2$. From the table it appears that $f(A2)=\text{chocolate bar}$.

To solve $f(x)=\text{root beer}$, however, we scan the table in the opposite direction, looking for an $x$ that creates $\text{root beer}$ as an output. The solution is $x=C1$.

If a function is defined by an equation, such as $f(x)=2 x^2 - 6 x$, then we evaluate it by replacing every $x$ with the given input value. To find $f(10)$, we insert $10$ everywhere we see an $x$ and simplify, if possible.

[ \begin{align} f(10) &= 2(10)^2-6(10) \newline &= 200-60 \newline &= 140 \end{align} ]

We now know that $f(10)=140$.

A function can be evaluated even if we do not get a numerical result. Evaluating $f(x^{2})$ or $f(t+2)$ would mean substituting each $x$ with the expression $x^{2}$ or $t+2$.

QUICK CHECK

  1. Evaluate $f(2)$ if $f(x)=x-3$.

    Answer
    $f(2)=(2)-3=-1$

  2. If $g(x)=x^{2}+6x$, what is $g(😀)$?

    Answer
    $g(😀)=(😀)^2+6(😀)$

  3. For the function shown below, what is $f(5)$?

    Answer
    $f(5)=A$

  4. Using the same function diagram as above, what is the solution to $f(x)=D$?

    Answer
    Since $f(42)=D$, the solution is $x=42$.

Representations of Functions

Because functions are so widely used, there are many different ways to represent them. We have already encountered functions shown by mapping diagrams and equations. We'll also see functions written as tables, sets of points, sequences of operations, and graphs.

Each way to visualize a function highlights something special about the function, and switching from one to another can help us see different features and discover connections that might have been hidden otherwise.

Of primary importance is the connection between equations, tables and graphs.

Graphs of Functions

The graph of a function is the set of all points $(x, y)$ where each $y$ is found by evaluating the function's equation, since $y=f(x)$.

For instance, to graph the function $f(x)=x^{2}-3$ we randomly choose a handful of values for $x$ and evaluate the function for each one, creating a table of values.

$x$ $f(x)=x^{2}-3$
$-2$ $(-2)^2-3 = 1$
$-1$ $(-1)^2-3 = -2$
$0$ $(0)^2-3 = -3$
$1$ $(1)^2-3 = -2$
$2$ $(2)^2-3 = 1$
$3$ $(3)^2-3 = 6$

Then we convert those values into ordered $(x, y)$ pairs

[ \left\lbrace (-2, 1), (-1, -2), (0, -3), (1, -2), (2, 1), (3, 6) \right\rbrace ]

that can be plotted and connected with a smooth curve.

Even though calculators and apps can graph most functions, graphing functions by hand is still an important skill to practice.

QUICK CHECK

Sketch a graph of the function $f(x)=\frac{2}{3}x + 1$.
Answer

The Vertical Line Test

It is important to remember that not every relationship or rule defines a function. The key is that each input corresponds to just one output. This applies to graphs as well.

In order for a graph to be a function each $x$ can only correspond to one $y$. This means that no two points on the graph can share the same $x$-coordinate.

A quick way to test this is to imagine drawing vertical lines across it. If any line hits the graph more than once, it's not a function. For obvious reasons, this is called the vertical line test.

In each of the figures below there is a blue vertical line. Apply the vertical line test to each graph by moving the vertical line across the graph.

To use the interactive figure visit   https://www.geogebra.org/m/r9g6gyym

The vertical line test is very useful, but we must make sure we can see the entire graph.

QUICK CHECK

  1. Does the equation $y=2x-3$ define $y$ as a function of $x$?

    Answer
    Yes, each $x$ will create exactly one $y$ value. And if we graph $y=x-3$ it clearly passes the vertical line test.

  2. If $x+2y=4$, is $y$ a function of $x$?

    Answer
    Yes. Rewriting the equation as $y=-1/2 x +2$ we see that each $x$ has exactly one corresponding $y$ value and the graph passes the vertical line test.

  3. Use a graph to decide if the equation $x^2+y^2=3$ defines $y$ as a function of $x$.

    Answer
    No, the graph of $x^2+y^2=3$ is a circle, which would not pass the vertical line test.

    To graph $x^2+y^2=3$ on a calculator you would need to solve for $y$, which results in two equations. The top half of the circle is $y=\sqrt{3-x^2}$ and the bottom half is $y=-\sqrt{3-x^2}$. Looking at just one half might lead you to incorrectly assume that the equation is a function.

Evaluate Functions Using Graphs

When a function is defined by a graph we evaluate the function by reading off the $y$ coordinate that matches the given $x$ value.

In the figure below you can move the INPUT $x$ value which will change the OUTPUT $y$ value.

To use the interactive figure visit   https://www.geogebra.org/m/lQTU2l1r

To evaluate $f(5)$, for example, move the INPUT to $x=5$ and read off the corresponding OUTPUT on the $y$-axis. In this case, $f(5)=4$.

So to use a graph to find a function's output, just find where your input value meets the graph. The height of that point is your answer.

Solving reverses the process-we find $x$ when given a specific $y$. As an example, to solve $f(x)=4$ for $x$ you move the INPUT until the OUTPUT equals $4$. Then you record the INPUT. Here there are multiple values for $x$ that work: $x=1.7$, $x=4$, and $x=11.7$ all appear to give outputs of $4$, and would be valid solutions to $f(x)=4$.

Domain of a Function

Every time we identify a function we should also determine its domain. Recall that the domain is like the list of buttons on a vending machine: it's all the possible input choices you have.

When a function is defined by a table, a diagram or a set of points, then we can list each individual thing in the domain, like we did in the sandwich and vending machine examples earlier.

When a function is defined by an equation, the domain is every real number that produces a real number output.

For instance, if $f(x)=\sqrt{x} $ then the domain is any real number greater than or equal to zero, since square roots of negative values are not real numbers. This can be written as an interval $[0,\infty)$ or with set-builder notation $\lbrace x \vert x \ge 0 \rbrace $.

Similarly, the domain of $g(x)=\frac{1}{x}$ is every real number except zero, since division by zero is undefined. Writing this as an interval is a bit tricky since we have to use a union: $(-\infty,0) \bigcup (0,\infty)$. With set-builder notation we simply say which $x$ values cannot be used: $ \lbrace x \vert x \neq 0 \rbrace $.

As this example shows, it is often easiest to say what is not in the domain. Specifically, we must always eliminate from the domain any numbers that result in division by zero and even roots of negative numbers.

QUICK CHECK

  1. Explain why the domain of $f(x)=\frac{1}{x^2-9}$ is $ \lbrace x \vert x \neq \pm 3 \rbrace $.

    Answer
    The denominator cannot equal zero, so $x$ cannot be $3$ or $-3$. Using interval notation the domain is $(-\infty,-3) \bigcup (-3, 3) \bigcup (3,\infty)$. With set-builder notation we can write that a bit more compactly as { $ x \vert x\neq \pm 3 $ }.

  2. What is the domain of $g(x)=\sqrt{x-5}$?

    Answer
    To avoid taking the root of a negative number, $x-5>=0$, or $x \geq 5$. Using interval notation the domain is $[5, \infty)$. With set builder-notation it is ${x \vert x \geq 5}$.

  3. Find the domain of $h(x)=\sqrt[3]{x}$.

    Answer
    The cube root is not an even root, so the domain is all real numbers.

Looking Ahead

Until we gain familiarity with several different types of functions, it will be difficult to determine the range of a function by inspecting its equation. We will have more success if we work with its graph instead.

Graphs are also one of the best ways to determine the domain of a function. In fact, we can learn a lot about a function from looking at its graph. This will be the focus of the next section.

Creative Commons LicenseThis work copyrighted by Nolan Mitchell under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. Source files are available at https://github.com/duragauge/duragauge.github.io.

You can also download a PDF copy of the entire book here. The PDF was last updated on January 21, 2024, and may not reflect changes to the online content made after that date.