What Is a Function?

Learning goals

  • Require exactly one output for each allowed input
  • Read and evaluate function notation such as f(3)f(3) and f(a)f(a)
  • Apply the vertical line test to a graph
  • State the domain and range of a simple rule
  • Show one function as a rule, table, graph or words

A function is a rule with one output for each allowed input

A function assigns exactly one output to each allowed input. The input is what you put into the rule; the output is what it returns. Doubling is a function: input 55 gives 1010, and input −3-3 gives −6-6. Everyday rules work the same way: “assign to each person their exact height right now” is a function, since every person has one height at this moment, but “assign to each height the person who is that tall” is not, since many different people can share a height.

A function may send different inputs to the same output. Squaring sends both 33 and −3-3 to 99: each input still has just one result. A rule fails to be a function when one input has two or more different outputs.

Consider instead “pair a number with every real value whose square equals it.” Give it the input 99 and there are two numbers whose square is 99, namely 33 and −3-3:

32=9and(−3)2=9.3^2 = 9 \qquad \text{and} \qquad (-3)^2 = 9.

The input 99 has two outputs, so this pairing is not a function.

Why function notation?

Function notation records two things that a bare yy leaves out: which rule produced the output and which input was used.

You might track a car’s distance, speed and fuel at once. Calling every output yy makes those rules hard to tell apart. Function notation names the rule. Write y=f(x)y = f(x) to say ”ff is the name of the rule, and yy is the output it produces.” For the rule y=2x+1y = 2x + 1, this becomes

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

read aloud as ”ff of xx equals 2x+12x + 1.” Different letters name different rules, so ff, gg, and hh can sit on the same page as three distinct machines.

Function notation also keeps the input attached to its output. Compute the output of ff at x=3x = 3 and at x=5x = 5:

f(3)=2(3)+1=7,f(5)=2(5)+1=11.f(3) = 2(3) + 1 = 7, \qquad f(5) = 2(5) + 1 = 11.

Here f(3)f(3) and f(5)f(5) are outputs of the same rule at different inputs. The notation tells you which input produced 77 and which produced 1111.

Reading and evaluating f(x)f(x)

In f(x)f(x), ff names the function, the quantity in parentheses is the input, and the whole expression f(x)f(x) is the output. Names such as gg and hh work too. A descriptive name, such as AA for an area or CC for a cost, can help you remember what the rule does.

A function machine turning input 3 into output 7The top input 3 enters function f, which doubles the input and adds 1. The bottom output is 7.inputx = 3ff(x) = 2x + 1outputf(3) = 7
A function as a machine. You drop an input into the rule f, the machine applies it, and exactly one output comes out. Writing f(3) = 7 records both at once: the input 3 that went in, and the output 7 that came out.

The parentheses in f(x)f(x) do not mean multiplication. f(3)f(3) means “apply the rule ff to input 33,” not ”ff times 33.”

To evaluate a function at a particular input, substitute that number for xx everywhere it appears, then simplify. This uses the substitution you already know.

Worked example 1 Evaluating f(x)=3x−4f(x) = 3x - 4 at several inputs

The rule is “triple the input, then subtract 44.” Substitute each input for xx and simplify.

At x=5x = 5, replace every xx with 55:

f(5)=3(5)−4=15−4=11.f(5) = 3(5) - 4 = 15 - 4 = 11.

At x=0x = 0:

f(0)=3(0)−4=0−4=−4.f(0) = 3(0) - 4 = 0 - 4 = -4.

At x=−2x = -2, keep the parentheses so the sign is handled correctly:

f(−2)=3(−2)−4=−6−4=−10.f(-2) = 3(-2) - 4 = -6 - 4 = -10.

The same substitution works even when the input is a letter instead of a number. At x=ax = a, replace every xx with aa and simplify only what can be simplified:

f(a)=3a−4.f(a) = 3a - 4.

The value of aa is unspecified, so 3a−43a-4 cannot be evaluated to a single number yet. Notice also that f(0)=−4f(0)=-4: an input of zero need not produce an output of zero.

An entire expression can be the input. Replace every xx in the rule with the whole expression x+1x+1:

f(x+1)=3(x+1)−4=3x+3−4=3x−1.f(x+1)=3(x+1)-4=3x+3-4=3x-1.

This changes the input before applying the rule. Adding 11 to the output is different:

f(x)+1=(3x−4)+1=3x−3.f(x)+1=(3x-4)+1=3x-3.

