Functions

Domain and Range of a Function: How to Find Both

The domain of a function is the set of all inputs xx it accepts, and the range is the set of all outputs yy it actually produces. Find the domain by deleting every xx that breaks the function, and find the range by asking which yy values can be reached.

Domain={x:f(x) is defined},Range={f(x):x∈Domain}\text{Domain}=\{x : f(x)\text{ is defined}\},\quad \text{Range}=\{f(x) : x\in\text{Domain}\}

The domain nearly always comes from three quick rules. The range needs a little more thought, but a single idea (solve y=f(x)y=f(x) for xx and see when a solution exists) handles most cases, including ones where a graph is no help.

What are the domain and range of a function?

A function is a machine: the domain is everything you are allowed to feed in, and the range is everything that can come out. Both are sets of numbers, and both can be finite lists, intervals, or unions of intervals. Any relation has a domain and range, but a function adds the rule that each input produces exactly one output. In function notation, the domain lives inside the parentheses of f(x)f(x) and the range is the set of values f(x)f(x) takes.

For a set of ordered pairs, read the first coordinates for the domain and the second coordinates for the range, listing repeats once. The pairs {(1,4),(2,4),(3,7)}\{(1,4),(2,4),(3,7)\} have domain {1,2,3}\{1,2,3\} and range {4,7}\{4,7\}. Two inputs sharing an output is perfectly legal. Two outputs for one input is not.

Textbooks sometimes mention a third set, the codomain. It is the set of outputs the function is declared able to produce, while the range is what it truly hits. For f(x)=x2f(x)=x^2 declared on the real numbers, the codomain is all reals but the range is only [0,∞)[0,\infty). In algebra and precalculus, “range” means the outputs actually reached.

Quick check

State the domain and range of the set of pairs {(1,4),(2,4),(3,7)}\{(1,4),(2,4),(3,7)\}.

How do you find the domain of a function from its equation?

Start from the assumption that every real number is allowed, then remove anything that breaks the function. Only three things break real-valued functions at this level:

  1. A denominator equal to zero.
  2. A negative number under an even root (square root, fourth root, and so on).
  3. A zero or negative argument inside a logarithm (see the logarithm rules for why the argument must be positive).

The mental shortcut is to ask “what could go wrong?” rather than “what works?”. Polynomials, odd roots and exponentials have nothing that can go wrong, so their domain is every real number.

When several restrictions appear in one function, solve each one separately and keep only the xx values that satisfy all of them.

Worked example. Find the domain of f(x)=x+2x−3f(x)=\dfrac{\sqrt{x+2}}{x-3}.

The root requires a non-negative radicand:

x+2≥0⇒x≥−2x+2\ge 0 \quad\Rightarrow\quad x\ge -2

The denominator requires:

x−3≠0⇒x≠3x-3\ne 0 \quad\Rightarrow\quad x\ne 3

Take x≥−2x\ge -2 and remove the single point x=3x=3, which lies inside that ray. The domain is

[−2,3)∪(3,∞)[-2,3)\cup(3,\infty)

The point x=−2x=-2 is included: the numerator becomes 00, and 0−5=0\frac{0}{-5}=0 is a perfectly good output.

The trap that costs the most points is simplifying before finding the domain. Restrictions belong to the original expression, so they must be written down first. The hole section below shows exactly how this goes wrong.

How do you write domain and range in interval notation?

Interval notation lists values from smallest to largest. A square bracket means the endpoint is included, and a parenthesis means it is excluded. Since ∞\infty is not a number that can be reached, it always takes a parenthesis: [2,∞)[2,\infty) is correct and [2,∞][2,\infty] is not.

Turning "not equal" into intervals

The condition x≠4x\neq 4 means every number except 4, which splits the line into two pieces: (−∞,4)∪(4,∞)(-\infty,4)\cup(4,\infty). The symbol ∪\cup means "or", joining the pieces.

