This site is a work in progress. New lessons are added regularly. Contact us

Relations and Functions

Learning goals

  • Define a relation as a set of ordered pairs
  • Ask which variable is the input before calling it a function
  • Treat the domain as part of the function, not a leftover
  • Separate the natural domain from a declared one
  • Distinguish the range from the codomain it sits inside

A relation is the object underneath

Before a function there is a relation. A relation between two variables xx and yy is simply a set of ordered pairs (x,y)(x, y). An equation in xx and yy is one way to name such a set. The equation carves out of the whole plane exactly those points whose coordinates make the equation true, and that set of points is the relation. The equation y=2x+1y = 2x + 1 names a line, the equation x2+y2=1x^2 + y^2 = 1 names a circle, and the equation x=y2x = y^2 names a sideways parabola. In every case the primitive thing is the set of points; the equation is just its description.

A function is not a new kind of object. It is a relation with one extra property laid on top, and we lay it there for a definite reason. We want to be able to evaluate, to feed in a value and get a single answer back. A relation lets a point sit anywhere; a function insists that once you fix the input, the output is pinned down with no ambiguity. So a function is a relation in which each input is paired with exactly one output. Everything in this lesson comes from taking that sentence apart, and the first surprise is hiding in the word input.

The same curve, two different questions

Which variable is the input? Nothing in a set of points answers that; it is a choice you make. And the whole verdict “function or not” can flip depending on the choice. The cleanest example is the sideways parabola x=y2x = y^2.

Read it with xx as the input. Ask for the output at x=4x = 4: you need yy with y2=4y^2 = 4, and there are two, namely y=2y = 2 and y=2y = -2. One input, two outputs, so with xx as the input this relation is not a function. Now read the identical set of points with yy as the input instead. Ask for the output at any value of yy: the rule x=y2x = y^2 hands back the single number y2y^2, one output every time. With yy as the input the very same relation is a function. The points on the page never moved. Only the question changed.

The relation x = y squared read with x as input and with y as inputLeft: a vertical line meets the sideways parabola at two points, so reading x as the input fails. Right: a horizontal line meets the same parabola once, so reading y as the input succeeds.reading x as the inputx = 2not a function of xreading y as the inputy = 1a function of y
One relation, the parabola x = y squared, read two ways. On the left x is the input, and the vertical line x = 2 meets the curve twice, so one input has two outputs and it is not a function of x. On the right y is the input, and every horizontal line meets the curve exactly once, so it is a function of y. The set of points is identical; only the choice of input differs.

This is why the vertical line test is worth restating carefully. It is often remembered as a fact about the shape of a curve, but it is not. It is the test for whether reading xx as the input produces a function, and it is exactly the picture of “one output per input.”

Since nothing in the proof was special to xx, swap the roles of the two variables and the same argument runs word for word. Reading yy as the input is a function if and only if no horizontal line meets the relation more than once. The horizontal line test is not a second rule to memorize; it is the vertical line test asked about the other variable. Geometrically, swapping which variable is the input reflects the whole picture across the line y=xy = x, which turns every vertical line into a horizontal one. That reflection is exactly the move a later lesson will call forming the inverse of a function. A relation read with yy as the input is a function precisely when it passes the horizontal line test. So the question that opens this chapter, “can this rule be undone,” is underneath just the vertical line test asked about the second variable. We return to it in the inverse-functions lesson.

Two more relations are worth holding next to x=y2x = y^2. The unit circle x2+y2=1x^2 + y^2 = 1 fails both tests. At x=0x = 0 it has the two points (0,1)(0, 1) and (0,1)(0, -1), and at y=0y = 0 it has (1,0)(1, 0) and (1,0)(-1, 0), so the circle is a function of neither variable. The cubic y=x3y = x^3 passes both. Each xx gives the single output x3x^3, and each yy comes from the single input equal to its cube root, so the cubic is a function of both. “Function” really does live in the pairing of a curve with a choice of input, not in the curve alone.

