Algebra 1 · F.IF.C.7 · F.IF.C.7B

Graphing a piecewise function

A rule changes partway along the number line. How do you draw a graph that obeys each formula only where that formula is in charge?

Where you are 4 in Piecewise functions

When you reach for it

A piecewise function hands each input to one formula, chosen by a condition such as x < 1 or x \ge 1. Evaluating it deals with one input at a time. Graphing it shows every input at once: where the function rises and falls, where the formula changes, and whether the graph carries on unbroken at that change or leaps to a new height. You reach for it whenever a rule comes in pieces and you want to see the whole function, or read off its domain and range.

The procedure

Day 1: each piece over its own inputs

Take

f(x) = \begin{cases} x + 1 & \text{if } x < 1 \\ 4 - x & \text{if } x \ge 1 \end{cases}

The conditions split the x-axis at x = 1, the boundary. Every input to the left of 1 goes to x + 1, and every input from 1 onwards goes to 4 - x. So the graph of f is two familiar graphs, each cut down: the part of the line y = x + 1 above x < 1, and the part of the line y = 4 - x above x \ge 1. Nothing else. Drawing either line in full would claim outputs the rule never gives.

Each piece is a linear function, so two points fix it (Graphing a line from its equation). The most useful point is at the boundary, so put x = 1 into each formula, even the one whose condition leaves 1 out. The first gives 1 + 1 = 2, so that piece heads toward (1, 2). The second gives 4 - 1 = 3, so that piece starts at (1, 3).

The inequality decides how each end is drawn. The condition x \ge 1 includes 1, so (1, 3) is on the graph: a closed dot, filled in. The condition x < 1 leaves 1 out, so the first piece comes as close to (1, 2) as you like without reaching it: an open dot, a hollow ring. This is the convention of inequalities on the number line, for the same reason: \le and \ge include the end, < and > do not. One more point on each piece fixes its direction, (-1, 0) on the first and (3, 1) on the second. Each condition has only one end, so each piece runs on for ever, shown by an arrow.

x y −4 −2 2 4 −2 2 4 6
Figure 1Dashed, the whole lines y = x + 1 and y = 4 - x. Solid, the part of each that the rule keeps.

Join or jump. Here the pieces reach the line x = 1 at different heights, 2 and 3, so the graph jumps: you lift the pen. When the two boundary values are equal, the closed dot of one piece lands on the open dot of the other and fills it, and the graph joins: one unbroken path, usually with a corner at the boundary. A graph made only of straight pieces, joined or not, is called piecewise linear.

The vertical line test at a boundary. Away from the boundary, each vertical line meets one piece once. At the boundary the Testing graphs and equations for functions still allows only one point, so the column x = 1 may hold at most one closed dot. Here it holds exactly one, (1, 3); the open dot (1, 2) is not a point of the graph. If both conditions included 1 and the formulas gave different values there, two closed dots would be stacked and the rule would not be a function (Example 3).

Day 2: other pieces, and domain and range

A piece need not be a slanted line. A constant piece such as y = -2 is horizontal. A quadratic piece is part of a parabola: plot its two ends, open or closed as before, and its vertex if the vertex lies inside its condition, since that is where the piece turns. A few more points give the curve its shape.

The domain is every input that some condition covers, so it is the conditions put together, written in Interval and set-builder notation with \cup between stretches that do not touch. When no condition covers some stretch of inputs, the graph has a gap there: no point sits above those inputs. The range is every output some piece reaches, so find each piece’s outputs and put them together. On the graph, both are the shadows on the two axes, as in Domain and range from a graph. The boundary dots need care: the height of an open dot is in the range only if some other part of the graph reaches it.

Worked examples

Example 1

Day 1: two lines that jump

Graph

g(x) = \begin{cases} -x + 2 & \text{if } x \le -1 \\ 2x - 1 & \text{if } x > -1 \end{cases}
Solution

The boundary is x = -1. Put it into both formulas. The first gives -(-1) + 2 = 3, and its condition x \le -1 includes -1, so (-1, 3) is a closed dot. The second gives 2(-1) - 1 = -3, and x > -1 leaves -1 out, so (-1, -3) is an open dot.