Set-builder notation says the same thing in a different style: {x∣x≥2}\{x\mid x\ge 2\} reads “all xx such that xx is at least 2.” Some teachers want inequalities, some want intervals, and some want set-builder, so check which one your course expects. All three describe the same set.

For a quick sanity check, sketch a number line. Shade what is allowed, and draw an open circle on every excluded point and a filled one on every included point. Then read the shading left to right, writing one interval for each unbroken stretch. Unions always run in increasing order, so (−∞,−2]∪[2,∞)(-\infty,-2]\cup[2,\infty) is right and the reverse order is not.

How do you find the range of a function algebraically?

Three step cards solving for x show the range of (2x+1)/(x-3) excludes y equals 2
Solve y = (2x+1)/(x-3) for x, then test the one forbidden y: it gives -6 = 1, so 2 is never an output.

The clean idea behind every range method is this: a number yy is in the range exactly when the equation y=f(x)y=f(x) has a solution xx in the domain. So solve for xx and see which yy values make that possible. This is also why the range of a function equals the domain of its inverse, and it works even when you cannot picture the graph.

Worked example. Find the range of g(x)=2x+1x−3g(x)=\dfrac{2x+1}{x-3}.

The domain is x≠3x\ne 3. Now set y=2x+1x−3y=\frac{2x+1}{x-3} and solve for xx:

y(x−3)=2x+1y(x-3)=2x+1

xy−3y=2x+1xy-3y=2x+1

xy−2x=3y+1xy-2x=3y+1

x(y−2)=3y+1x(y-2)=3y+1

x=3y+1y−2x=\frac{3y+1}{y-2}

A solution for xx exists for every yy except y=2y=2. Confirm that y=2y=2 truly fails: 2(x−3)=2x+12(x-3)=2x+1 simplifies to −6=1-6=1, which is false. The range is (−∞,2)∪(2,∞)(-\infty,2)\cup(2,\infty). It matches the horizontal asymptote y=2y=2, which is the value the graph approaches but never reaches. The same swap is the first step of finding the inverse of a rational function.

The other quick tools are thinking in layers and plugging in boundary values. For x−1+3\sqrt{x-1}+3, the root is at least 0, so the whole expression is at least 3. Test a value or two near the edge of the domain to confirm the output behaves as expected. The solve-for-xx method fails only when xx cannot be isolated, as with x+sin⁡xx+\sin x. In that case, graphing is the practical route.

Try this: Find the range of f(x)=4xx+1f(x)=\dfrac{4x}{x+1} by solving y=f(x)y=f(x) for xx. Then check your answer against the horizontal asymptote. (Answer: all real numbers except 44.)

Why does the range of a quadratic stop at the vertex?

Every quadratic can be written as a(x−h)2+ka(x-h)^2+k. A square is never negative, so the term a(x−h)2a(x-h)^2 has a smallest possible size of 00, reached at x=hx=h. That makes the output stop at kk, the vertex height. If a>0a>0 the parabola opens up and the range is [k,∞)[k,\infty). If a<0a<0 it opens down and the range is (−∞,k](-\infty,k].

Worked example. Find the range of h(x)=−2x2+8x−3h(x)=-2x^2+8x-3.

The vertex has xx-coordinate

x=−b2a=−82(−2)=2x=-\frac{b}{2a}=-\frac{8}{2(-2)}=2

Substitute to get the height:

h(2)=−2(4)+16−3=5h(2)=-2(4)+16-3=5

Since a=−2<0a=-2<0, the parabola opens downward and the range is (−∞,5](-\infty,5].

A second method confirms the answer. The equation −2x2+8x−3−y=0-2x^2+8x-3-y=0 has a real solution only when its discriminant is non-negative. Here b2−4ac=64+8(−3−y)=40−8yb^2-4ac=64+8(-3-y)=40-8y, and 40−8y≥040-8y\ge 0 gives y≤5y\le 5. The same match appears whichever route is used, which makes it a handy self-check, and it is the reason the quadratic formula is tied to range. Because a parabola is not one-to-one, any inverse needs a restricted domain; see the inverse of a quadratic function.

