Writing Piecewise Functions
Learning Outcomes
- Define piecewise function
- Evaluate a piecewise function
- Write a piecewise function given an application
A piecewise function is a function where more than one formula is used to define the output over different pieces of the domain.
We use piecewise functions to describe situations where a rule or relationship changes as the input value crosses certain "boundaries." Piecewise function are useful in many real-world situations. For example, we often encounter situations in business where 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 where incomes up to [latex]$10,000[/latex] are taxed at [latex]10\%[/latex] and any additional income is taxed at [latex]20\%[/latex]. The tax on a total income, S, would be [latex]0.1[/latex]S if [latex]S\le[/latex] [latex]$10,000[/latex] and [latex]1000 + 0.2 (S - $10,000)[/latex] if S > [latex]$10,000[/latex].
Piecewise Function
A piecewise function is a function where 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 of these smaller domains. We notate this idea like this:
[latex-display] f\left(x\right)=\begin{cases}\text{formula 1 if x is in domain 1}\\ \text{formula 2 if x is in domain 2}\\ \text{formula 3 if x is in domain 3}\end{cases} [/latex-display] In piecewise notation, the absolute value function isEvaluate a Piecewise-Defined Function
In the first example, we will show how to evaluate a piecewise defined function. Note how it is important to pay attention to the domain to determine which expression to use to evaluate the input.Example
Given the function [latex]f(x)=\begin{cases}7x+3\text{ if }x<0\\7x+6\text{ if }x\ge{0}\end{cases}[/latex], evaluate:- [latex]f (-1)[/latex]
- [latex]f (0)[/latex]
- [latex]f (2)[/latex]
Answer: In order to evaluate a function for a given [latex]x[/latex] value, we first have to determine which domain that [latex]x[/latex] values falls into. In this example, if the [latex]x[/latex] value is less than zero then we will use the first formula. If the given [latex]x[/latex] value is greater than or equal to zero, then we will use the second formula. 1. [latex]f(x)[/latex] is defined as [latex]7x+3[/latex] for [latex]x=-1\text{ because }-1<0[/latex]. Evaluate: [latex]f(-1)=7(-1)+3=-7+3=-4[/latex] 2. [latex]f(x)[/latex] is defined as [latex]7x+6[/latex] for [latex]x=0\text{ because }0\ge{0}[/latex]. Evaluate: [latex]f(0)=7(0)+6=0+6=6[/latex] 3. [latex]f(x)[/latex] is defined as [latex]7x+6[/latex] for [latex]x=2\text{ because }2\ge{0}[/latex]. Evaluate: [latex]f(2)=7(2)+6=14+6=20[/latex]
Example
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.
Find the cost of using [latex]1.5[/latex] gigabytes of data and the cost of using [latex]4[/latex] gigabytes of data.
Answer:
To find the cost of using [latex]1.5[/latex] gigabytes of data, C[latex](1.5)[/latex], we first look to see which part of the domain our input falls. Because [latex]1.5[/latex] is less than [latex]2[/latex], we use the first formula.
[latex-display]C(1.5) = $25[/latex-display]To find the cost of using [latex]4[/latex] gigabytes of data, C[latex](4)[/latex], we see that our input of [latex]4[/latex] is greater than [latex]2[/latex], so we use the second formula.
Write a Piecewise-Defined Function
In the last example, we will show how to write a piecewise-defined function that models the price of a guided museum tour.Example
A museum charges [latex]$5[/latex] per person for a guided tour for a group of [latex]1[/latex] to [latex]9[/latex] people or a fixed $50 fee for a group of [latex]10[/latex] or more people. Write a function relating the number of people, [latex]n[/latex], to the cost, [latex]C[/latex].Answer: Two different formulas will be needed. For n-values under [latex]10[/latex], [latex]C=5n[/latex]. For values of n that are [latex]10[/latex] or greater, [latex]C=50[/latex]. [latex-display]C(n)=\begin{cases}{5n}\text{ if }{0}<{n}<{10}\\ 50\text{ if }{n}\ge 10\end{cases}[/latex-display]
How To: Given a piecewise function, write the formula and identify the domain for each interval
- Identify the intervals where different rules apply.
- Determine formulas for the rules that describe how to calculate an output from an input in each interval.
- Use a bracket and "if" statements to write the function.
Summary
- A piecewise function is a function where more than one formula is used to define the output over different pieces of the domain.
- Evaluating a piecewise function means you need to pay close attention to the correct expression used for the given input.
Contribute!
Licenses & Attributions
CC licensed content, Original
- Revision and Adaptation. Provided by: Lumen Learning License: CC BY: Attribution.
- Determine a Basic Piecewise Defined Function. Authored by: James Sousa (Mathispower4u.com) for Lumen Learning. License: CC BY: Attribution.
CC licensed content, Shared previously
- Ex: Determine Function Values for a Piecewise Defined Function. Authored by: James Sousa (Mathispower4u.com) . License: CC BY: Attribution.
CC licensed content, Specific attribution
- Precalculus. Provided by: OpenStax Authored by: Jay Abramson, et al.. Located at: https://openstax.org/books/precalculus/pages/1-introduction-to-functions. License: CC BY: Attribution. License terms: Download For Free at : http://cnx.org/contents/[email protected]..