One more point on each piece: x = -3 gives -(-3) + 2 = 5, so (-3, 5) is on the first, and x = 1 gives 2(1) - 1 = 1, so (1, 1) is on the second. Draw the first line from (-1, 3) through (-3, 5) and on to the left with an arrow, since x \le -1 has no left end. Draw the second from (-1, -3) through (1, 1) and on to the right.

x y −4 −2 2 4 −2 2 4 6
Figure 2The graph of g in Example 1. It jumps at x = -1.

The boundary values are 3 and -3, so the graph jumps down by 6 at x = -1. The column x = -1 holds one closed dot, so the graph passes the vertical line test, and g(-1) = 3.

Example 2

Day 1: two lines that join

Graph

h(x) = \begin{cases} x + 3 & \text{if } x < 0 \\ 3 - 2x & \text{if } x \ge 0 \end{cases}
Solution

At the boundary x = 0 the first formula gives 0 + 3 = 3 and the second gives 3 - 2(0) = 3. The first piece would end at an open dot (0, 3), and the second starts at a closed dot in the very same place. The closed dot fills the open one, so (0, 3) is on the graph and the pieces meet there with no break.

Further points: (-3, 0) on the first piece and (2, -1) on the second. The graph rises with slope 1 up to (0, 3), turns there, and falls with slope -2.

x y −4 −2 2 4 −2 2 4
Figure 3The graph of h in Example 2. The pieces join at (0, 3).

The graph joins, so it can be drawn without lifting the pen. Because the pieces agree at 0, the graph would be exactly the same if the rule said x \le 0 and x > 0: the point (0, 3) would then come from the first piece instead of the second.

Example 3

Day 1: a boundary that both conditions include

In each rule both conditions include x = 1. Decide whether it defines a function, and graph it.

u(x) = \begin{cases} 2x & \text{if } x \le 1 \\ x + 1 & \text{if } x \ge 1 \end{cases}
v(x) = \begin{cases} 2x & \text{if } x \le 1 \\ x + 3 & \text{if } x \ge 1 \end{cases}
Solution

The input 1 satisfies both conditions, so both formulas claim it. A function allows that only if they give the same output.

For u: 2(1) = 2 and 1 + 1 = 2. Both pieces put a closed dot at (1, 2), which is one point drawn twice, so the input 1 still has one output and u is a function. Its graph is the line y = 2x rising through (0, 0) up to (1, 2), then the line y = x + 1 carrying on less steeply through (3, 4). It joins.

For v: 2(1) = 2 but 1 + 3 = 4. Now the column x = 1 holds two closed dots, (1, 2) and (1, 4). The line x = 1 meets the graph twice, so the input 1 has two outputs and v is not a function. Making either condition strict, for instance x > 1 on the second line, removes one dot and leaves a function whose graph jumps.

x y −2 2 4 −2 2 4 6 x y −2 2 4 −2 2 4 6 (a) (b)
Figure 4Example 3. In (a) the two closed dots coincide; in (b) the line x = 1 meets two of them.
Example 4

Day 2: a constant piece and a parabola piece

Graph p, and give its domain and range.

p(x) = \begin{cases} -2 & \text{if } x < -1 \\ x^2 - 1 & \text{if } -1 \le x < 2 \\ 5 - x & \text{if } x \ge 2 \end{cases}
Solution

There are two boundaries, x = -1 and x = 2.

The first piece gives -2 for every input left of -1: a horizontal ray at height -2, ending at an open dot (-1, -2) because x < -1 leaves -1 out.

The second piece is part of the parabola y = x^2 - 1, whose vertex is (0, -1). The condition -1 \le x < 2 contains 0, so the vertex is on this piece. Its ends: (-1)^2 - 1 = 0 gives a closed dot (-1, 0), and 2^2 - 1 = 3 gives an open dot at (2, 3). The points (1, 0) and \displaystyle \left(\frac{3}{2}, \frac{5}{4}\right) shape the curve.