Worked example 1 Is the circle x2+y2=25x^2 + y^2 = 25 a function?

The question is incomplete until we say a function of which variable, so test both readings.

Read xx as the input and solve for the output yy:

y2=25x2y=±25x2.y^2 = 25 - x^2 \quad\Longrightarrow\quad y = \pm\sqrt{25 - x^2}.

At x=3x = 3 this gives y=±16=±4y = \pm\sqrt{16} = \pm 4, the two points (3,4)(3, 4) and (3,4)(3, -4). One input, two outputs, so it is not a function of xx. A vertical line at x=3x = 3 would cut the circle twice.

Read yy as the input instead and solve for xx:

x=±25y2.x = \pm\sqrt{25 - y^2}.

At y=3y = 3 this gives x=±4x = \pm 4, the points (4,3)(4, 3) and (4,3)(-4, 3), so it is not a function of yy either. A circle is a function of neither variable, which fits the picture: no single output rule can follow a curve that doubles back on itself both horizontally and vertically.

Check your understanding

For the relation y2=x+1y^2 = x + 1, which statement is true?

Answer choices

The domain is part of the function, not a leftover

Here is the second idea, and it is easy to miss because in earlier courses it never came up. A function is not just a rule. Fully specified, it is three pieces of data at once: a domain, the set of allowed inputs, and a rule, telling you what to do to an input. The third piece is a codomain, a set you declare the outputs to fall inside. Change any one of the three and you have changed the function. The rule is the piece students notice, because it is the formula you can write down. The domain is just as much a part of the function, and forgetting it is the source of the trouble in this section.

In earlier courses “the domain” always meant one specific thing without anyone saying so: the largest set of inputs on which the formula returns a real number. That set has a name, the natural domain of the formula (also called the implied domain). It is a convention, the domain you assume when no other is stated. The natural domain is found the way you already know: throw out inputs that divide by zero or take an even root of a negative. For f(x)=1x3f(x) = \dfrac{1}{x - 3} the natural domain is every real number except 33, and for g(x)=xg(x) = \sqrt{x} it is every real number greater than or equal to 00.

A declared domain is different. It is a domain stated outright as part of the function, and it can be smaller than the natural domain. Writing “let f(x)=x2f(x) = x^2 for x0x \ge 0” declares the domain to be the nonnegative numbers, even though the formula x2x^2 would happily accept every real number. The formula does not force this restriction; the author of the function chooses it, and it travels with the function from then on. Intro algebra only ever computed the natural domain and called it “the” domain, which quietly assumed the domain is always read off the formula. It is not. The natural domain is a default, and a declared domain overrides it.

You have already felt the domain acting as real data. In the Solving Linear Equations lesson of Chapter 1, clearing denominators in xx2=2x2\dfrac{x}{x-2} = \dfrac{2}{x-2} produced the candidate x=2x = 2. That candidate had to be thrown out, because x=2x = 2 was never in the domain of the original equation. The exclusion did not come from the algebra after clearing; it came from the domain, which was fixed before any step was taken. That is the same lesson in a different costume: the domain is decided up front and constrains everything that follows.

Worked example 2 Find the natural domain of f(x)=x4x7f(x) = \dfrac{\sqrt{x - 4}}{x - 7}

No domain is declared, so find the natural domain: every real input for which the formula returns a real number. Two conditions must hold at once.

The square root requires a nonnegative inside, so

x40x4.x - 4 \ge 0 \quad\Longrightarrow\quad x \ge 4.

The denominator cannot be zero, so

x70x7.x - 7 \ne 0 \quad\Longrightarrow\quad x \ne 7.

Both must hold, so the natural domain is every real number with x4x \ge 4, except x=7x = 7. Notice that x=7x = 7 satisfies the root condition, so it is only the denominator that removes it, while every number below 44 is removed by the root. The domain is the overlap of the two requirements, not either one alone.

