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 $10,000 are taxed at and any additional income is taxed at . The tax on a total income, S, would be S if $10,000 and 1000 + 0.2 (S - $10,000) if S > $10,000.
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:
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 , evaluate:Answer: In order to evaluate a function for a given value, we first have to determine which domain that values falls into. In this example, if the value is less than zero then we will use the first formula. If the given value is greater than or equal to zero, then we will use the second formula. 1. is defined as for . Evaluate: 2. is defined as for . Evaluate: 3. is defined as for . Evaluate:
Example
A cell phone company uses the function below to determine the cost, , in dollars for gigabytes of data transfer.
Find the cost of using gigabytes of data and the cost of using gigabytes of data.
Answer:
To find the cost of using gigabytes of data, C, we first look to see which part of the domain our input falls. Because is less than , we use the first formula.
C(1.5) = $25To find the cost of using gigabytes of data, C, we see that our input of is greater than , 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 $5 per person for a guided tour for a group of to people or a fixed $50 fee for a group of or more people. Write a function relating the number of people, , to the cost, .Answer: Two different formulas will be needed. For n-values under , . For values of n that are or greater, .

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.