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:

Piecewise Function 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 Bold X Squared, 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 Bold X Squared 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:

Piecewise Function Example

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 Bold X Squared!  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 x Squared.  (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.

Piecewise Continuous and NonContinuous

We can actually put piecewise functions in the graphing calculator:

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:

Checking to see if Piecewise Functions are Continuous

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:

Deriving Piecewise Function Equations from Graphs

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 Absolute Value of x.  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  Absolute Value as Piecewise Function.

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):

Deriving Piecewise Functions from Absolute Value Functions

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

Obtaining Piecewise Functions from Graphs

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:

Piecewise Function to Transform

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:

Transformed Piecewise Function

Here are the “before” and “after” graphs, including the t-chart:

Transformed Piecewise Function Graphs

Piecewise Function Word Problems



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?


(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:  Word Problem Boundary

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:

Word Problem Piecewise Function

(b)   Let’s graph:

Graph of Dog Word Problem

Note that this piecewise equation is non-continuous.

Also note a reasonable domain for this problem might be Domain (given dogs don’t weigh over 200 pounds!) and a reasonable range might be Range.

(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)!


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.


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.

T-Shirt Word 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:

Word Problem Piecewise Function


What value of a would make this piecewise function continuous?

Make a Piecewise Function Continuous


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

Solving for a

If a = 26, the piecewise function is continuous!

Learn these rules, and practice, practice, practice!

Click on Submit (the arrow to the right of the problem) to solve this problem. You can also type in more problems, or click on the 3 dots in the upper right hand corner to drill down for example problems.

If you click on “Tap to view steps”, you will go to the Mathway site, where you can register for the full version (steps included) of the software.  You can even get math worksheets.

You can also go to the Mathway site here, where you can register, or just use the software for free without the detailed solutions.  There is even a Mathway App for your mobile device.  Enjoy!

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

119 thoughts on “Piecewise Functions

  1. Hi I don’t know what to do in my project about piecewise function can you help me?

    Research about tax rates in the Philippines (e.g if you earn certain income level, then your tax rate is such and such
    Based on the assisting structure, ask students should define a piecewise function that models this situation by giving
    A. The function’s equation
    B. A table showing some function values
    C. A graph
    Your students will use the piecewise function, representing the tax structure or basic for discussing whether you think the tax rate is fair.

  2. Could you help me in this problem?
    Here is it.
    The fee for hiring a guide to explore a cave is 700. A guide can only take care of a maximum of 4 persons and additional guides can be hired as needed represent the cost of hiring guides as a function of the number of tourist who wish to explore the cave.

    • Here’s how I’d do this problem: y = 0, for x = 0. y = 700 * ([(x-1)/4] + 1) for x > 0, where x is an integer. Note that [ ] is an integer function, where you take the next lowest integer after the division. For example [1.5] = 1. Does that make sense?

      • SO if only 2 people show up then y=700[2/4] =0.??? Yet cost for 1,2,3,or 4 people would be 700. I read somewhere that the least integer is ]x[ so
        [1/4[=1?? So we jump up if fraction and stay if integer ]4/4[=1??

        • Thanks for writing back – you are absolute right! How about this: y = 0, for x = 0. y = 700 * ([(x-1)/4] + 1) for x > 0, where x is an integer. Lisa

    • Thanks so much for your nice comment – this means a lot. Keep visiting the site and let me know how I can make it better 😉 Lisa

    • I would write this as:

      f(x) = 40, if 0 less than or equal to x less than or equal to 500, 40 + ([(x – 500)/300] + 1)*3.5, if x > 500.

      Note that the [ ] function is the integer function, which means take the lower integer (round down) from what you get. Not sure if this is correct – does it look right?
      (for some reason, I had to spell out less than or equal to, or it wouldn’t work).

  3. Can someone help me with this problem?

    The cost c (in dollars) per unit of making x photocopies at The Office Shop is given below.

    18 cents for at most 20 copies
    12 cents for more than 20 copies up to 50
    9 cents for more than 50 copies but less than 100
    5 cents for 100 copies or more but up to 200
    3 cents for more than 200 copies

    Write the piecewise-defined function that represents the situation.

  4. how do you answer this question, an air conditioning salesperson receives a base salary of $2850 per month plus a commission. the commission is 2% of the sales up to and including $2500 for the month and 5% of the sales over $2500 for the month.

    • Thanks for writing! This could be a piece-wise function (and I think you meant 25000 instead of 2500?):
      y = 2850 + .02x; 0 is less than or equal to x is less than or equal to 25000
      y = 2850 + .05x; x is greater than 25000
      Does that make sense? Lisa
      (sorry, I had to spell out the inequalities since they didn’t show up right)

  5. How would u write a pieceiwse functions for x=5 and x=-5 what would be the inequality? Is it different then y=5and y=-5??i know vertical should be different than horizontal.

Leave a Reply

Your email address will not be published. Required fields are marked *