For example, at x=2x=2 these give f(3)=5f(3)=5 and f(2)+1=2+1=3f(2)+1=2+1=3. In general, f(x+1)f(x+1) does not mean f(x)+1f(x)+1.

Check your understanding

If g(x)=4x−5g(x) = 4x - 5, what is g(2)g(2)?

Answer choices

Check your understanding

If g(x)=4x−5g(x) = 4x - 5, what is g(a)g(a)?

Answer choices

When a rule is not a function

An input-output pairing is called a relation. To decide whether a relation is a function, check whether any input has two different outputs. The same check works for pairs, tables and graphs.

As a set of ordered pairs, a relation is a function when no input value is paired with two different output values. The set {(1,2),(2,4),(3,6)}\{(1, 2), (2, 4), (3, 6)\} is a function, and so is {(1,5),(2,5),(3,5)}\{(1, 5), (2, 5), (3, 5)\}, where every input lands on the same output 55 (repeated outputs are allowed). But {(1,2),(1,5)}\{(1, 2), (1, 5)\} is not a function, because the input 11 is paired with both 22 and 55.

As a table, the same test reads down the input column: if any input appears twice with different outputs beside it, the relation is not a function. As a graph, there is a quick visual version of the test, worth knowing because you have already plotted points and lines in the coordinate plane.

Because a point’s input is its horizontal position, a vertical line fixes one input. The vertical line test asks whether any such line meets the graph more than once. One line with two crossings is enough to rule out a function; passing requires every vertical line to meet the graph at most once.

A closer look at why the vertical line test works#

The points (2,5)(2,5) and (2,−1)(2,-1) lie on the same vertical line, x=2x=2. If both belong to a relation’s graph, input 22 has two outputs, 55 and −1-1, so the relation is not a function. If there is just one point on the line x=2x=2, that input has one output. If there is none, 22 is not an allowed input.

Now fix any input aa. A point (a,b)(a,b) has input aa as its horizontal coordinate and output bb as its vertical coordinate. The heights of the points where the graph meets x=ax=a are exactly the outputs paired with input aa. No point with a different input lies on that line.

A function has exactly one output at each allowed input, so each vertical line meets its graph at most once. Conversely, if every vertical line meets a relation’s graph at most once, every input that appears has just one output. The graph therefore represents a function on those inputs. A vertical line may miss it entirely: that input is outside its domain.

Graph A and Graph B, each crossed by a dashed vertical lineGraph A is a rising straight line crossed by a dashed vertical line. Graph B is a sideways curve that opens to the right, crossed by a dashed vertical line.Graph AGraph B
Two graphs, Graph A and Graph B, each crossed by a dashed vertical line. Count where each dashed line meets its graph. Two meeting points show that a graph is not a function; to pass, every vertical line must meet the graph at most once.

Check your understanding

Look at Graph B above, on the right. Find where its dashed vertical line meets the curve. Based on the vertical line test, is Graph B a function, and why?

Answer choices

Worked example 2 Deciding whether a rule is a function

Test each relation against the one rule: does any input have two different outputs?

The set {(−2,4),(0,0),(2,4)}\{(-2, 4), (0, 0), (2, 4)\} is a function. The inputs are −2-2, 00, and 22, all different, and each has a single output. The output 44 appears twice, but that is allowed, since it comes from two different inputs.

The table below is not a function:

input xx11222255
output33669988

The input 22 shows up twice with two different outputs, 66 and 99, so the relation is not a function:

2↦6and2↦9.2 \mapsto 6 \quad \text{and} \quad 2 \mapsto 9.

Finally, the equation x=y2x = y^2 is not a function of xx. Choose the input x=4x = 4 and solve for the output: y2=4y^2 = 4 gives y=2y = 2 or y=−2y = -2, two outputs for one input. A vertical line at x=4x = 4 would cross its graph twice, so the graph fails the vertical line test as well.

Check your understanding

Which set of input-output pairs is NOT a function?

Answer choices

Domain and range

The domain of a function is the set of all inputs it is allowed to take. The range is the set of all outputs it actually produces. Input goes with domain, output goes with range, and you can describe each in plain words without any special symbols. In this lesson, “number” means a real number, the kind you already plot on a number line.

Unless a problem restricts the inputs, rules built only from adding, subtracting and multiplying accept all real numbers. For other rules, check which operations are defined. A denominator must not be zero, and a real square root needs a nonnegative number inside it. For example, g(x)=1xg(x) = \dfrac{1}{x} has domain “all numbers except 00,” because x=0x = 0 would divide by zero. The square root rule h(x)=xh(x) = \sqrt{x} has domain “all numbers greater than or equal to 00,” because a negative input has no real square root.