Quick check

Find the range of f(x)=x2+6x+1f(x)=x^2+6x+1.

How do you read domain and range from a graph?

Picture a light shining straight down onto the xx-axis: the shadow of the graph is the domain. Now shine it sideways onto the yy-axis: that shadow is the range. This catches things a quick glance misses, such as a graph that bends back on itself and covers a stretch of yy values more than once.

  • A closed dot means the endpoint is included, so use a bracket.
  • An open dot means it is excluded, so use a parenthesis.
  • An arrow means the graph continues forever, so use ∞\infty or −∞-\infty.
  • A gap in the shadow means a union of intervals.

The vertical line test ties in naturally: the domain is exactly the set of xx values where a vertical line meets the graph at all. For piecewise functions, combine the shadow of each piece, and watch for overlaps. Take f(x)=x+1f(x)=x+1 for x<0x<0 and f(x)=x2f(x)=x^2 for x≥0x\ge 0. The first piece gives outputs in (−∞,1)(-\infty,1) and the second gives [0,∞)[0,\infty). They overlap on [0,1)[0,1), and their union is every real number, so the range is (−∞,∞)(-\infty,\infty).

The most common graph error is reading the range off the highest and lowest visible points when arrows show the curve continues. The second is swapping the axes. Domain reads left to right, range reads bottom to top.

What are the domain and range of common parent functions?

Memorizing these few results turns many problems into one-step transformations. Each one follows from the rules above.

Function Domain Range
x2x^2 (−∞,∞)(-\infty,\infty) [0,∞)[0,\infty)
x\sqrt{x} [0,∞)[0,\infty) [0,∞)[0,\infty)
1x\dfrac{1}{x} x≠0x\neq 0 y≠0y\neq 0
exe^x (−∞,∞)(-\infty,\infty) (0,∞)(0,\infty)
ln⁡x\ln x (0,∞)(0,\infty) (−∞,∞)(-\infty,\infty)
sin⁡x\sin x (−∞,∞)(-\infty,\infty) [−1,1][-1,1]

These are the building blocks in the family of parent functions. When a graph is moved with transformations of functions, the domain shifts with horizontal moves and the range shifts with vertical moves. Take f(x)=x−4+1f(x)=\sqrt{x-4}+1. Shifting right 4 moves the domain to [4,∞)[4,\infty), and shifting up 1 moves the range to [1,∞)[1,\infty). A reflection or stretch changes which direction the range extends, but never the position of a horizontal shift.

Notice the pattern in the table: exe^x and ln⁡x\ln x have their domain and range swapped. That is not a coincidence, and the last section explains why.

How do holes and real-life limits change domain and range?

Consider f(x)=x2−1x−1f(x)=\dfrac{x^2-1}{x-1}. Factor the numerator to get (x−1)(x+1)x−1\frac{(x-1)(x+1)}{x-1}, which cancels to x+1x+1 for every x≠1x\ne 1. The graph is the line y=x+1y=x+1 with a hole at x=1x=1. The domain is therefore x≠1x\ne 1, even though the simplified line accepts every number. The hole also steals an output: the line would give y=2y=2 at x=1x=1, and no other input produces 2, so the range is y≠2y\ne 2.

Domain is decided before simplifying

Cancelling a factor hides a restriction but does not remove it. Write the excluded xx values from the original expression, then simplify.

In applied problems, the domain is whatever the situation permits. A ball launched with height h(t)=−16t2+48t+5h(t)=-16t^2+48t+5 feet only makes sense from launch at t=0t=0 until it lands. Setting h(t)=0h(t)=0 gives 16t2−48t−5=016t^2-48t-5=0, and the positive solution is t≈3.10t\approx 3.10 seconds. The domain is [0,3.10][0,3.10]. The vertex is at t=1.5t=1.5, where h(1.5)=−36+72+5=41h(1.5)=-36+72+5=41, so the range is [0,41][0,41] feet. The algebraic parabola would continue to negative times and negative heights, but physics does not.

