2.2: Domain and Range
- Last updated
- Save as PDF
- Page ID
- 197478

- Roy Simpson, Cosumnes River College
- OpenStax
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)
\( \newcommand{\dsum}{\displaystyle\sum\limits} \)
\( \newcommand{\dint}{\displaystyle\int\limits} \)
\( \newcommand{\dlim}{\displaystyle\lim\limits} \)
\( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)
( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)
\( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)
\( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)
\( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)
\( \newcommand{\Span}{\mathrm{span}}\)
\( \newcommand{\id}{\mathrm{id}}\)
\( \newcommand{\Span}{\mathrm{span}}\)
\( \newcommand{\kernel}{\mathrm{null}\,}\)
\( \newcommand{\range}{\mathrm{range}\,}\)
\( \newcommand{\RealPart}{\mathrm{Re}}\)
\( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)
\( \newcommand{\Argument}{\mathrm{Arg}}\)
\( \newcommand{\norm}[1]{\| #1 \|}\)
\( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)
\( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)
\( \newcommand{\vectorA}[1]{\vec{#1}} % arrow\)
\( \newcommand{\vectorAt}[1]{\vec{\text{#1}}} % arrow\)
\( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vectorC}[1]{\textbf{#1}} \)
\( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)
\( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)
\( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\(\newcommand{\longvect}{\overrightarrow}\)
\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)
\(\newcommand{\ket}[1]{\left| #1 \right>}\)
\(\newcommand{\bra}[1]{\left< #1 \right|}\)
\(\newcommand{\braket}[2]{\left< #1 \vphantom{#2} \right| \left. #2 \vphantom{#1} \right>}\)
\(\newcommand{\braopket}[3]{\left< #1 \vphantom{#2}\vphantom{#3} \right| #2 \vphantom{#1}\vphantom{#3} \left| #3 \vphantom{#1}\vphantom{#2} \right>}\)
\(\newcommand{\qmvec}[1]{\mathbf{\vec{#1}}}\)
\(\newcommand{\op}[1]{\hat{\mathbf{#1}}}\)
\(\newcommand{\expect}[1]{\langle #1 \rangle}\)
\(\newcommand{\dfn}[1]{\emph{\textbf{#1}}}\)
Section Preview
- Note to the Instructor (click to expand)
- The algebraic functions encountered in this section should not involve compositions of functions (e.g., the inverse square function composed with a square root composed with a quadratic). Focus on the domains of basic functions (involving shifts). Piecewise functions and the absolute value represented as a piecewise function are critical topics.
Core Prerequisites (i.e., "Understanding the Lesson"): The following prerequisite topics (which have not already been listed as prerequisites in previous sections of this text) are required to understand the core concepts in this lesson.
- (click to expand)
-
- Sets and Numbers
- Arithmetic
- Graphing Functions
Operational Prerequisites (i.e., "Completing the Homework"): The following prerequisite topics (which have not already been listed as prerequisites in previous sections of this text) are needed to complete the homework.
- (click to expand)
-
- Sets and Numbers
- Solving Equations
- Solving Inequalities
The following is a list of learning objectives for this section.
- Learning Objectives (click to expand)
-
- Find the domain of a function defined by an equation.
- Graph piecewise-defined functions.
If you're in the mood for a scary movie, you may want to check out one of the five top-grossing horror movies released from 2000 to 2013—I Am Legend, Hannibal, The Ring, The Grudge, and The Conjuring. Figure \(\PageIndex{1}\) shows the inflation-adjusted amount, in millions of dollars, that each of those movies grossed, as well as the share of the movie market that went to horror movies in each year. Notice that we can use the data to create a function of the amount each movie earned or the market share of horror movies by year. In creating various functions using the data, we can identify different independent and dependent variables, and we can analyze the data and the functions to determine the domain and range. In this section, we will investigate methods for determining the domain and range of functions such as these.
Finding the Domain of a Function Defined by an Equation
In this section, we will practice determining domains and ranges for specific functions. Keep in mind that, in determining domains and ranges, we need to consider what is physically possible or meaningful in real-world examples, such as market share and year in the horror movie example above. We also need to consider what is mathematically permitted. For example, we cannot include any input value that leads us to take an even root of a negative number if the domain and range consist of real numbers. Or in a function expressed as a formula, we cannot include any input value in the domain that would lead us to divide by 0.
We can visualize the domain as a "holding area" that contains "raw materials" for a "function machine" and the range as another "holding area" for the machine's products (see Figure \(\PageIndex{2}\)).
We can write the domain and range in interval notation, which uses values within brackets to describe a set of numbers. In interval notation, we use a square bracket, \([\), when the set includes the endpoint and a parenthesis, \((\), to indicate that the endpoint is either not included or the interval is unbounded. For example, if a person has $100 to spend, he or she would need to express the interval that is more than 0 and less than or equal to 100 and write \((0,100]\). We review interval notation in greater detail below.
Let's turn our attention to finding the domain of a function whose equation is provided. Oftentimes, finding the domain of such functions involves checking for three situations. First, if the formula has no denominator and no even root, consider whether the domain could be all real numbers. (Odd roots, such as cube roots, cause no restrictions.) Second, if there is a denominator in the function's equation, exclude values in the domain that force the denominator to be zero. Third, if there is an even root, consider excluding values that would make the radicand negative.
Before we begin, let us review the conventions of interval notation:
- The left endpoint (the smaller value) is written first.
- The right endpoint (the larger value) is written second, following a comma.
- Parentheses, \((\) or \()\), are used to signify that an endpoint is not included, called exclusive.
- Brackets, \([\) or \(]\), are used to indicate that an endpoint is included, called inclusive.
- The symbols \(-\infty\) and \(\infty\) are not real numbers, so they are never included in a set; they are always written with a parenthesis.
Figure \(\PageIndex{3}\) provides a summary of interval notation.
Example \(\PageIndex{1}\): Finding the Domain of a Function as a Set of Ordered Pairs
Find the domain of the following function: \(\{(2,10),(3,10),(4,20),(5,30),(6,40)\}\).
- Solution
-
First identify the input values. The input value is the first coordinate in an ordered pair. There are no restrictions, as the ordered pairs are simply listed. The domain is the set of the first coordinates of the ordered pairs: \(\{2,3,4,5,6\}\).
Checkpoint \(\PageIndex{1}\)
Find the domain of the following function: \(\{(-4,1),(-2,1),(0,3),(1,-2),(3,5)\}\).
- Answer
-
\(\{-4,-2,0,1,3\}\)
Example \(\PageIndex{2}\): Finding the Domain of a Function
Find the domain of the function \(f(x) = x^2 - 1\).
- Solution
-
The input value, shown by the variable \(x\) in the equation, is squared and then the result is lowered by one. Any real number may be squared and then be lowered by one, so there are no restrictions on the domain of this function. The domain is the set of real numbers. In interval form, the domain of \(f\) is \((-\infty,\infty)\).
Checkpoint \(\PageIndex{2}\)
Find the domain of the function \(f(x) = 3 - 2x^2\).
- Answer
-
\((-\infty,\infty)\)
Example \(\PageIndex{3}\): Finding the Domain of a Function Involving a Denominator
Find the domain of the function\[f(x) = \dfrac{x + 1}{2 - x}.\nonumber\]
- Solution
-
When there is a denominator, we want to include only values of the input that do not force the denominator to be zero. So, we will set the denominator equal to 0 and solve for \(x\).\[\begin{array}{rrclcl}
& 2 - x & = & 0 & & \\[6pt]
\implies & 2 & = & x & \quad & \left( \text{adding }x\text{ to both sides} \right) \\[6pt]
\end{array}\nonumber\]Now, we will exclude 2 from the domain. The domain consists of all real numbers \(x\) with \(x < 2\) or \(x > 2\). We can use a symbol known as the union, \(\cup\), to combine the two sets. In interval notation, we write the solution: \((-\infty,2) \cup(2,\infty)\).Figure \(\PageIndex{4}\) Thus, in interval form, the domain of \(f\) is \((-\infty,2) \cup(2,\infty)\).
Checkpoint \(\PageIndex{3}\)
Find the domain of the function\[f(x) = \dfrac{2x - 3}{x + 4}.\nonumber\]
- Answer
-
\((-\infty,-4) \cup (-4,\infty)\)
Example \(\PageIndex{4}\): Finding the Domain of a Function with an Even Root
Find the domain of the function\[f(x) = \sqrt{7 - x} .\nonumber\]
- Solution
-
When there is an even root in the formula, we exclude any real numbers that result in a negative number in the radicand. To do this, we set the radicand greater than or equal to zero and solve for \(x\).\[\begin{array}{rrclcl}
& 7 - x & \geq & 0 & \quad & \left( \text{even-indexed radicals must have nonnegative arguments} \right) \\[6pt]
\implies & 7 & \geq & x & \quad & \left( \text{adding }x\text{ to both sides} \right) \\[6pt]
\end{array}\nonumber\]Therefore, \(x\) must be less than or equal to \(7\). Hence, we need to exclude any number greater than 7 from the domain. The domain is all real numbers less than or equal to \(7\), or \((-\infty,7]\).
Checkpoint \(\PageIndex{4}\)
Find the domain of the function\[f(x) = \sqrt{5 + 2 x}.\nonumber\]
- Answer
-
\(\left[-\dfrac{5}{2},\infty\right)\)
Preview of Future Material
Functions of the types found in Examples \(\PageIndex{2}\) through \(\PageIndex{4}\) will be explored in more detail later in the textbook. For now, any domain questions involving these functions will be fairly straightforward; however, later we will see them "composed" with other functions.
Q&A
Can there be functions in which the domain and range do not intersect at all?
Yes. For example, the function\[f(x) = -\dfrac{1}{\sqrt{x}}\nonumber\]has the set of all positive real numbers as its domain but the set of all negative real numbers as its range. As a more extreme example, a function's inputs and outputs can be completely different categories (for example, names of weekdays as inputs and numbers as outputs, as on an attendance chart); in such cases the domain and range have no elements in common.
Using Notations to Specify Domain and Range
In the previous examples, we used inequalities and lists to describe the domain of functions. We can also use inequalities, or other statements that might define sets of values or data, to describe the behavior of the variable in set-builder notation.
Definition: Set-Builder Notation
Set-builder notation is a notation for specifying a set by a property that characterizes its members.
Notation: Set-Builder Notation
Set-builder notation commonly uses the following notation:\[\{ x \mid x \text{ satisfies some condition} \}. \nonumber\]The braces, \(\{ \, \}\), are read literally as "the set of." The vertical bar is read as, "such that." Hence, set-builder notation is read as "the set of \(x\) such that \(x\) satisfies some given condition."
For example, \(\{x \mid 10 \leq x < 30\}\) describes the behavior of \(x\) in set-builder notation. So we would read \(\{x \mid 10 \leq x < 30\}\) as "the set of \(x\)-values such that 10 is less than or equal to \(x\), and \(x\) is less than 30."
The following figure compares inequality notation, set-builder notation, and interval notation.
To combine two intervals using inequality notation or set-builder notation, we use the word "or." As we saw in earlier examples, we use the union symbol, \(\cup\), to combine two unconnected intervals. For example, the union of the sets \(\{2,3,5\}\) and \(\{4,6\}\) is the set \(\{2,3,4,5,6\}\). It is the set of all elements that belong to one or the other (or both) of the original two sets. For sets with a finite number of elements like these, the elements do not have to be listed in ascending order of numerical value. If the original two sets have some elements in common, those elements should be listed only once in the union set. For sets of real numbers on intervals, another example of a union is\[\{x \mid \, | x | \geq 3\} = (-\infty,-3] \cup [3,\infty).\nonumber\]
Set-Builder Notation and Interval Notation
Set-builder notation is a method of specifying a set of elements that satisfy a certain condition. It takes the form \(\{x \mid \text{statement about } x\}\) which is read as, "the set of all \(x\) such that the statement about \(x\) is true." For example,\[\{x \mid 4 < x \leq 12\} .\nonumber\]Interval notation is a way of describing sets that include all real numbers between a lower limit that may or may not be included and an upper limit that may or may not be included. If the set is unbounded, \(-\infty\) or \(\infty\) takes the place of a limit, always with a parenthesis. The endpoint values are listed between brackets or parentheses. A square bracket indicates inclusion in the set, and a parenthesis indicates exclusion from the set. For example,\[(4,12] .\nonumber\]
Example \(\PageIndex{5}\): Describing Sets on the Real-Number Line
Describe the intervals of values shown in the following figure using inequality notation, set-builder notation, and interval notation.
- Solution
-
To describe the values, \(x\), included in the intervals shown, we would say, "\(x\) is a real number greater than or equal to 1 and less than or equal to 3, or a real number greater than 5."
Inequality \(1 \leq x \leq 3 \text{ or } x > 5\) Set-builder notation \(\{x \mid 1 \leq x \leq 3 \text{ or } x > 5\}\) Interval notation \([1,3] \cup(5,\infty)\)
Remember that, when writing or reading interval notation, using a square bracket means the boundary is included in the set. Using a parenthesis means the boundary is not included in the set.
Checkpoint \(\PageIndex{5}\)
Use the following figure to specify the graphed set in
- words
- set-builder notation
- interval notation
- Answer
-
- All real numbers less than or equal to \(-2\), or greater than or equal to \(-1\) and less than \(3\)
- \(\{x \mid x \leq -2 \text{ or } -1 \leq x < 3\}\)
- \((-\infty,-2] \cup [-1,3)\)
Finding Domain and Range from Graphs
Another way to identify the domain and range of functions is by using graphs. Because the domain refers to the set of possible input values, the domain of a function is the set of all \(x\)-coordinates of points on its graph (the graph's horizontal extent). The range is the set of possible output values, which is the set of all \(y\)-coordinates of points on the graph (the graph's vertical extent). Keep in mind that if the graph continues beyond the portion of the graph we can see, the domain and range may be greater than the visible values.
We can observe that the graph in the figure above extends horizontally from \(-5\) to the right without bound, so the domain is \([-5,\infty)\). The vertical extent of the graph is all range values \(5\) and below, so the range is \((-\infty,5]\). Note that the domain and range are always written from smaller to larger values, or from left to right for domain, and from the bottom of the graph to the top of the graph for range.
Example \(\PageIndex{6}\): Finding Domain and Range from a Graph
Find the domain and range of the function \(f\) whose graph is shown below.
- Solution
-
We can observe that the horizontal extent of the graph is \(-3\) (exclusive) to 1 (inclusive), so the domain of \(f\) is \((-3,1]\).
The vertical extent of the graph is \(-4\) (inclusive) to 0 (inclusive), so the range is \([-4,0]\). Notice that even though the point \((-3,0)\) is not on the graph (open circle), the output 0 is still in the range because \(f(0) = 0\). See the figure below.
Figure \(\PageIndex{10}\)
Checkpoint \(\PageIndex{6}\)
Find the domain and range of the function \(g\) whose graph is shown below.

- Answer
-
Domain: \([-1,3)\); range: \([-1,3]\)
Example \(\PageIndex{7}\): Finding Domain and Range from a Graph of Oil Production
Find the domain and range of the function \(f\) whose graph is shown below.
- Solution
-
The input quantity along the horizontal axis is the year, which we represent with the variable \(t\) for time. The output quantity is "thousands of barrels of oil per day," which we represent with the variable \(b\) for barrels. The graph may continue to the left and right beyond what is viewed, but based on the portion of the graph that is visible, we can determine the domain as \(1973 \leq t \leq 2008\) and the range as approximately \(180 \leq b \leq 2010\).
In interval notation, the domain is \([1973,2008]\), and the range is about \([180,2010]\). For the domain and the range, we approximate the smallest and largest values since they do not fall exactly on the grid lines.
Checkpoint \(\PageIndex{7}\)
Identify the domain and range of the graph in the figure below using interval notation.
- Answer
-
Domain: \([1950,2000]\); range: approximately \([47,89]\), in millions of people (the endpoints are read from the graph)
Q&A
Can a function's domain and range be the same?
Yes. For example, the domain and range of the cube root function are both the set of all real numbers.
Finding Domains and Ranges of the Toolkit Functions
We will now return to our set of toolkit functions to determine the domain and range of each.
To show that a number \(y\) is in the range of \(f\), we need an input \(x\) in the domain with \(f(x) = y\). Solving the equation \(f(x) = y\) for \(x\) is often the easiest way to find one.
Example \(\PageIndex{8}\): Finding the Domain and Range Using Toolkit Functions
Find the domain and range of \(f(x) = 2x^3 - 1\).
- Solution
-
There are no restrictions on the domain, since any real number can be cubed, doubled, and then decreased by 1. Therefore, the domain is \((-\infty,\infty)\). To find the range, we solve \(2x^3 - 1 = y\) for \(x\), which gives \(x = \sqrt[3]{\dfrac{y+1}{2}}\). The cube root of any real number is a real number, so every real number \(y\) is an output of \(f\). The range is also \((-\infty,\infty)\).
Checkpoint \(\PageIndex{8}\)
Find the domain and range of \(f(x) = 4 - x^3\).
- Answer
-
Domain: \((-\infty,\infty)\); range: \((-\infty,\infty)\)
Example \(\PageIndex{9}\): Finding the Domain and Range
Find the domain and range of \(f(x) = \frac{2}{x + 1}\).
- Solution
-
We cannot evaluate the function at \(-1\) because division by zero is undefined. The domain is \((-\infty,-1) \cup(-1,\infty)\). A fraction with numerator 2 can never equal 0, so 0 is not in the range. Every other real number is an output. To see this, let \(y \neq 0\) and solve \(\dfrac{2}{x+1} = y\) for \(x\).\[\begin{array}{rrclcl}
& \dfrac{2}{x+1} & = & y & & \\[6pt]
\implies & 2 & = & y(x+1) & \quad & \left( \text{multiplying both sides by }x+1 \right) \\[6pt]
\implies & \dfrac{2}{y} & = & x+1 & \quad & \left( \text{dividing both sides by }y \neq 0 \right) \\[6pt]
\implies & \dfrac{2}{y} - 1 & = & x & \quad & \left( \text{subtracting 1 from both sides} \right) \\[6pt]
\end{array}\nonumber\]Because \(\dfrac{2}{y} \neq 0\), this value of \(x\) is not \(-1\), so it is in the domain. Thus every \(y \neq 0\) is an output of \(f\), and the range is \((-\infty,0) \cup (0,\infty)\).
Checkpoint \(\PageIndex{9}\)
Find the domain and range of \(f(x) = -\dfrac{3}{x - 2}\).
- Answer
-
Domain: \((-\infty,2)\cup(2,\infty)\); range: \((-\infty,0)\cup(0,\infty)\)
Example \(\PageIndex{10}\): Finding the Domain and Range
Find the domain and range of \(f(x) = 2 \sqrt{x + 4}\).
- Solution
-
We cannot take the square root of a negative number, so the value inside the radical must be nonnegative.\[x + 4 \geq 0 \text{ when } x \geq -4.\nonumber\]The domain of \(f\) is \([-4,\infty)\).
We then find the range. A square root is never negative, so \(f(x) = 2\sqrt{x+4} \geq 0\) for every \(x\) in the domain. To see that every \(y \geq 0\) is an output, let \(y \geq 0\) and solve \(2\sqrt{x+4} = y\) for \(x\).\[\begin{array}{rrclcl}
& 2\sqrt{x+4} & = & y & & \\[6pt]
\implies & \sqrt{x+4} & = & \dfrac{y}{2} & \quad & \left( \text{dividing both sides by 2} \right) \\[6pt]
\implies & x+4 & = & \dfrac{y^2}{4} & \quad & \left( \text{squaring both sides} \right) \\[6pt]
\implies & x & = & \dfrac{y^2}{4} - 4 & \quad & \left( \text{subtracting 4 from both sides} \right) \\[6pt]
\end{array}\nonumber\]Because \(\dfrac{y^2}{4} \geq 0\), this value of \(x\) is at least \(-4\), so it is in the domain. Thus every \(y \geq 0\) is an output of \(f\), and the range of \(f\) is \([0,\infty)\). - Analysis
- The following figure represents the function \(f\).
Figure \(\PageIndex{22}\)
Interactive Element: Domain and Range as Shadows of a Graph
The following Interactive Element might help you visualize how the domain and range of \(f(x)=2\sqrt{x+4}\) are just the horizontal and vertical extents of its graph.
Interact: Drag the large orange point along the curve and watch the green bar on the \(x\)-axis and the purple bar on the \(y\)-axis grow.
Observation: The green bar (the domain) always starts at the closed endpoint \(x=-4\) and the purple bar (the range) always starts at \(y=0\); dragging far right shows both go on without bound, so the domain is \([-4,\infty)\) and the range is \([0,\infty)\).
Checkpoint \(\PageIndex{10}\)
Find the domain and range of \(f(x) = -\sqrt{2 - x}\).
- Answer
-
Domain: \((-\infty,2]\); range: \((-\infty,0]\)
Graphing Piecewise-Defined Functions
Sometimes, we come across a function that requires more than one formula in order to obtain the given output. For example, in the toolkit functions, we introduced the absolute value function \(f(x) = | x |\). With a domain of all real numbers and a range of values greater than or equal to 0, absolute value can be defined as the magnitude, or modulus, of a real number value regardless of sign. It is the distance from 0 on the number line. All of these definitions require the output to be greater than or equal to 0.
If we input 0, or a positive value, the output is the same as the input.\[f(x) = x \text{ if } x \geq 0.\nonumber\]If we input a negative value, the output is the opposite of the input.\[f(x) = -x \text{ if } x < 0.\nonumber\]Because this requires two different processes, or pieces, the absolute value function is an example of a piecewise function. A piecewise function is a function in which more than one formula is used to define the output over different pieces of the domain.
Definition: Piecewise Function
A piecewise-defined function (also called a piecewise function or a function defined by cases) is a function specified by two or more sub-functions, where each sub-function applies on its own portion of the domain. The portion of the domain on which a given sub-function applies is called its subdomain.
Piecewise functions can be defined using the common functional notation, where the body of the function consists of a list of "subfunctions" and associated subdomains.
Notation: Piecewise Function
Piecewise functions are almost always written using the following notation:\[ f ( x ) = \begin{cases}
\text{subfunction 1}, & \text{if } x \text{ is in subdomain 1} \\[6pt]
\text{subfunction 2}, & \text{if } x \text{ is in subdomain 2} \\[6pt]
\text{subfunction 3}, & \text{if } x \text{ is in subdomain 3} \\[6pt]
\vdots & \vdots \\[6pt]
\end{cases} \nonumber \]Some authors prefer to use a semicolon instead of a comma following the subfunctions. Moreover, the use of "if" following the comma is a stylistic choice, with some authors preferring to use the word "for" instead (e.g., "for \(x < 2\)"). A piecewise function can also be written more succinctly by leaving out both "if" and "for," as follows:\[ f ( x ) = \begin{cases}
x^2, & x < 2 \\[6pt]
e^x, & 2 \leq x < 5 \\[6pt]
\sin(x), & x \geq 5 \\[6pt]
\end{cases} \nonumber \]A value of \(x\) at which one subdomain ends and the next begins is called a breakpoint.
We use piecewise functions to describe situations in which a rule or relationship changes as the input value crosses certain "boundaries." For example, we often encounter situations in business for which the cost per piece of a certain item is discounted once the number ordered exceeds a certain value. Tax brackets are another real-world example of piecewise functions. For example, consider a simple tax system in which incomes up to $10,000 are taxed at 10%, and any additional income is taxed at 20%. The tax, in dollars, on a total income of \(S\) dollars would be \(0.1 S\) if \(S \leq 10{,}000\) and \(1000 + 0.2(S - 10{,}000)\) if \(S > 10{,}000\).
Example \(\PageIndex{11}\): Writing a Piecewise Function
A museum charges $5 per person for a guided tour with a group of 1 to 9 people or a fixed $50 fee for a group of 10 or more people. Write a function relating the number of people, \(n\), to the cost, \(C\).
- Solution
-
Two different formulas will be needed. For \(n\)-values under 10, \(C = 5 n\). For values of \(n\) that are 10 or greater, \(C = 50\).\[C(n) = \begin{cases}
5 n,& \text{ if } 1 \leq n \leq 9 \\[6pt]
50,& \text{ if } n \geq 10 \\[6pt]
\end{cases}\nonumber\]Here \(n\) is a whole number, since it counts people. - Analysis
- The function is represented in the figure below. Because \(n\) counts people, only whole-number inputs make sense, so the graph is a set of separate points. For \(n = 1, 2, \ldots, 9\) the points lie on the line \(C = 5n\), and for \(n \geq 10\) they all have height 50. The first formula would also give \(5(10) = 50\) at \(n = 10\), so the two formulas agree where they meet, but not all piecewise functions have this property.
Figure \(\PageIndex{23}\)
Checkpoint \(\PageIndex{11}\)
A print shop charges $0.20 per page for orders of 1 to 99 pages and $0.15 per page for orders of 100 pages or more. Write a function relating the number of pages, \(p\), to the cost, \(C\), in dollars.
- Answer
-
\[C(p) = \begin{cases}
0.20p,& \text{ if } 1 \leq p \leq 99 \\[6pt]
0.15p,& \text{ if } p \geq 100 \\[6pt]
\end{cases}\nonumber\]where \(p\) is a whole number.
Example \(\PageIndex{12}\): Working with a Piecewise Function
A cell phone company uses the function below to determine the cost, \(C\), in dollars for \(g\) gigabytes of data transfer.\[C(g) = \begin{cases}
25,& \text{ if } 0 \leq g < 2 \\[6pt]
25 + 10(g - 2),& \text{ if } g \geq 2 \\[6pt]
\end{cases}\nonumber\]Find the cost of using 1.5 gigabytes of data and the cost of using 4 gigabytes of data.
- Solution
-
To find the cost of using 1.5 gigabytes of data, \(C(1.5)\), we first look to see which part of the domain our input falls in. Because 1.5 is less than 2, we use the first formula.\[C(1.5) = \$25.\nonumber\]To find the cost of using 4 gigabytes of data, \(C(4)\), we see that our input of 4 is greater than 2, so we use the second formula.\[C(4) = 25 + 10(4 - 2) = \$45 .\nonumber\]
- Analysis
- The function is represented in the figure below. We can see where the function changes from a constant to a shifted and stretched identity at \(g = 2\). We plot the graphs for the different formulas on a common set of axes, making sure each formula is applied on its proper domain.
Figure \(\PageIndex{24}\)
Checkpoint \(\PageIndex{12}\)
A parking garage uses the function below to determine the cost, \(P\), in dollars to park for \(h\) hours.\[P(h) = \begin{cases}
8,& \text{ if } 0 < h \leq 3 \\[6pt]
8 + 3(h - 3),& \text{ if } h > 3 \\[6pt]
\end{cases}\nonumber\]Find the cost of parking for 3 hours and for 5.5 hours.
- Answer
-
\(P(3) = \$8\); \(P(5.5) = \$15.50\)
While I am not a huge fan of "algorithmic" instructions on how to do each problem (such habits lead to an overwhelming amount of memorization and a subpar level of understanding), such instruction is incredibly helpful when it comes to graphing piecewise functions.
How To
Given a piecewise function, sketch a graph.
- Indicate on the \(x\)-axis the boundaries defined by the intervals on each piece of the domain.
- For each piece of the domain, graph on that interval using the corresponding equation pertaining to that piece. Do not graph two functions over one interval because it would violate the criteria of a function.
- At each breakpoint, draw a closed circle at the end of the piece whose subdomain includes the breakpoint, and an open circle at the end of any piece whose subdomain excludes it.
Example \(\PageIndex{13}\): Graphing a Piecewise Function
Sketch a graph of the function.\[f(x) = \begin{cases}
x^2,& \text{ if } x \leq 1 \\[6pt]
3,& \text{ if } 1 < x \leq 2 \\[6pt]
x,& \text{ if } x >2 \\[6pt]
\end{cases}\nonumber\]
- Solution
-
Each of the component functions is from our library of toolkit functions, so we know their shapes. We can imagine graphing each function and then limiting the graph to the indicated domain. At the endpoints of each subdomain, we draw open circles to indicate where the endpoint is not included because of a less-than or greater-than inequality; we draw a closed circle where the endpoint is included because of a less-than-or-equal-to or greater-than-or-equal-to inequality.
The figure below shows the three components of the piecewise function graphed on separate coordinate systems.
Figure \(\PageIndex{25}\) Now that we have sketched each piece individually, we combine them in the same coordinate plane.
Figure \(\PageIndex{26}\) - Analysis
-
Note that the graph does pass the Vertical Line Test even at \(x = 1\) and \(x = 2\) because the points \((1,3)\) and \((2,2)\) are not part of the graph of the function, though \((1,1)\) and \((2,3)\) are.
Checkpoint \(\PageIndex{13}\)
Graph the following piecewise function.\[f(x) = \begin{cases}
x^3,& \text{ if } x \leq-1 \\[6pt]
-2,& \text{ if } -1 < x \leq 4 \\[6pt]
\sqrt{x},& \text{ if } x >4 \\[6pt]
\end{cases}\nonumber\]
- Answer
-
The graph has three pieces: the cubic \(y = x^3\) for \(x \leq -1\), ending at the closed point \((-1,-1)\); the horizontal segment \(y = -2\) from the open point \((-1,-2)\) to the closed point \((4,-2)\); and the curve \(y = \sqrt{x}\) for \(x > 4\), starting at the open point \((4,2)\).
Before we leave this section, it's best to preview the real definition of the absolute value as a piecewise function.
Definition: Absolute Value (as a number)
The absolute value (or modulus) of a real number \(x\), denoted \(|x|\), is its distance from zero on the real number line. It is defined by\[|x| = \begin{cases} x & \text{if } x \geq 0, \\ -x & \text{if } x \lt 0. \end{cases}\nonumber\]
Q&A
Can more than one formula from a piecewise function be applied to a value in the domain?
No. The subdomains of a piecewise function do not overlap, so each input in the domain belongs to exactly one subdomain and is evaluated with exactly one formula.