Check your understanding

What is the natural domain of h(x)=1x5h(x) = \dfrac{1}{\sqrt{x - 5}}?

Answer choices

Same formula, different domain, different function

Because the domain is genuine data, two functions can share a formula letter for letter and still be different functions. This is not a technicality; it is the hinge the last lesson of this chapter turns on.

Compare f(x)=x2f(x) = x^2 with domain all real numbers against g(x)=x2g(x) = x^2 with domain x0x \ge 0. Same rule, different domains. They behave differently in a way that matters. The function ff is not one-to-one: f(2)=4f(-2) = 4 and f(2)=4f(2) = 4, so two different inputs share an output, and the horizontal line y=4y = 4 meets its graph twice. The function gg is one-to-one: on the inputs x0x \ge 0, if g(a)=g(b)g(a) = g(b) then a2=b2a^2 = b^2, and since aa and bb are both nonnegative this forces a=ba = b. No horizontal line therefore meets the graph of gg more than once. One of these functions can be undone by a rule and the other cannot, purely because their domains differ.

The rule y = x squared on all reals versus on x greater than or equal to zeroLeft: the full parabola with a horizontal line cutting both arms. Right: the same parabola with the left arm dashed and removed, so the horizontal line meets the solid right arm only once.domain: all real xy = 2not one-to-onedomain: x greater or equal 0y = 2one-to-one
One formula, y = x squared, under two domains. On the left the domain is every real number, and the horizontal line y = 2 meets the graph twice, so the function is not one-to-one. On the right the domain is restricted to x greater than or equal to zero; the removed left half is dashed, the horizontal line now meets the graph once, and the function is one-to-one. Same rule, different domain, different function.

Worked example 3 Show that restricting the domain changes the function

Let f(x)=x2f(x) = x^2 on all real numbers and let g(x)=x2g(x) = x^2 on the domain x0x \ge 0. Decide whether each is one-to-one, and say why they are different functions.

For ff, look for two inputs with the same output. The inputs 3-3 and 33 both work:

f(3)=9=f(3).f(-3) = 9 = f(3).

Two inputs, one output, so ff is not one-to-one.

For gg, the input 3-3 is no longer allowed, because the domain is x0x \ge 0. Take any allowed inputs a,b0a, b \ge 0 with g(a)=g(b)g(a) = g(b):

a2=b2a2b2=0(ab)(a+b)=0.a^2 = b^2 \quad\Longrightarrow\quad a^2 - b^2 = 0 \quad\Longrightarrow\quad (a - b)(a + b) = 0.

Then a=ba = b or a=ba = -b, and since both are nonnegative, a=ba = -b can only happen when a=b=0a = b = 0. Either way a=ba = b, so gg is one-to-one. The two functions share every letter of their formula yet differ in a real property, one-to-oneness, so they are genuinely different functions. The domain, not the formula, made the difference, and restricting a domain to gain one-to-oneness is exactly how the inverse-functions lesson will earn its inverses honestly.

Check your understanding

Let f(x)=x2f(x) = x^2 with domain all real numbers and g(x)=x2g(x) = x^2 with domain x0x \ge 0. Which statement is correct?

Answer choices

Range and codomain

The output side has its own pair of words, and keeping them apart avoids a common muddle. The codomain is the set you declare the outputs to live in when you set the function up. The codomain is often just “the real numbers,” for lack of a reason to say anything smaller. The range is sharper: it is the set of outputs the function actually produces, every value f(x)f(x) hit by some input in the domain.

The range always sits inside the codomain. The two sets need not be equal, because declaring a set for the outputs to live in does not promise that every element of it gets used. Take f(x)=x2f(x) = x^2 on all real numbers with codomain the real numbers. Every output is a square, and a square is never negative, so the outputs actually produced are the numbers greater than or equal to 00. The range is that nonnegative set, a strict part of the real-number codomain: the negative numbers sit in the codomain but are never outputs. When a problem asks for “the range,” it is asking what the function really hits. Answering that takes a moment’s thought about the rule, not just a glance at where you declared the outputs.

