Section 1.2: Piecewise Defined Functions

This content comes directly from the OpenStax textbook Algebra and Trigonometry, 2nd edition Section 3.2 Domain and Range.

Access this resource for free at https://openstax.org/books/algebra-and-trigonometry-2e/pages/3-2-domain-and-range


Learning Objectives

In this section, you will:

  • Define a piecewise-defined function..
  • Evaluate a piecewise-defined function.
  • Graph a piecewise-defined function.
  • Interpret the graph of a piecewise-defined function.

Let’s Get Started 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, consider the absolute value function [latex]f\left(x\right)=|x|[/latex].  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.

[latex]f\left(x\right)=x\;\text{if}\,x\ge 0[/latex]

If we input a negative value, the output is the opposite of the input.

[latex]f\left(x\right)=-x \;\text{if}\,x\lt0[/latex]

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 [latex]S[/latex] would be [latex]0.1S[/latex] if [latex]S\le \text{\$}10\text{,}000[/latex] and [latex]\text{\$}1000+0.2\left(S-\text{\$}10\text{,}000\right)[/latex] if [latex]S\gt\text{\$}10\text{,}000[/latex].

 

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:

[latex]f\left(x\right)=\Bigg\{\begin{array}{l}\text{formula 1 if }x\text{ is in domain 1}\\ \text{formula 2 if }x\text{ is in domain 2}\\ \text{formula 3 if }x\text{ is in domain 3}\end{array}[/latex]

In piecewise notation, the absolute value function is

[latex]|x|=\bigg\{\begin{array}{l}x\text{ if }x\ge 0\\ -x\text{ if }x<0\end{array}[/latex]

 

How To

Given 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 1

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, [latex]n[/latex], to the cost, [latex]C[/latex].

 

Show/Hide Solution

 

image Analysis

The function is represented in Figure 1. The graph is a diagonal line from [latex]n=0[/latex] to [latex]n=10[/latex] and a constant after that.  In this example, the two formulas agree at the meeting point where [latex]n=10[/latex], but not all piecewise functions have this property.

 

Graph of C(n).

Figure 1

 


EXAMPLE 2

Working with a Piecewise Function

A cell phone company uses the function below to determine the cost, [latex]C[/latex], in dollars for [latex]g[/latex] gigabytes of data transfer.

[latex]C\left(g\right)=\Bigg\{\begin{array}{ccc}25& \text{if}& 0\gt g \gt 2\\ 25+10\left(g-2\right)& \text{if}& g\ge 2\end{array}[/latex]

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

 

Show/Hide Solution

 

image Analysis

The function is represented in Figure 2. We can see where the function changes from a constant to a shifted and stretched identity at [latex]g=2[/latex].  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 2

 


 

How To

Given a piecewise function, sketch a graph.

  1. Indicate on the [latex]x-[/latex]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 3

Graphing a Piecewise Function

Sketch a graph of the function.

[latex]f\left(x\right)=\Bigg\{\begin{array}{ccc}{x}^{2}& \text{if}& x\le 1\\ 3& \text{if}& 1\lt x \le 2\\ x& \text{if}& x \gt 2\end{array}[/latex]

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

 

Show/Hide Solution

 

image Analysis

The function is represented in Figure 2. We can see where the function changes from a constant to a shifted and stretched identity at [latex]g=2[/latex].  We plot the graphs for the different formulas on a common set of axes, making sure each formula is applied on its proper domain.

Note that the graph does pass the vertical line test even at [latex]x=1[/latex] and [latex]x=2[/latex] because the points [latex]\left(1,3\right)[/latex] and [latex]\left(2,2\right)[/latex] are not part of the graph of the function, though [latex]\left(1,1\right)[/latex] and [latex]\left(2,\,3\right)[/latex] are.

 


image  Try It #1

Graph the following piecewise function.

[latex]f\left(x\right)=\Bigg\{\begin{array}{ccc}{x}^{3}& \text{if}& x \lt-1\\ -2& \text{if}& -1 \lt x \lt 4\\ \sqrt{x}& \text{if}& x \gt 4\end{array}[/latex]

Section 1.2 Exercises

[Answers to odd problem numbers are provided at the end of the problem set.  Just scroll down!]

For the following exercises, sketch a graph of the piecewise function. Write the domain in interval notation.

 

1.  [latex]f\left(x\right)=\Bigg\{\begin{array}{lll}x+1\hfill & \text{if}\hfill & x<-2\hfill \\ -2x-3\hfill & \text{if}\hfill & x\ge -2\hfill \end{array}[/latex]

 

2.  [latex]f\left(x\right)=\Bigg\{\begin{array}{lll}2x-1\hfill & \text{if}\hfill & x<1\hfill \\ 1+x\hfill & \text{if}\hfill & x\ge 1\hfill \end{array}[/latex]

 

3. [latex]f\left(x\right)=\Bigg\{\begin{array}{ccc}3& \text{if}& x<0\\ \sqrt{x}& \text{if}& x\ge 0\end{array}[/latex]

 

4.  [latex]f\left(x\right)=\Bigg\{\begin{array}{c}x+1\,\,\text{if}\,\,x<0\\ x-1\,\,\text{if}\,\,\,x>0\end{array}[/latex]

 

5. [latex]f\left(x\right)=\Bigg\{\begin{array}{r}\hfill \begin{array}{r}\hfill {x}^{2}\\ \hfill x+2\end{array}\end{array}\,\,\begin{array}{l}\text{if}\,\,\,\,\,x<0\hfill \\ \text{if}\,\,\,\,\,x\ge 0\hfill \end{array}[/latex]

 

6.[latex]f\left(x\right)=\Bigg\{\begin{array}{c}{x}^{2}\text{ if }x<0\\ 1-x\text{ if }x>0\end{array}[/latex]

 

7. [latex]f\left(x\right)=\Bigg\{\begin{array}{c}|x|\\ 1\end{array}\begin{array}{l}\,\,\,\text{if}\,\,\,x<2\hfill \\ \,\,\,\text{if}\,\,\,x\ge 2\hfill \end{array}[/latex]

 

8.  [latex]f\left(x\right)=\Bigg\{\begin{array}{ccc}x+1& \text{if}& x<1\\ {x}^{3}& \text{if}& x\ge 1\end{array}[/latex]

Numeric

For the following exercises, given each function [latex]f,[/latex]evaluate [latex]f\left(-3\right),\,f\left(-2\right),\,f\left(-1\right),[/latex] and [latex]f\left(0\right).[/latex]

 

9. [latex]f\left(x\right)=\Bigg\{\begin{array}{cc}1& \text{if }x\le -3\\ 0& \text{if }x>-3\end{array}[/latex]

 

10.  [latex]f\left(x\right)=\Bigg\{\begin{array}{lll}x+1\hfill & \text{if}\hfill & x<-2\hfill \\ -2x-3\hfill & \text{if}\hfill & x\ge -2\hfill \end{array}[/latex]

 

11.  [latex]f\left(x\right)=\Bigg\{\begin{array}{cc}-2{x}^{2}+3& \text{if }x\le -1\\ 5x-7& \text{if }x>-1\end{array}[/latex]

 

For the following exercises, given each function[latex]\,f,\,[/latex]evaluate[latex]f\left(-1\right),\,f\left(0\right),\,f\left(2\right),\,[/latex]and[latex]\,f\left(4\right).[/latex]

 

12. [latex]f\left(x\right)=\Bigg\{\begin{array}{ccc}{x}^{2}-2& \text{if}& x<2\\ 4+|x-5|& \text{if}& x\ge 2\end{array}[/latex]

 

13.  [latex]f\left(x\right)=\Bigg\{\begin{array}{lll}7x+3\hfill & \text{if}\hfill & x<0\hfill \\ 7x+6\hfill & \text{if}\hfill & x\ge 0\hfill \end{array}[/latex]

 

14.  [latex]f\left(x\right)=\Bigg\{\begin{array}{ccc}{x}^2-5& \text{if}& x<1\\ 4x+5 & \text{if}& 1\le x\le 4\\ \frac{1}{2}x & \text{if}& x>4\end{array}[/latex]

 

15.  [latex]f\left(x\right)=\Bigg\{\begin{array}{ccc}5x& \text{if}& x<0\\ 3& \text{if}& 0\le x\le 3\\ {x}^{2}& \text{if}& x>3\end{array}[/latex]

 

For the following exercises, write the domain for the piecewise function in interval notation.

 

16.  [latex]f\left(x\right)=\Bigg\{\begin{array}{c}x+1\,\,\,\,\,\text{ if}\,\,x<-2\\ -2x-3\,\,\text{if}\,\,x\ge -2\end{array}[/latex]

 

17.  [latex]f\left(x\right)=\Bigg\{\begin{array}{c}{x}^{2}-2\,\,\,\,\,\text{ if}\,\,x<1\\ -{x}^{2}+2\,\,\text{if}\,\,x>1\end{array}[/latex]

 

18.  [latex]f\left(x\right)=\Bigg\{\begin{array}{c}2x-3\\ -3{x}^{2}\end{array}\,\,\begin{array}{c}\text{if}\,\,\,x<0\\ \text{if}\,\,\,x\ge 2\end{array}[/latex]

 


Answers to Section 1.2 Odd Problems

1.  domain:[latex]\,\left(-\infty ,\infty \right)[/latex]

Graph of f(x).

 

3.  domain:[latex]\,\left(-\infty ,\infty \right)[/latex]

Graph of f(x).

 

5.  domain:[latex]\,\left(-\infty ,\infty \right)[/latex]

Graph of f(x).

 

 

7.  domain:[latex]\,\left(-\infty ,\infty \right)[/latex]

Graph of f(x).

 

9.  [latex]\begin{array}{cccc}f\left(-3\right)=1;& f\left(-2\right)=0;& f\left(-1\right)=0;& f\left(0\right)=0\end{array}[/latex]

 

11.  [latex]\begin{array}{cccc}f\left(-3\right)=-15;& f\left(-2\right)=-5;& f\left(-1\right)=1;& f\left(0\right)=-7\end{array}[/latex]

 

13.  [latex]\begin{array}{cccc}f\left(-1\right)=-4;& f\left(0\right)=6;& f\left(2\right)=20;& f\left(4\right)=34\end{array}[/latex]

 

15.  [latex]\begin{array}{cccc}f\left(-1\right)=-5;& f\left(0\right)=3;& f\left(2\right)=3;& f\left(4\right)=16\end{array}[/latex]

 

17.  domain:[latex]\,\left(-\infty ,1\right)\cup \left(1,\infty \right)[/latex]

 

 

License

Icon for the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License

Baylor University's Co-requisite Supplement for Calculus I Copyright © 2023 by Amy Graham Goodman is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License, except where otherwise noted.

Share This Book