Counting contexts change the type of set. The number of tickets sold must be a whole number, so the domain is {0,1,2,3,… }\{0,1,2,3,\dots\} and the graph is separate dots, not a line. State which kind of numbers are allowed before writing any interval.

How do domain and range change with inverses and composition?

An inverse undoes a function, so inputs and outputs trade places: the domain of ff becomes the range of f−1f^{-1}, and the range of ff becomes its domain. This explains the swapped pair in the table, since exe^x has range (0,∞)(0,\infty) and its inverse ln⁡x\ln x has domain (0,∞)(0,\infty). A function needs to be one-to-one to have an inverse, and restricting the domain is how to fix one that is not. Restrict f(x)=x2f(x)=x^2 to x≥0x\ge 0, and the inverse x\sqrt{x} appears with domain [0,∞)[0,\infty) and range [0,∞)[0,\infty).

For composition of functions, the domain of f(g(x))f(g(x)) has two requirements: xx must be in the domain of gg, and g(x)g(x) must land in the domain of ff. Forgetting the second requirement is a classic error. With f(x)=x2f(x)=x^2 and g(x)=xg(x)=\sqrt{x}, the composition simplifies to f(g(x))=xf(g(x))=x. Yet the domain is x≥0x\ge 0, not all reals, because gg rejects negative numbers before ff ever sees them.

A final habit worth building: after writing a domain or range, test one value inside it and one just outside. If the inside value gives a clean output and the outside one breaks or is unreachable, the answer is almost certainly right.

Quick check

Let f(x)=xf(x)=\sqrt{x} and g(x)=x2−4g(x)=x^2-4. Find the domain of f(g(x))f(g(x)).

Practice problems

0 of 5 solved

  1. Find the domain of f(x)=5x+4f(x)=\dfrac{5}{x+4}.

  2. Find the domain of f(x)=3x−6f(x)=\sqrt{3x-6}.

  3. Find the range of f(x)=x−1+3f(x)=\sqrt{x-1}+3.

  4. Find the range of f(x)=x2−4x+9f(x)=x^2-4x+9.

  5. Find the domain and range of f(x)=3x−1x+2f(x)=\dfrac{3x-1}{x+2}.

Common questions

What is the difference between domain and range?

The domain is the set of inputs a function accepts, usually the xx values. The range is the set of outputs it actually produces, usually the yy values. Domain is read left to right on a graph, range from bottom to top.

What is the domain and range of a constant function?

For f(x)=5f(x)=5 the domain is all real numbers, because any xx can be entered. The range is the single value {5}\{5\}, since every input gives the same output.

Is the range the same as the codomain?

Not exactly. The codomain is the set of outputs a function is declared to be able to produce, while the range is the set of outputs it really hits. For f(x)=x2f(x)=x^2 with codomain all real numbers, the range is only [0,∞)[0,\infty). Most algebra courses use the word range for the outputs actually reached.

How do you write domain and range in interval notation?

Write the values from smallest to largest, using brackets for included endpoints and parentheses for excluded ones. Infinity always gets a parenthesis. Use the union symbol ∪\cup to join separate pieces, such as (−∞,2)∪(2,∞)(-\infty,2)\cup(2,\infty) for x≠2x\neq 2.

Can domain and range ever be the same set?

Yes. The line f(x)=2x+1f(x)=2x+1 and the function f(x)=xf(x)=\sqrt{x} both have equal domain and range ((−∞,∞)(-\infty,\infty) and [0,∞)[0,\infty) respectively). The sets are unrelated in general, so matching is a coincidence of the function, not a rule.

Why does the range exclude the hole in a graph?

A hole means the function is undefined at that xx, so the yy value that would sit there is never produced, unless another xx produces it. For f(x)=x2−1x−1f(x)=\frac{x^2-1}{x-1} the hole at x=1x=1 removes y=2y=2 from the range.

Up next