The range takes a little more thought, because it depends on what the rule can actually reach. For f(x)=x2f(x) = x^2, every output is a square, and a square is never negative, so no output can be below 00. Every nonnegative number is reached too: to land exactly on some target r≥0r \ge 0, use the input x=rx = \sqrt{r}, since (r)2=r(\sqrt{r})^2 = r. So the range is “all numbers greater than or equal to 00.”

Worked example 3 Finding a domain and a range

Find the domain of f(x)=1x−3f(x) = \dfrac{1}{x - 3}, and find the range of g(x)=x2+1g(x) = x^2 + 1.

For the domain of ff, the only danger is a zero denominator. Set the denominator equal to zero to find the forbidden input:

x−3=0⟹x=3.x - 3 = 0 \quad \Longrightarrow \quad x = 3.

Every other number is fine, so the domain of ff is “all numbers except 33.”

For the range of gg, start from what x2x^2 can do. Since x2≥0x^2 \ge 0 for every input, adding 11 pushes every output up by one:

g(x)=x2+1≥0+1=1.g(x) = x^2 + 1 \ge 0 + 1 = 1.

A table of sample values shows the pattern; the smallest entry is 11, at x=0x = 0:

xx−2-2−1-1001122
g(x)g(x)5522112255

No output can fall below 11. And every number r≥1r \ge 1 is actually reached: solve x2+1=rx^2 + 1 = r for xx, which gives x=r−1x = \sqrt{r - 1}, a real number precisely because r−1≥0r - 1 \ge 0. So the range of gg is “all numbers greater than or equal to 11.”

Check your understanding

What is the domain of h(x)=1x−4h(x) = \dfrac{1}{x - 4}?

Answer choices

Check your understanding

What is the range of k(x)=x2+4k(x) = x^2 + 4?

Answer choices

Four ways to show the same function

A function can be described by a rule, a table, a graph or words. For “double the input and add one”:

As a rule (an equation), it is compact and ready to evaluate:

f(x)=2x+1.f(x) = 2x + 1.

As a table, it lists sample inputs beside their outputs:

input xx−1-1001122
f(x)f(x)−1-1113355

As a graph, it is the collection of points (x,f(x))(x, f(x)) in the coordinate plane, which for this rule is the straight line you would get from y=2x+1y = 2x + 1. As words, it is the sentence “double the input, then add one.” All four describe the very same pairing of inputs with outputs. The rule and the words tell you how to produce any output; the table shows a handful of sample pairs, while the graph pictures every pair the function has, over whatever stretch of inputs is drawn.

Check your understanding

A rule sends 1↦31 \mapsto 3, 2↦52 \mapsto 5, and 3↦73 \mapsto 7. Which equation matches this rule?

Answer choices

Worked example 4 Turning words into a rule, then reading it back

A rule says “square the input, then subtract 22.” Write it in function notation, then find f(−3)f(-3).

Translate the sentence one operation at a time. “Square the input” is x2x^2, and “subtract 22” appends −2- 2:

f(x)=x2−2.f(x) = x^2 - 2.

Now evaluate at x=−3x = -3, substituting carefully:

f(−3)=(−3)2−2=9−2=7.f(-3) = (-3)^2 - 2 = 9 - 2 = 7.

Common mistakes

Practice

Multiple Choice Questions (MCQ)

Progressively harder sets of questions. Each opens on its own page.

Core practice

Practice problems at the level of the course, to be worked out on paper. Hints one at a time, then the answer or the full worked solution, with your progress kept in this browser.

Core practice Work it out on paper 10 problems Start →
More practice (optional)

Extra sets, as hard as the Challenge set. Each one opens on its own page.

More resources (optional)

Other explanations of this lesson, if you want a second take.

A bit of history (optional)

A function can be useful as a table, even when its reader has no formula to calculate the outputs.

In 1938, a public relief project in New York hired unemployed people to compute mathematical tables for scientists and engineers. At its largest, the Mathematical Tables Project employed about 450450 people. Most calculations were done by hand.

Gertrude Blanch, the project’s chief mathematician, helped make this possible. Most workers had little mathematical training, so her planning group broke calculations into simple steps on worksheets. Many workers only added; others subtracted. Each person could do their part without knowing the whole calculation. The project eventually produced 3737 volumes of tables.

Each table paired inputs with outputs that others could look up. That is the same idea as the function tables in this lesson: one output for each listed input.

Source: NIST’s history of the Mathematical Tables Project.

Your progress

See all your progress →