Worked example 4 Find the range of f(x)=x2+1f(x) = x^2 + 1 on all real numbers

The range is the set of values the output can actually take, so start from what the rule can reach.

The term x2x^2 is a square, so it is never negative:

x20x2+11.x^2 \ge 0 \quad\Longrightarrow\quad x^2 + 1 \ge 1.

Every output is therefore at least 11. The value 11 itself is reached, at x=0x = 0, and by taking xx large the outputs climb without bound, so every number greater than or equal to 11 occurs. The range is all real numbers greater than or equal to 11. If this function were set up with codomain “all real numbers,” the range would be a strict part of it, since nothing below 11 is ever output.

A bound can belong to the range or sit just outside it, and the two cases look alike until you check. Take f(x)=1x2+1f(x) = \dfrac{1}{x^2 + 1} on all real numbers. The denominator is at least 11, so every output lies in 0<f(x)10 < f(x) \le 1. The upper bound 11 is attained: it is the genuine output at x=0x = 0, since f(0)=1f(0) = 1. The lower bound 00 is only approached: as xx grows the outputs shrink toward 00, but a ratio of positive numbers is never 00, so no input ever produces it. A value belongs to the range exactly when some input actually produces it. That is why the range is 0<y10 < y \le 1, closed at the attained end and open at the approached end. Deciding this is never automatic: for each candidate bound you check whether it is a real output or only a value the outputs crowd against.

The rule and domain as a set of ordered pairs

Both ideas of this lesson fold into one object if you describe a function the way a set theorist does. A function’s rule and domain together are a set of ordered pairs in which no two different pairs share the same first coordinate. Declaring a codomain on top of those pairs completes the function. Read that description once for each idea.

Read for the first idea, “first coordinate” is a choice. Which entry of each pair you call first is which variable you are feeding in, and the rule against a repeated first coordinate is precisely the vertical line test. Swap the two entries of every pair and you get a new set of pairs. Whether that new set is again a function is precisely the horizontal line test, and the swapped set is the seed of the inverse.

Read for the second idea, the domain is not computed from anything. It is simply the set of first coordinates that appear among the pairs, so it is built in from the start; include different pairs and you have a different function. The range, in the same breath, is the set of second coordinates that appear. So the pairs carry the rule, the domain, and the range at once. The one piece they do not carry is the codomain, the larger set you declare the outputs to live in. So you state the codomain separately, and the function is then complete. Two ideas, one object.

Common mistakes

Practice

Multiple Choice Questions (MCQ)

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

Free Response Questions (FRQ)

Longer questions in parts, to be worked out on paper. Progressive hints, the answer on its own so you can check yourself and try again, then the full worked solution, plus a rubric to mark your own work against.

Free response Work it out on paper 5 questions 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)

Ask a mathematician in 1740 what a function was, and the answer was a formula.

Leonhard Euler, a Swiss mathematician, wrote that down in 1748. A function, he said, is an analytic expression: one formula, built from a variable and some constants. On that view the formula was the function. Its domain is then whatever the formula allows, and nothing at all is left for you to choose.

That view did not last the century. Peter Gustav Lejeune Dirichlet, a German mathematician, replaced it in 1837. His version asks for no formula at all. To each value of the input, in a stated range of values, there corresponds one definite output. That is the whole of it. The pairing is the function, and the range of allowed inputs is announced rather than computed.

Dirichlet had already built the example that forced the change. Take the rule that returns one fixed number at every fraction, and a different fixed number everywhere else. It jumps between the two inside every interval, however short. No formula of Euler’s kind can capture that. Yet each input still gets exactly one output, so it is a function.

So the pairing comes first, and a formula is only one way to name it. That is why this lesson treats the domain as data, not as a leftover. It is also why one set of points can be a function of one variable but not the other.