# Piecewise Functions

This section covers:

# Introduction to Piecewise Functions

Piecewise functions are just what they are named: pieces of different functions all on one graph.  The easiest way to think of them is if you drew more than one function on a graph, and you just erased parts of the functions where they aren’t supposed to be (along the x’s); they are defined differently for different intervals of x.  So y is defined differently for different values of x; we use the x to look up what interval it’s in, so we can find out what the y is supposed to be. Here’s an example and graph:

So what this means is for every x less than or equal to –2, we need to graph the line 2x + 8, as if it were the only function on the graph.  For every x value greater than –2, we need to graph , as if it were the only function on the graph.  Then we have to “get rid of” the parts that we don’t need.  Remember that we still use the origin as the reference point for both graphs! See how the vertical line x = 2 acts as a “boundary” line between the two graphs? Note that the point (–2, 4) has a closed circle on it.  Technically, it should only belong to the 2x + 8 function, since that function has the less than or equal sign, but since the point is also on the  graph, we can just use a closed circle as if it appears on both functions. See, not so bad, right?

# Evaluating Piecewise Functions

Sometimes, you’ll be given piecewise functions and asked to evaluate them; in other words, find the y values when you are given an x value.  Let’s do this for x = –6 and x = 4 (without using the graph).   Here is the function again: We first want to look at the conditions at the right first, to see where our x is.  When x = –6, we know that it’s less than –2, so we plug in our x to 2x + 8 only.  So f(x) or y is (2)(–6) + 8, or –4.   We don’t even care about the !  It’s that easy.  You can also see that we did this correctly by using the graph above. Now try x = 4.  We look at the right first, and see that our x is greater than –2, so we plug it in the .  (We can just ignore the 2x + 8 this time.)  So f(x) or y is 42 = 16.

# Graphing Piecewise Functions

You’ll probably be asked to graph piecewise functions.  Sometimes the graphs will contain functions that are non-continuous or discontinuous, meaning that you have to pick up your pencil in the middle of the graph when you are drawing it (like a jump!).   Continuous functions means that you never have to pick up your pencil if you were to draw them from left to right. And remember that the graphs are true functions only if they pass the Vertical Line Test. Let’s draw these piecewise functions and determine if they are continuous or non-continuous.  Note how we draw each function as if it were the only one, and then “erase” the parts that aren’t needed.  We’ll also get the Domain and Range like we did here in the Algebraic Functions section.

We can actually put piecewise functions in the graphing calculator:

# How to Tell if Piecewise Function is Continuous or Non-Continuous

To tell if a piecewise graph is continuous or non-continuous, you can look at the boundary points and see if the y point is the same at each of them.  (If the y’s were different, there’d be a “jump” in the graph!) Let’s try this for the functions we used above:

# Obtaining Equations from Piecewise Function Graphs

You may be asked to write a piecewise function, given a graph.  Now that we know what piecewise functions are all about, it’s not that bad! To review how to obtain equations from linear graphs, see Obtaining the Equations of a Line, and from quadratics, see Finding a Quadratic Equation from Points or a Graph. Here are the graphs, with explanations on how to derive their piecewise equations:

# Absolute Value as a Piecewise Function

We can write absolute value functions as piecewise functions – it’s really cool!   You might want to review Algebraic Equations with Absolute Value before continuing on to this topic. Let’s say we have the function .  From what we learned earlier, we know that when x is positive, since we’re taking the absolute value, it will still just be x.  But when x is negative, when we take the absolute value, we have to take the opposite (negate it), since the absolute value has to be positive.  Make sense?  So, for example, if we had |5|, we just take what’s inside the absolute sign, since it’s positive.  But for |–5|, we have to take the opposite (negative) of what’s inside the absolute value to make it 5 (– – 5 is 5). This means we can write this absolute value function as a piecewise function.  Notice that we can get the “turning point” or “boundary point” by setting whatever is inside the absolute value to 0.   For example, we can write  . Also note that, if the function is continuous (there is no “jump”) at the boundary point, it doesn’t matter where we put the “less than or equal to” (or “greater than or equal to”) signs, as long as we don’t repeat them!   We can’t repeat them because, theoretically, we can’t have 2 values of y for the same x, or we wouldn’t have a function. Here are more examples, with explanations.  (You might want to review Quadratic Inequalities for the second example below):

You may also be asked to take an absolute value graph and write it as a piecewise function:

# Transformations of Piecewise Functions

