Functions

Relations and Functions: How to Tell Them Apart

A relation is any set of ordered pairs (x,y)(x, y), and a function is a relation in which every input xx has exactly one output yy. Equal outputs are allowed. One input with two different outputs is not.

(a,b)∈f and (a,c)∈f  ⟹  b=c(a,b)\in f \text{ and } (a,c)\in f \implies b=c

Every function is a relation, but most relations are not functions. The sections below show how to test that rule on pairs, tables, equations and graphs, how to read the domain and range, and what happens when a relation is reversed.

What are relations and functions, exactly?

Mapping diagram showing inputs 1, 2, 3 all mapping to 5 is a function, but reversed it is not
The pairs (1,5), (2,5), (3,5) form a function forward, but reversed the input 5 has three outputs.

A relation only records which inputs are linked to which outputs. Students and their heights, cities and their zip codes, and the pairs (1,2),(1,5),(3,2)(1, 2), (1, 5), (3, 2) are all relations. A function adds one rule, and the rule has a direction: reading from input to output, nothing branches.

(a,b)∈f  and  (a,c)∈f ⟹ b=c(a, b) \in f \ \text{ and } \ (a, c) \in f \ \Longrightarrow \ b = c

In words, if the same input shows up twice, the outputs must match. A vending machine is a good picture: pressing B4 always returns the same snack, though two different buttons may return the same snack.

Repeats are not the problem

A repeated output, such as (1,5)(1, 5) and (2,5)(2, 5), is fine. Only a repeated input with different outputs, such as (1,5)(1, 5) and (1,6)(1, 6), breaks the rule.

Direction matters more than most lessons admit. The relation {(1,5),(2,5),(3,5)}\{(1,5),(2,5),(3,5)\} is a function with yy depending on xx, yet reversed it becomes {(5,1),(5,2),(5,3)}\{(5,1),(5,2),(5,3)\}, where one input has three outputs. So the honest question is never “is this a function?” but “is yy a function of xx?”

How do you tell if a relation is a function?

Two sets of ordered pairs compared by counting pairs and inputs to test for a function
Set A has 4 pairs and 4 inputs so it is a function, while set B has 4 pairs but only 3 inputs.

Look only at the inputs, the first coordinates. A repeated input matters only when the outputs attached to it differ. In a table, read down the xx column. In a mapping diagram, every element on the left needs exactly one arrow leaving it. Several arrows may arrive at the same element on the right, but two arrows leaving one element on the left fail the test. An element with no arrow at all means the diagram is not a function on that whole set, although removing that element from the domain would repair it.

Example 1. Decide whether each relation is a function.

A={(1,4),(2,9),(3,4),(1,4),(5,0)}B={(1,4),(2,9),(3,4),(2,7)}A = \{(1,4),(2,9),(3,4),(1,4),(5,0)\} \qquad B = \{(1,4),(2,9),(3,4),(2,7)\}

For AA, the pair (1,4)(1,4) is written twice, but a set counts it once. The distinct pairs are (1,4),(2,9),(3,4),(5,0)(1,4),(2,9),(3,4),(5,0), with inputs 1,2,3,51,2,3,5, each used once. The output 44 repeats, which is allowed. So AA is a function.

For BB, the input 22 is paired with both 99 and 77. That single conflict is enough, so BB is not a function.

A fast mental check for long lists: count the distinct pairs and the distinct inputs. If there are more distinct pairs than distinct inputs, some input is carrying two outputs, and the relation fails. Here AA has 44 pairs and 44 inputs, while BB has 44 pairs and only 33 inputs.

Quick check

Is {(4,1),(5,3),(6,3),(4,2)}\{(4,1),(5,3),(6,3),(4,2)\} a function?

Does an equation define y as a function of x?

Solve for yy and watch for a plus-or-minus sign. A ±\pm that comes from an even root, or an absolute value such as ∣y∣=x|y| = x, signals two outputs for one input. An odd root never causes this, because every real number has exactly one real cube root.

Example 2. Does y2=x+4y^2 = x + 4 define yy as a function of xx? What about y3=x+4y^3 = x + 4?

Test one input in the first equation. At x=0x = 0 the equation reads y2=4y^2 = 4, so y=2y = 2 or y=−2y = -2. One input, two outputs, so it is not a function. Solving in general gives the same signal:

y=±x+4y = \pm\sqrt{x + 4}

For y3=x+4y^3 = x + 4, each xx gives one real cube root:

y=x+43y = \sqrt[3]{x + 4}