The third piece is the line y = 5 - x, from a closed dot (2, 3) falling to the right through (4, 1).

x y −4 −2 2 4 −2 2 4
Figure 5The graph of p in Example 4. It jumps at x = -1 and joins at x = 2.

At x = -1 the boundary values are -2 and 0, so the graph jumps there. At x = 2 both are 3, so the closed dot fills the open one and the graph joins.

Every real number satisfies one of the three conditions, so the domain is (-\infty, \infty). For the range, take each piece’s outputs. The first gives only -2. The second runs from -1 at the vertex up toward 3, which it does not reach: [-1, 3). The third starts at 3, included, and falls without end: (-\infty, 3]. That last set already holds -2 and all of [-1, 3), so the range is (-\infty, 3], and the highest point of the graph is (2, 3).

Example 5

Day 2: a gap in the domain

Graph q, and give its domain and range.

q(x) = \begin{cases} x + 2 & \text{if } -4 \le x < -1 \\ 2x - 5 & \text{if } 3 < x \le 5 \end{cases}
Solution

No condition covers the inputs from -1 to 3, so the graph has nothing above them; q(0), for instance, does not exist.

The first piece runs from a closed dot (-4, -2) to an open dot (-1, 1), since -1 + 2 = 1 and x < -1 leaves -1 out. The second runs from an open dot (3, 1), since 2(3) - 5 = 1, to a closed dot (5, 5).

x y −4 −2 2 4 6 −2 2 4 6
Figure 6The graph of q in Example 5. Both pieces stop at an open dot at height 1.

The domain is the two conditions together, [-4, -1) \cup (3, 5]. The first piece’s outputs run from -2, reached, up to 1, not reached: [-2, 1). The second’s run from 1, not reached, to 5, reached: (1, 5]. So the range is [-2, 1) \cup (1, 5]. Both pieces come as close to height 1 as you like, yet each stops at an open dot there, so 1 is never an output. A gap in the domain does not always leave a gap in the range (Exercise 20); here the range misses a single number.

Example 6

Day 2: filling, waiting and draining a tank

A water tank starts empty. A pump fills it at 40 liters a minute for 5 minutes, nothing happens for 7 minutes, and then a drain empties it at 25 liters a minute. The water V, in liters, after t minutes is

V(t) = \begin{cases} 40t & \text{if } 0 \le t \le 5 \\ 200 & \text{if } 5 < t \le 12 \\ 200 - 25(t - 12) & \text{if } 12 < t \le 20 \end{cases}

Graph V, give its domain and range, and say what the graph shows.

Solution

The first piece runs from a closed dot (0, 0) to a closed dot (5, 200), since 40 \cdot 5 = 200. The second is flat at 200. Its condition 5 < t would leave an open dot at (5, 200), but the first piece’s closed dot already fills it; the piece ends at a closed dot (12, 200). The third starts where 200 - 25(0) = 200, so it joins too, and falls with slope -25 to 200 - 25(8) = 0, a closed dot (20, 0).

0 5 10 15 20 0 50 100 150 200 time (minutes) water (liters)
Figure 7The water in the tank in Example 6.

The domain is [0, 20], the minutes the rule describes, and the range is [0, 200], from empty to full. The graph joins at both boundaries, as it must: the amount of water cannot leap from one value to another in an instant. The flat piece is the wait, and the slopes 40 and -25 are the pump’s and the drain’s rates.

Boundaries

  • A piecewise rule defines a function only if no input gets two different outputs. Where two conditions share an input, the formulas must agree there; at a shared boundary that is the two-closed-dots test of Example 3.
  • An open dot marks a point that is not on the graph. If a closed dot of another piece sits in the same place, the point is on the graph after all.
  • A piece is drawn only over its condition. Its formula still produces numbers for other inputs, but those numbers are not outputs of this function.
  • An arrow means a piece goes on without end. A piece whose condition has two ends, such as -4 \le x < -1, gets a dot at each end and no arrow.

Where this goes next

