[Home](https://learningfolio.de5.net/) / [Math](https://learningfolio.de5.net/math/) / [Math glossary](https://learningfolio.de5.net/math/glossary/) / Domain and Range of a Function: Rules, Graphs, and Examples

[Math glossary](https://learningfolio.de5.net/math/glossary/)

# Domain and Range of a Function: Rules, Graphs, and Examples

Find the domain and range of a function from a rule, table, or graph. Check radicals, excluded values, endpoints, and piecewise examples.

Written by **Learningfolio Team**

We’re subject-matter experts in math, science, parent support, and education, with 100 years of combined experience. We believe in learning, experimenting, and growing, and we review one another’s work.

## On this page

* [TL;DR](https://learningfolio.de5.net/math/functions-domain-range-and-input-output/#tldr)
* [Key Points](https://learningfolio.de5.net/math/functions-domain-range-and-input-output/#key-points)
* [What are the domain, range, and codomain?](https://learningfolio.de5.net/math/functions-domain-range-and-input-output/#what-are-the-domain-range-and-codomain)
* [Can a relation have a domain and range without being a function?](https://learningfolio.de5.net/math/functions-domain-range-and-input-output/#can-a-relation-have-a-domain-and-range-without-being-a-function)
* [How do you find the domain of a formula?](https://learningfolio.de5.net/math/functions-domain-range-and-input-output/#how-do-you-find-the-domain-of-a-formula)
* [How do you find the range of a formula?](https://learningfolio.de5.net/math/functions-domain-range-and-input-output/#how-do-you-find-the-range-of-a-formula)
* [How do you read domain and range from a graph?](https://learningfolio.de5.net/math/functions-domain-range-and-input-output/#how-do-you-read-domain-and-range-from-a-graph)
* [Examples of Finding Domain and Range](https://learningfolio.de5.net/math/functions-domain-range-and-input-output/#examples-of-finding-domain-and-range)
* [What mistakes should you check for?](https://learningfolio.de5.net/math/functions-domain-range-and-input-output/#what-mistakes-should-you-check-for)
* [Try It Yourself](https://learningfolio.de5.net/math/functions-domain-range-and-input-output/#try-it-yourself)
* [Questions About Domain and Range](https://learningfolio.de5.net/math/functions-domain-range-and-input-output/#questions-about-domain-and-range)
* [Conclusion](https://learningfolio.de5.net/math/functions-domain-range-and-input-output/#conclusion)
* [Read More](https://learningfolio.de5.net/math/functions-domain-range-and-input-output/#read-more)
* [Research Behind This Article](https://learningfolio.de5.net/math/functions-domain-range-and-input-output/#research-behind-this-article)

## TL;DR

**The domain of a function contains its allowed inputs. The range contains the outputs it actually reaches.** Read both from a graph or find them from a rule by checking restrictions and possible outputs.

## Key Points

* Domain refers to inputs, range to outputs, and codomain to the stated set that can contain outputs.
* A zero denominator, a negative even-root argument, or a nonpositive logarithm argument restricts the real domain.
* A graph’s horizontal coverage gives the domain, while its vertical coverage gives the range.
* A missing input removes an output only when no other allowed input produces that same output.

## What are the domain, range, and codomain?

A **function** gives one output for every allowed input. The **domain** is its set of allowed inputs. The **range** is its set of actual outputs. If the function is written $f:A\to B$, the domain is $A$ and the **codomain** is $B$. Every output belongs to $B$, but the function may reach only part of that codomain. OpenStax’s precalculus lesson introduces domain and range through tables, rules, and graphs.

For $f(x)=x^2$ on the finite domain $\{-2,-1,0,1,2\}$, the outputs are $4,1,0,1,4$. List each output only once. The range is $\{0,1,4\}$. The same rule with domain of all real numbers would have range $[0,\infty)$. Changing the input set changes the possible outputs.

The range equals the codomain only when the function reaches every element of the codomain. The [types of functions lesson](https://learningfolio.de5.net/math/types-of-functions/) uses the term **onto** for that case.

## Can a relation have a domain and range without being a function?

Yes. A **relation** is a set of ordered pairs. Its domain contains the first coordinates that appear, and its range contains the second coordinates that appear. A function is a relation that assigns exactly one output to each input in its domain.

| Input | Output |
| --- | --- |
| $-3$ | $4$ |
| $-3$ | $7$ |
| $0$ | $7$ |
| $5$ | $4$ |

The domain of this relation is $\{-3,0,5\}$ and its range is $\{4,7\}$. It is not a function from these inputs because $-3$ is paired with both 4 and 7. Sharing the output 7 between different inputs is allowed in a function. It is the repeated **input with different outputs** that fails the rule. [OpenStax, Relations and Functions](https://openstax.org/books/intermediate-algebra-2e/pages/3-5-relations-and-functions)

On a graph, draw a vertical line at a permitted input. If it meets two or more plotted points, that input has more than one output. For instance, the relation $x=y^2$ passes through both $(4,2)$ and $(4,-2)$. Its domain as a set of first coordinates is $[0,\infty)$, and its range is all real numbers. It becomes a function of $x$ if you restrict $y$ to be nonnegative. Then its range narrows to $[0,\infty)$. The [parabola guide](https://learningfolio.de5.net/math/geometry/parabola/) explains why the sideways orientation matters.

## How do you find the domain of a formula?

Use a stated domain or contextual restriction first. If none is given, introductory real-variable problems usually ask for the largest real set on which the expression makes sense. OpenStax’s algebra and trigonometry chapter distinguishes this formula-based domain from constraints in an applied situation.

| If the formula contains… | Check this restriction |
| --- | --- |
| A polynomial $x^2+3x-1$ by itself | A polynomial accepts every real input. |
| A fraction | Denominator must be nonzero. |
| An even root | The quantity inside the root must be zero or positive. |
| An even root in a denominator | The quantity inside that root must be strictly positive. |
| An odd root such as a cube root | The root itself accepts positive, zero, and negative inputs. |
| A real logarithm | The argument must be strictly positive. |

Take the overlap of all restrictions. For $1/\sqrt{x-3}$, the root requires $x\ge3$, and the denominator rules out $x=3$. Thus the domain is $(3,\infty)$. The Las Positas College functions lesson combines restrictions, and OpenStax’s intermediate algebra chapter shows how to set up inequalities for even roots.

Context can narrow the domain further. If a function gives the fee for buying $x$ books, the formula might accept decimals. Possible purchase counts are nonnegative integers. That is the relevant domain for the purchase question.

## How do you find the range of a formula?

Find which $y$-values the function can actually reach on its domain. A graph, an inequality, or solving $y=f(x)$ can establish the answer. To use the equation method, keep a $y$-value only if the resulting equation has a solution in the original domain.

For $f(x)=(x-2)^2+3$, the square is at least 0. The minimum of 3 occurs at $x=2$. Every $y\ge3$ can be obtained by choosing $x=2+\sqrt{y-3}$. Those facts give the full range $[3,\infty)$ when the domain is all real numbers. If you restrict the domain, some of those inputs may disappear.

OpenStax’s calculus chapter describes shifts of toolkit functions. A vertical shift changes the location of its outputs. For a square-root curve, a shift up by two units moves the minimum from 0 to 2, while a horizontal shift moves the starting input.

| Function with its natural real domain | Domain | Range |
| --- | --- | --- |
| $b$, a constant | $(-\infty,\infty)$ | $\{b\}$ |
| $x^2$ | $(-\infty,\infty)$ | $[0,\infty)$ |
| $\sqrt{x}$ | $[0,\infty)$ | $[0,\infty)$ |
| $1/x$ | $(-\infty,0)\cup(0,\infty)$ | $(-\infty,0)\cup(0,\infty)$ |
| $e^x$ | $(-\infty,\infty)$ | $(0,\infty)$ |
| $\ln x$ | $(0,\infty)$ | $(-\infty,\infty)$ |
| $\sin x$ | $(-\infty,\infty)$ | $[-1,1]$ |

The [log rules lesson](https://learningfolio.de5.net/math/log-rules/) explains why the logarithm accepts only positive arguments over the real numbers.

## How do you read domain and range from a graph?

Imagine projecting every plotted point onto one axis. Project onto the $x$-axis for domain and onto the $y$-axis for range. OpenStax’s domain and range chapter shows how open endpoints, included endpoints, and gaps affect each projection.

![Two graph segments with a gap at x equals one and vertical values extending from negative one up to but excluding three](https://learningfolio.de5.net/assets/versioned/domain-range-graph-projections.509b45b0adf5.webp)


The graph misses $x=1$, yet its range includes some outputs from both pieces. Determine horizontal and vertical coverage separately.

Use square brackets at included endpoints and parentheses at excluded endpoints. Infinity is always written with a parenthesis. Use union, $\cup$, to combine intervals separated by gaps. For finitely many isolated points, braces show the individual values.

An open circle deserves a second look. Its $y$-value is excluded only when no point elsewhere on the graph has that same height. In the diagram, the open point at $(1,2)$ is missing, but $(2,2)$ on the other segment still provides the output 2. The [coordinate plane lesson](https://learningfolio.de5.net/math/coordinate-plane-and-ordered-pairs/) reviews how to read each coordinate.

## Examples of Finding Domain and Range

### Example 1

Find the domain and range of the ordered pairs $\{(-3,4),(-1,2),(2,4),(5,7)\}$.

1. Read the first component of each pair for the inputs.
2. The domain is $\{-3,-1,2,5\}$.
3. The outputs are 4, 2, 4, and 7. The range is $\{2,4,7\}$.

### Example 2

Find the domain and range of the two segments in the figure. The first is $y=x+1$ for $-2\le x<1$. The second is $y=4-x$ for $1<x\le3$.

1. The inputs form $[-2,1)\cup(1,3]$. Neither branch includes $x=1$.
2. The first branch gives outputs $[-1,2)$. The second gives outputs $[1,3)$.
3. Their output intervals overlap. The full range is $[-1,3)$. In particular, the input gap does not create an output gap.

### Example 3

Find the domain and range of $g(x)=\sqrt{2x-6}+1$.

1. Require $2x-6\ge0$, so the domain is $[3,\infty)$.
2. At $x=3$, the square root is zero and $g(3)=1$.
3. The square root covers every nonnegative value as $x$ grows. Adding one gives range $[1,\infty)$.

### Example 4

Find the domain and range of $f(x)=(x^2-4)/(x-2)$.

1. The original denominator excludes $x=2$. The domain is $(-\infty,2)\cup(2,\infty)$.
2. Canceling the common factor gives $f(x)=x+2$ for $x\ne2$.
3. The output 4 would require the missing input $x=2$. The range is $(-\infty,4)\cup(4,\infty)$.

### Example 5

Find the range of $g(x)=1/(1+x^2)$.

1. The domain is all real numbers, because $1+x^2\ge1$.
2. The output is always positive and at most 1. It reaches 1 at $x=0$.
3. For each $0<y\le1$, solving gives $x^2=1/y-1\ge0$. Therefore the range is $(0,1]$.

### Example 6

Find the domain and range of a piecewise rule that uses $x+1$ for $x<0$ and $x^2+2$ for $x\ge0$.

1. Every real number belongs to one of the two branches. The domain is $(-\infty,\infty)$.
2. On the first branch, outputs are less than 1. On the second, $x^2$ covers all nonnegative values, so outputs are at least 2.
3. The range is $(-\infty,1)\cup[2,\infty)$. In this case the branches leave a real gap in the range.

## What mistakes should you check for?

### Mistake 1: Restoring a missing input after canceling a factor

In Example 4 the canceled formula still agrees with the original only where $x\ne2$. Mark denominator restrictions before simplifying. The original rule decides which inputs are permitted.

### Mistake 2: Using parentheses for an included endpoint

The square-root rule in Example 3 reaches its minimum of 1. Writing $(1,\infty)$ leaves that value out. Check whether a specific allowed input gives the endpoint before choosing the bracket.

### Mistake 3: Listing possible outputs without checking the original domain

If $f(x)=x^2$ is restricted to $2\le x\le3$, the lowest value is 4. The familiar range $[0,\infty)$ belongs to the unrestricted version. Recompute the range using the interval given in the problem.

## Try It Yourself

1. Find the domain of $g(x)=\sqrt{7-x}$.
2. Find the range of $f(x)=(x+2)^2-5$ for all real $x$.
3. Find the domain and range of $f(x)=1/(x-4)$.

### Answers and Reasoning

1. Require $7-x\ge0$, so the domain is $(-\infty,7]$.
2. The minimum occurs at $x=-2$ and equals $-5$. The range is $[-5,\infty)$.
3. The domain is $(-\infty,4)\cup(4,\infty)$. The range is $(-\infty,0)\cup(0,\infty)$, because a reciprocal cannot be zero and $x=4+1/y$ produces every nonzero $y$.

## Questions About Domain and Range

### Can domain and range be the same set?

Yes. For $f(x)=x$ with all real inputs, every real number is also an output. For $f(x)=\sqrt{x}$, both sets equal $[0,\infty)$.

### Does repeating an output break the function rule?

No. Different inputs may produce the same output. The function rule requires exactly one output for each input.

### Is a function’s codomain always all real numbers?

The codomain depends on how the function is specified. A coin-flip coding function can have codomain $\{0,1\}$. A square function might be declared with codomain all real numbers or only the nonnegative reals.

## Conclusion

* Find the allowed inputs before looking for outputs.
* Solve restrictions using the original expression and any stated context.
* Determine whether each candidate output and endpoint is actually reached.

## Read More

* [How to recognize a one-to-one function on a graph](https://learningfolio.de5.net/math/geometry/horizontal-line/)
* [How square roots and perfect squares work](https://learningfolio.de5.net/math/square-roots-and-perfect-squares/)

## Research Behind This Article

1. OpenStax, *Precalculus 2e: Domain and Range*. [OpenStax](https://openstax.org/books/precalculus-2e/pages/1-2-domain-and-range)
2. OpenStax, *Algebra and Trigonometry 2e: Domain and Range*. [OpenStax](https://openstax.org/books/algebra-and-trigonometry-2e/pages/3-2-domain-and-range)
3. Las Positas College, *Essential Math Skills Toolkit: The Domain and Range of a Function*. [LibreTexts](https://math.libretexts.org/Courses/Las_Positas_College/Essential_Math_Skills_Toolkit/10%3A_An_Overview_of_Functions/10.04%3A_The_Domain_and_Range_of_a_Function)
4. OpenStax, *Calculus Volume 1: Basic Classes of Functions*. [OpenStax](https://openstax.org/books/calculus-volume-1/pages/1-2-basic-classes-of-functions)
5. OpenStax, *Intermediate Algebra: Use Radicals in Functions*. [OpenStax](https://openstax.org/books/intermediate-algebra/pages/8-7-use-radicals-in-functions)
6. OpenStax, *Intermediate Algebra 2e: Relations and Functions*. [OpenStax](https://openstax.org/books/intermediate-algebra-2e/pages/3-5-relations-and-functions)