That is one output per input, so it is a function.

The two directions are not symmetric. One failing input proves an equation is not a function, but one passing input proves nothing, so a “yes” needs an argument for every xx, such as having solved for yy cleanly. Notice too that x=y2−4x = y^2 - 4 is not a function of xx, yet xx is a function of yy there, which is the direction point from earlier.

Try this: In y2=x+4y^2 = x + 4, count how many yy-values you get for x=−4x = -4, x=0x = 0 and x=5x = 5. One of them gives a single value. Why does that not rescue the equation?

How does the vertical line test work?

Every point on a vertical line shares the same xx-value. If such a line touches the graph twice, two different yy-values sit above one input, which is exactly the violation. That is the whole idea behind the vertical line test, and it is why the test is a restatement of the definition rather than a separate rule.

Two cases catch students. At a jump discontinuity, a vertical line through the jump hits the filled dot but misses the open circle, so the graph still passes. And a graph that looks like a function over the window you can see may curl back outside it, so the test applies to the entire graph.

A horizontal line test asks a different question: can an output be reached from two inputs? Failing it does not stop a graph from being a function. It only means the function is not one-to-one, which matters for inverses. The four mapping types sort out like this:

Mapping Example Function? One-to-one?
One-to-one y=2x+1y = 2x + 1 Yes Yes
Many-to-one y=x2y = x^2 Yes No
One-to-many x=y2x = y^2 No No
Many-to-many {(1,2),(1,3),(2,2),(2,3)}\{(1,2),(1,3),(2,2),(2,3)\} No No

How do you find the domain and range of a relation?

The domain is the set of inputs and the range is the set of outputs. For a list of pairs, write the first coordinates and the second coordinates, listing each value once. For an equation, the domain starts as all real numbers and domain and range work then removes whatever breaks the formula. Three things usually do:

  • a denominator that equals zero
  • an even root of a negative number
  • a logarithm of zero or a negative number

Finding the range means asking what the smallest and largest outputs are and whether everything between them occurs. For f(x)=x−3+2f(x) = \sqrt{x - 3} + 2, the root needs x−3≥0x - 3 \ge 0, and a root is never negative:

x≥3andx−3≥0  ⇒  f(x)≥2x \ge 3 \quad\text{and}\quad \sqrt{x-3} \ge 0 \;\Rightarrow\; f(x) \ge 2

So the domain is [3,∞)[3, \infty) and the range is [2,∞)[2, \infty). A shortcut confirms it: this is the parent root curve shifted right 33 and up 22 (see transformations of functions), so its starting corner is (3,2)(3, 2), and the graph runs right and up from there. At the corner, f(3)=2f(3) = 2, and at x=7x = 7 the value is 4+2=4\sqrt{4} + 2 = 4.

A vocabulary trap: the range is the set of outputs actually produced, while the codomain is the set the outputs are allowed to land in. For f(x)=x2f(x) = x^2 on the real numbers, the codomain is all reals but the range is only [0,∞)[0, \infty). Some courses use “range” for the codomain, so check which meaning your textbook intends.

Quick check

State the domain of g(x)=4x+5g(x)=\dfrac{4}{x+5}.

What does function notation f(x) tell you?

The symbol f(x)f(x) reads “f of x” and means the output of the function ff at input xx. It is not ff times xx. It replaces the variable yy and also tells you which function is being used, which matters once several functions appear in one problem. The full conventions are in function notation.

Example 3. Let f(x)=x2−3xf(x) = x^2 - 3x. Find f(−2)f(-2) and f(a+1)f(a + 1).

Replace every xx with the input, wrapped in parentheses. The parentheses keep the negative sign attached to the square.

f(−2)=(−2)2−3(−2)=4+6=10f(-2) = (-2)^2 - 3(-2) = 4 + 6 = 10

f(a+1)=(a+1)2−3(a+1)=a2+2a+1−3a−3=a2−a−2f(a+1) = (a+1)^2 - 3(a+1) = a^2 + 2a + 1 - 3a - 3 = a^2 - a - 2

Check the second answer with a=2a = 2. Directly, f(3)=9−9=0f(3) = 9 - 9 = 0, and the simplified form gives 4−2−2=04 - 2 - 2 = 0. They agree.

The skill of putting a whole expression into ff is exactly what composition of functions uses. Evaluation also depends on the domain: if 33 is outside the domain of ff, then f(3)f(3) does not exist, however neatly the formula could be typed.

Where do relations and functions appear in real life?