Reading the graph backwards, from the picture to the formulas and their conditions, is Writing a piecewise rule from a graph. Rules that change at a threshold in real settings, such as charges by weight, are Piecewise functions in context. A graph made only of constant pieces, stepping at every integer, is the greatest integer function. The difference between a graph that joins and one that jumps or has a hole is made exact in Continuous graphs, jumps and holes and later in Continuity, where a jump is a place at which the left and right limits disagree.

Exercises

Day 1: graph the pieces

For each function, give the dot at each end of each piece (open or closed), one more point on each piece, and say whether the graph joins or jumps.

  1. f(x) = x + 2 for x < 1, and f(x) = -x for x \ge 1.
  2. g(x) = 2x + 1 for x \le 2, and g(x) = 9 - 2x for x > 2.
  3. h(x) = -x - 1 for x < -2, and h(x) = x + 3 for x \ge -2.
  4. \displaystyle k(x) = \frac{1}{2}x + 1 for x < 2, and k(x) = x - 4 for x \ge 2.
  5. m(x) = x + 4 for -4 \le x < 0, and m(x) = 4 - 2x for 0 \le x \le 3.

Day 1: join, jump, or not a function

  1. Without drawing, decide whether each graph joins or jumps at its boundary, and give the size of any jump. (a) 3x - 1 for x < 2, and 7 - x for x \ge 2. (b) 5 - x for x \le -1, and 2x + 3 for x > -1.
  2. Which of these rules define a function? (a) x + 1 for x \le 2, and 5 - x for x \ge 2. (b) 3 - x for x \le 0, and x - 3 for x \ge 0. (c) x for x < 0, and -x for x > 0.
  3. Find c so that the graph of the rule x + c for x < 1, and 3x - 1 for x \ge 1, joins.
  4. Find a so that the graph of the rule ax + 1 for x \le 2, and 7 - x for x > 2, joins.

Day 2: pieces that are not lines

Graph each function, then give its domain and range.

  1. f(x) = 4 - x^2 for x \le 1, and f(x) = 1 for x > 1.
  2. g(x) = 3 for x < -1, and g(x) = (x - 1)^2 - 1 for x \ge -1.
  3. s(x) = -1 for x < 0, s(x) = 1 for 0 \le x < 2, and s(x) = 3 for x \ge 2.
  4. r(x) = x^2 for -2 \le x \le 1, and r(x) = 4 - x for 1 < x < 4.

Day 2: domain and range

  1. Give the domain and range of w(x) = x + 1 for -3 \le x \le 0, and w(x) = 4 for 2 < x < 5.
x y −4 −2 2 4 −2 2 4 6 x y −4 −2 2 4 −2 2 4 6 x y −4 −2 2 4 −2 2 4 6 A B C
Figure 8Graphs A, B and C for Exercises 15 to 17.
  1. Give the domain and range of graph A.
  2. Give the domain and range of graph B.
  3. Give the domain and range of graph C.
  4. The tank of Example 6 starts another day holding 120 liters. It drains at 15 liters a minute for 4 minutes, waits 6 minutes, then the pump adds 30 liters a minute for 3 minutes: W(t) = 120 - 15t for 0 \le t \le 4, W(t) = 60 for 4 < t \le 10, and W(t) = 60 + 30(t - 10) for 10 < t \le 13. Describe the graph, check that it joins at both boundaries, and give the domain and range.

Reasoning

  1. Hildegard writes a rule whose conditions are x \le 3 and x \ge 3. Using the vertical line test, explain when that is allowed and when it is not.
  2. Give a piecewise function whose domain has a gap but whose range has none, and explain how that can happen.
  3. A rule has two linear pieces with the same slope: mx + b_1 for x < a, and mx + b_2 for x \ge a. When does its graph join? Describe the graph in each case.
  4. Eadric graphs a rule whose pieces agree at the boundary. He draws the open dot of one piece and the closed dot of the other at the same point, and says the graph has a hole there. Is he right?