Let’s do a transformation of a piecewise function. We learned how about Parent Functions and their Transformations here in the Parent Graphs and Transformations section.   You’ll probably want to read this section first, before trying a piecewise transformation. Let’s transform the following piecewise function flipped around the x axis, vertically stretched by a factor of 2 units, 1 unit to the right, and 3 units up. So we will draw , $$-2f\left( x-1 \right)+3$$ where: Let’s make sure we use the “boundary” points when we fill in the t-chart for the transformation.   Remember that the transformations inside the parentheses are done to the x (doing the opposite math), and outside are done to the y.   So to come up with a t-chart, as shown in the table below, we can use key points, including two points on each of the “boundary lines”. Note that because this transformation is complicated, we can come up with a new piecewise function by transforming the 3 “pieces” and also transforming the “x”s where the boundary points are (adding 1, or going to the right 1), since we do the opposite math for the “x”s: Here are the “before” and “after” graphs, including the t-chart:

# Piecewise Function Word Problems

Problem: Your favorite dog groomer charges according to your dog’s weight.  If your dog is 15 pounds and under, the groomer charges $35. If your dog is between 15 and 40 pounds, she charges$40.  If your dog is over 40 pounds, she charges $40, plus an additional$2 for each pound. (a)   Write a piecewise function that describes what your dog groomer charges. (b)   Graph the function. (c)   What would the groomer charge if your cute dog weighs 60 pounds? Solution: (a)   We see that the “boundary points” are 15 and 40, since these are the weights where prices change.  Since we have two boundary points, we’ll have three equations in our piecewise function.  We have to start at 0, since dogs have to weigh over 0 pounds:  We are looking for the “answers” (how much the grooming costs) to the “questions” (how much the dog weighs) for the three ranges of prices.  The first two are just flat fees ($35 and$40, respectively).  The last equation is a little trickier; the groomer charges $40 plus$2 for each pound over 40.  Let’s try real numbers: if your dog weighs 60 pounds, she will charge $40 plus$2 times 20 (60 – 40).  We’ll turn this into an equation: 40 + 2(x – 40), which simplifies to 2x – 40 (see how 2 is the slope?).   So the whole piecewise function is: (b)   Let’s graph: Note that this piecewise equation is non-continuous. Also note a reasonable domain for this problem might be  (given dogs don’t weigh over 200 pounds!) and a reasonable range might be . (c)   If your dog weighs 60 pounds, we can either use the graph, or the function to see that you would have to pay $80. Whoa! That costs more than a human haircut (at least my haircuts)! Problem: You plan to sell She Love Math t-shirts as a fundraiser. The wholesale t-shirt company charges you$10 a shirt for the first 75 shirts.  After the first 75 shirts you purchase up to 150 shirts, the company will lower its price to $7.50 per shirt. After you purchase 150 shirts, the price will decrease to$5 per shirt.  Write a function that models this situation. Solution: We see that the “boundary points” are 75 and 150, since these are the number of t-shirts bought where prices change.  Since we have two boundary points, we’ll have three equations in our piecewise function.  We’ll start with x greater than or equal to 1, since, we assume at least one shirt is bought.  Note in this problem, the number of t-shirts bought (x), or the domain, must be a integer, but this restriction shouldn’t affect the outcome of the problem. We are looking for the “answers” (total cost of t-shirts) to the “questions” (how many are bought) for the three ranges of prices. For up to and including 75 shirts, the price is $10, so the total price would 10x. For more than 75 shirts but up to 100 shirts, the cost is$7.50, but the first 75 t-shirts will still cost $10 per shirt. So the second function includes the$750 spent on the first 75 shirts (75 times $10), and also includes$7.50 times the number of shirts over 75, which would be (x – 75).   For example, if you bought 80 shirts, you’d have to spend $10 times 75 =$750, plus $7.50 times 5 (80 – 75) for the shirts after the 75th shirt. Similarly, for over 150 shirts, we would still pay the$10 price up through 75 shirts, the $7.50 price for 76 to 150 shirts (75 more shirts), and then$5 per shirt for the number of shirts bought over 150.  So we’ll pay 10(75) + 7.50(75) + 5(x – 150) for x shirts.  Put in numbers and try it! So the whole piecewise function is:

Problem: What value of a would make this piecewise function continuous? Solution: For the piecewise function to be continuous, at the boundary point (where the function changes), the two y values must be the same.   So we can plug in –2 for x in both of the functions and make sure the y’s are the same

If a = 26, the piecewise function is continuous! Learn these rules, and practice, practice, practice!

More Practice: Use the Mathway widget below to try write an . Piecewise Function. Click on Submit (the blue arrow to the right of the problem) and click on Write the Absolute Value as Piecewise to see the answer.

You can also type in your own problem, or click on the three dots in the upper right hand corner and click on “Examples” to drill down by topic.

If you click on Tap to view steps, or Click Here, you can register at Mathway for a free trial, and then upgrade to a paid subscription at any time (to get any type of math problem solved!).

On to Matrices and Solving Systems with Matrices – you are ready!