Anything where one quantity determines another is a function. Time determines the distance traveled at a constant speed, weight determines postage, and a student ID determines one student. Price tables that jump at thresholds are piecewise functions, and each input still gets exactly one price.

Relations that fail the test are just as common. A student and the clubs they belong to is a relation, since one student can join several. A person and their birthday is a function, but birthday to person is not, because two people can share a birthday.

Databases run on this rule

A primary key, such as an ID number, is an input that determines exactly one row. That is why a record is a function of its key, and why duplicate keys cause errors.

Programming languages borrow the word too. A pure function returns the same output every time it receives the same input, which is the definition above and the reason such code is easy to test.

What is an inverse relation, and is it a function?

To reverse a relation, swap the coordinates of every pair. For an equation, swap xx and yy and solve for yy. The reversed relation always exists, but it is a function only when the original is one-to-one, with no output reached from two inputs.

Take f(x)=2x+1f(x) = 2x + 1:

y=2x+1  →  x=2y+1  →  y=x−12y = 2x + 1 \;\to\; x = 2y + 1 \;\to\; y = \frac{x - 1}{2}

Check: f(3)=7f(3) = 7, and the reverse sends 77 to 7−12=3\frac{7-1}{2} = 3. Lines with a nonzero slope always reverse cleanly, as the page on the inverse of a linear function shows.

Quadratics are the standard failure. Swapping in y=x2y = x^2 gives x=y2x = y^2, a sideways parabola that fails the vertical line test. The repair is to restrict the domain to x≥0x \ge 0, which makes the reverse y=xy = \sqrt{x}. The inverse of a quadratic function works through this restriction in detail.

Quick check

Is the inverse of {(1,2),(2,5),(3,2)}\{(1,2),(2,5),(3,2)\} a function?

How can you spot a function at a glance?

Knowing the shape of common graphs saves you from running the test every time. Lines, parabolas that open up or down, absolute value graphs, cubics and exponentials are all functions. Circles, ellipses, sideways parabolas and graphs of ∣y∣=x|y| = x are not. The catalog of parent functions is worth memorizing for this reason.

One symmetry fact is a sharp shortcut. If a graph is symmetric about the xx-axis, then (x,y)(x, y) and (x,−y)(x, -y) both lie on it, so any point with y≠0y \ne 0 makes it fail. Only the xx-axis itself survives. This is the opposite of even and odd functions, where symmetry about the yy-axis or the origin is allowed and common.

When a problem looks unclear, run through this order:

  1. Name the input and the output, and the direction you are testing.
  2. Look for a repeated input with different outputs.
  3. For an equation, solve for yy and look for ±\pm.
  4. For a graph, sweep a vertical line across it.

Practice problems

0 of 5 solved

  1. Is the relation {(1,2),(3,4),(5,2),(7,6)}\{(1,2),(3,4),(5,2),(7,6)\} a function?

  2. State the domain and range of {(−1,4),(0,3),(2,4),(5,−2)}\{(-1,4),(0,3),(2,4),(5,-2)\}.

  3. If f(x)=2x2−5x+1f(x)=2x^2-5x+1, find f(−3)f(-3).

  4. Find the domain of h(x)=x+2x−4h(x)=\dfrac{\sqrt{x+2}}{x-4}.

  5. Find the range of g(x)=−2(x−1)2+7g(x)=-2(x-1)^2+7.

Common questions

What is the difference between a relation and a function?

A relation is any set of ordered pairs. A function is a relation in which each input is paired with exactly one output, so every function is a relation but most relations are not functions.

Can a function have the same output for different inputs?

Yes. The function y=x2y=x^2 sends both 22 and −2-2 to 44. What a function cannot do is send one input to two different outputs.

Is a circle a function?

No. For almost every xx inside the circle there are two points with that xx-value, one above and one below, so a vertical line crosses the circle twice. Only the top half or the bottom half alone is a function.

Is the vertical line x=3x=3 a function?

No. The single input 33 is paired with every real number as an output. A horizontal line such as y=3y=3 is a function, because each input has exactly one output.

How do you remember which is the domain and which is the range?

The domain is the set of inputs, the xx-values, and the range is the set of outputs, the yy-values. In an ordered pair (x,y)(x, y) the domain value comes first, just as domain comes before range.

What does it mean to say y is a function of x?

It means that choosing a value for xx determines exactly one value of yy. The statement depends on direction: y=x2y=x^2 makes yy a function of xx, but xx is not a function of yy there.

Up next