Answers
  1. Jumps. First piece: open dot (1, 3), through (-2, 0), arrow to the left. Second: closed dot (1, -1), through (3, -3), arrow to the right.
  2. Joins at (2, 5): the first piece’s closed dot fills the second’s open dot. The first passes through (0, 1) and the second through (4, 1), a peak with arrows at both ends.
  3. Joins at (-2, 1), since -(-2) - 1 = 1 and -2 + 3 = 1. The first passes through (-4, 3) and the second through (0, 3): a V with its lowest point at (-2, 1).
  4. Jumps down by 4. First: open dot (2, 2), through (0, 1). Second: closed dot (2, -2), through (4, 0).
  5. Joins at (0, 4). A segment from a closed dot (-4, 0) up to (0, 4), then down to a closed dot (3, -2). No arrows, since both conditions have two ends.
  6. (a) Joins: 3(2) - 1 = 5 and 7 - 2 = 5. (b) Jumps down by 5: 5 - (-1) = 6 and 2(-1) + 3 = 1.
  7. (a) A function: both formulas give 3 at x = 2, one closed dot (2, 3). (b) Not a function: both conditions include 0, and the values 3 and -3 put two closed dots in the column x = 0. (c) A function, but neither condition includes 0: both pieces end at an open dot (0, 0), a hole, and 0 is not in the domain.
  8. c = 1. Joining needs 1 + c = 3(1) - 1 = 2.
  9. a = 2. Joining needs 2a + 1 = 7 - 2 = 5.
  10. Jumps. Part of a downward parabola with vertex (0, 4), through (-2, 0), ending at a closed dot (1, 3); then a horizontal ray at height 1 from an open dot (1, 1). Domain (-\infty, \infty), range (-\infty, 4]: the parabola piece already reaches every height up to 4, including 1.
  11. Joins. A horizontal ray at height 3 ending at an open dot (-1, 3), filled by the parabola’s closed dot (-1, 3), since (-2)^2 - 1 = 3. The parabola falls to its vertex (1, -1) and climbs for ever. Domain (-\infty, \infty), range [-1, \infty).
  12. Three horizontal pieces, like stairs: a ray to an open dot (0, -1), a segment from a closed dot (0, 1) to an open dot (2, 1), and a ray from a closed dot (2, 3). Domain (-\infty, \infty), range \{-1, 1, 3\}.
  13. Jumps at 1. Parabola from a closed dot (-2, 4) through the vertex (0, 0) to a closed dot (1, 1); then a segment from an open dot (1, 3) to an open dot (4, 0). Domain [-2, 4), range [0, 4]: the parabola gives [0, 4] and the segment (0, 3).
  14. Domain [-3, 0] \cup (2, 5), range [-2, 1] \cup \{4\}.
  15. Domain [-4, 3], range [-3, 2). The pieces give [-1, 2) and [-3, 1].
  16. Domain [-4, 4], range [-2, 2] \cup \{3\}. The flat piece gives only 3, the parabola [-2, 2].
  17. Domain (-\infty, -2] \cup (1, 4], range (-\infty, 1] \cup (2, 5].
  18. A segment from (0, 120) down to (4, 60), flat to (10, 60), then up to (13, 150). It joins, since 120 - 15(4) = 60 and 60 + 30(0) = 60. Domain [0, 13], range [60, 150].
  19. Allowed only when both formulas give the same value at 3: then both pieces put a closed dot on one point, and 3 has one output. If the values differ, the line x = 3 meets two closed dots, so 3 has two outputs and the rule is not a function.
  20. For example x for 0 \le x \le 1, and x - 2 for 3 \le x \le 4. The domain is [0, 1] \cup [3, 4], the pieces give [0, 1] and [1, 2], so the range is [0, 2]. The range is about heights, and inputs far apart can give heights that touch or overlap.
  21. At x = a the values are ma + b_1 and ma + b_2, equal exactly when b_1 = b_2. Then both pieces lie on one line and the graph is that whole line, unbroken. Otherwise the pieces are parallel and the graph always jumps, by b_2 - b_1: up if that is positive, down if negative.
  22. No. The closed dot puts the point on the graph and covers the open dot, so there is no hole. The boundary input has one output, the shared value, and the graph joins.
kg1128 · updated 2026-10-10 · CC-BY-SA-4.0