Skip to main content
Mathematics LibreTexts

1.2: Domain and Range

  • Page ID
    117097
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\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}}\)

    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≥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.

    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 on a total income S would be \(0.1S\) if \(S≤$10,000\) and \($1000+0.2(S−$10,000)\) if \(S>$10,000\).

    Piecewise Function

    A piecewise function is a function in which more than one formula is used to define the output. Each formula has its own domain, and the domain of the function is the union of all these smaller domains. We notate this idea like this:

    \[f(x)= \begin{cases} \text{formula 1} & \text{if x is in domain 1} \\ \text{formula 2} &\text{if x is in domain 2} \\ \text{formula 3} &\text{if x is in domain 3}\end{cases} \nonumber \]

    In piecewise notation, the absolute value function is

    \[|x|= \begin{cases} x & \text{if $x \geq 0$} \\ -x &\text{if $x<0$} \end{cases} \nonumber \]

    altGiven a piecewise function, write the formula and identify the domain for each interval.

    1. Identify the intervals for which different rules apply.
    2. Determine formulas that describe how to calculate an output from an input in each interval.
    3. Use braces and if-statements to write the function.
    Example \(\PageIndex{8A}\): 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=5n\). For values of n that are 10 or greater, \(C=50\).

    \[C(n)= \begin{cases} 5n & \text{if $n < 10$} \\ 50 &\text{if $n\geq10$} \end{cases} \nonumber \]

    Analysis

    The function is represented in Figure \(\PageIndex{20}\). The graph is a diagonal line from \(n=0\) to \(n=10\) and a constant after that. In this example, the two formulas agree at the meeting point where \(n=10\), but not all piecewise functions have this property.

    [Graph of C(n).]
    Figure \(\PageIndex{20}\)
    Example \(\PageIndex{8B}\): 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<g<2$} \\ 25+10(g-2) &\text{if $g\geq2$} \end{cases} \nonumber \]

    Find the cost of using 1.5 gigabytes of data and the cost of using 4 gigabytes of data.

    Soltuion

    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 Figure \(\PageIndex{21}\). 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.

    [Graph of C(g)]
    Figure \(\PageIndex{21}\)

    altGiven a piecewise function, sketch a graph.

    1. Indicate on the x-axis the boundaries defined by the intervals on each piece of the domain.
    2. 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.
    Example \(\PageIndex{8C}\): Graphing a Piecewise Function

    Sketch a graph of the function.

    \[f(x)= \begin{cases} x^2 & \text{if $x \leq 1$} \\ 3 &\text{if $1<x\leq2$} \\ x &\text{if $x>2$} \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 the domain, 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.

    Figure \(\PageIndex{20}\) shows the three components of the piecewise function graphed on separate coordinate systems.

    [Graph of each part of the piece-wise function f(x)]
    Figure \(\PageIndex{20}\): Graph of each part of the piece-wise function f(x)

    (a)\( f(x)=x^2\) if \(x≤1\); (b) \(f(x)=3\) if \(1< x≤2\); (c) \(f(x)=x\) if \(x>2\)

    Now that we have sketched each piece individually, we combine them in the same coordinate plane. See Figure \(\PageIndex{21}\).

    [Graph of the entire function.]
    Figure \(\PageIndex{21}\): Graph of the entire function.

    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.

    Exercise \(\PageIndex{8}\)

    Graph the following piecewise function.

    \[f(x)= \begin{cases} x^3 & \text{if $x < -1$} \\ -2 &\text{if $-1<x<4$} \\ \sqrt{x} &\text{if $x>4$} \end{cases} \nonumber \]

    Answer
    [Graph of f(x).]
    Figure \(\PageIndex{22}\)

    alt Can more than one formula from a piecewise function be applied to a value in the domain?

    No. Each value corresponds to one equation in a piecewise formula.


    This page titled 1.2: Domain and Range is shared under a CC BY 4.0 license and was authored, remixed, and/or curated by OpenStax via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.