Ⅳ Functions · Stage 21 — Linear Functions · 21.6 Piecewise FunctionsAll lessons →
Stage 21 · Linear Functions

21.6  Piecewise Functions: A Different Rule for Each Stretch

Split the domain into stretches, give each its own line, and mind the dots at the joints.

Ages 12–15 · Reasoning, one step at a time
Each stretch of x follows its own rule; open and filled dots at the joints show exactly which piece owns each endpoint. Here f jumps at x = 1 (open at 2, filled at 4) and joins continuously at x = 3.

Some rules change partway through. A parking garage is free for the first half-hour, then charges by the hour; a phone plan is flat up to a data cap, then bills per gigabyte. One single formula can't capture a rule that switches, so we write it in pieces — a different line for each stretch of the domain, stitched together with one big brace. This lesson reads, writes, and graphs piecewise functions, minds the open and filled dots at the joints, and ends with the most famous two-piece function of all: absolute value.

21.6.1 Why split into pieces

Picture a parking garage: free for the first 30 minutes, then $2 per hour. For the first half-hour the cost is locked at $0 — no rule about a rate applies yet. After that, the cost climbs steadily at $2 an hour. Those are two different rules governing two different stretches of time, so one straight line cannot describe the whole story.

Try to force a single line through it and you'll be wrong on one stretch or the other: a line that's flat at 0 keeps the cost at 0 forever, and a line that rises from the start charges you before 30 minutes are up. The honest description needs a rule per stretch — flat at first, then rising.

Parking cost against time: flat at $0 for the first half-hour, then rising $2 per hour. The rule changes at the joint — so the graph is built from two pieces.
Key idea

When a rule changes partway, no single formula will do. Describe it in pieces: split the domain into stretches and give each stretch its own rule.

21.6.2 How to write a piecewise function

We collect the pieces under one big brace, and beside each rule we write the stretch of x it governs. Our running example for the rest of the lesson is

f(x) = {
x + 1ifx < 1
4if1 ≤ x < 3
−x + 7ifx ≥ 3
Read it row by row: on x < 1 use x + 1; on 1 ≤ x < 3 use the constant 4; on x ≥ 3 use −x + 7.

The conditions on the right do all the bookkeeping. Notice that they tile the whole number line with no overlap and no gap: every real number x is less than 1, or between 1 and 3, or at least 3 — and never two of these at once. That is the whole requirement for a legal piecewise rule.

Watch

Every x must belong to exactly one piece — the conditions can't overlap and can't leave a gap. Mind which side of a boundary gets the and which gets the <: here x = 1 belongs to the middle piece (because 1 ≤ x), not to the first.

21.6.3 Drawing the graph of a piecewise function

To graph a piecewise function, draw each piece only over its own stretch — a segment or a ray, never the whole infinite line. The interesting moments are the joints, where one stretch ends and the next begins. At a joint you must decide which piece includes the endpoint:

a filled dot marks the piece that owns the endpoint (its condition uses ≤ or ≥), and an open dot marks a piece that approaches but excludes it (its condition uses < or >).

Where the two pieces arrive at the same height, the graph is continuous — one filled dot is enough, the picture has no break. Where they arrive at different heights, there is a jump: an open dot at the height the lower piece never reaches, a filled dot at the height that is actually taken.

On our function, walk through the two joints. At x = 1: the left piece x + 1 climbs toward 2 but stops short (its condition is x < 1, so it never reaches x = 1) — an open dot at (1, 2); the middle piece is the constant 4 starting right at x = 1 — a filled dot at (1, 4). The two heights differ, so x = 1 is a jump. At x = 3: the middle piece sits at 4 and the right piece −x + 7 gives −3 + 7 = 4 too — same height, so the graph is continuous there.

Try it Walk a point across the three pieces
Drag x and watch which piece lights up. At each joint, see who gets the filled dot and who gets the open one.
x
Key idea

At a joint, open = excluded, filled = included. Same height on both sides ⇒ continuous (one filled dot); different heights ⇒ a jump (open below, filled above).

21.6.4 Plugging in by interval to find a value

Evaluating a piecewise function is a two-step move: first find which stretch x falls in, then use that stretch's rule. Reach for the wrong piece and you'll get a confident, wrong answer. Work the three sample inputs on our function:

f(0): since 0 < 1, use x + 1 → 0 + 1 = 1.
f(2): since 1 ≤ 2 < 3, use the constant 44.
f(5): since 5 ≥ 3, use −x + 7 → −5 + 7 = 2.

Three inputs landing in three stretches: x = 0 in the rising piece, x = 2 in the flat piece, x = 5 in the falling piece — each read off its own rule.
Watch

Check the boundary's / < before you pick the rule. Here f(1) = 4, not 2 — because x = 1 satisfies 1 ≤ x < 3 and so belongs to the middle piece.

21.6.5 How absolute value connects to pieces

The most famous piecewise rule of all is hiding in plain sight: absolute value. The number |x| keeps a number as-is when it's non-negative and flips its sign when it's negative. That is exactly a two-piece rule:

|x| = {
xifx ≥ 0
−xifx < 0
|x| is one rule on each side of zero: x when x ≥ 0, −x when x < 0.

Graph the two pieces and you get a V: the ray y = x for x ≥ 0 climbing to the right, and the ray y = −x for x < 0 climbing to the left, meeting at the origin. Check a few values: |3| = 3, |−4| = 4, |0| = 0. And the same V can be slid sideways — y = |x − 2| is the very same V with its corner moved to sit at x = 2.

Try it The V of y = |x| is two arms
Slide x left and right of zero. The point rides the left arm (y = −x) or the right arm (y = x).
x
Key idea

Absolute value is the simplest piecewise rule: |x| = x for x ≥ 0 and −x for x < 0. Its graph is a V stitched at the origin.

Recap

A piecewise function uses a different rule on each stretch of the domain, collected under one big brace. The conditions must tile the domain — every x lands in exactly one piece, with no overlap and no gap, so mind the versus < at every boundary.

To graph it, draw each piece only over its own stretch and decide the joints: a filled dot for the piece that owns the endpoint, an open dot for the piece that excludes it. Same height on both sides ⇒ continuous; different heights ⇒ a jump. To evaluate, first find the stretch x belongs to, then use that stretch's rule. And absolute value is the simplest piecewise function of all: |x| = x for x ≥ 0, −x for x < 0 — a V meeting at the origin. Next, in 21.7, we turn every linear idea loose on the real world.

Exercises

  1. For the hero function f(x) = { x + 1 if x < 1 ; 4 if 1 ≤ x < 3 ; −x + 7 if x ≥ 3 }, find f(−1), f(2), and f(4).
    Answer

    f(−1): −1 < 1, so use x + 1 → −1 + 1 = 0. f(2): 1 ≤ 2 < 3, so the constant piece → 4. f(4): 4 ≥ 3, so −x + 7 → −4 + 7 = 3.

  2. For the same f, is there a jump at x = 1? If so, what are the two heights, and which dot is filled?
    Answer

    Yes. The left piece x + 1 approaches 2 (open dot, since x < 1 never reaches 1); the middle piece gives 4 (filled dot, since 1 ≤ x owns it). The heights 2 and 4 differ, so it's a jump — open at 2, filled at 4.

  3. Write the absolute value |x| as a piecewise function.
    Answer

    |x| = { x if x ≥ 0 ; −x if x < 0 }. When x is non-negative we keep it; when x is negative we flip its sign so the output is non-negative.

  4. Evaluate |−7| and |6 − 10|.
    Answer

    |−7| = 7 (−7 < 0, so flip the sign). For |6 − 10|, simplify inside first: 6 − 10 = −4, so |−4| = 4.

  5. At a joint where both pieces give the same height, which dot do we draw — and what does that tell us about the graph there?
    Answer

    One filled dot. Both pieces reach the same height, so there's no jump — the graph is continuous at that joint, passing through it without a break.

  6. Parking is free for the first 30 minutes, then $2 per hour. Is the cost function continuous at the 30-minute joint?
    Answer

    Yes. Just before 30 minutes the cost is still $0, and the second rule starts charging from $0 at exactly 30 minutes — both pieces meet at the same height ($0), so there's no jump. (There is a kink, where the graph bends from flat to rising, but no break.)

🎯 Quick check

Six questions to lock it in. Tap the answer you think is right.

§ For teachers and parents

This lesson introduces piecewise-defined functions as the natural next step once linear functions are fluent: a rule that switches partway needs a separate line on each stretch of the domain. It builds toward CCSS F-IF.C.7b (graph piecewise-defined functions, including step and absolute-value functions), F-IF.A.2 (evaluate functions, including piecewise, for inputs in their domains), and 6.NS.C.7c (absolute value as magnitude).

Three misconceptions to head off: (1) using the wrong piece at a boundary — students must read the ≤ versus < before choosing a rule; have them say aloud "x = 1 satisfies 1 ≤ x, so the middle piece owns it." (2) Drawing the whole line instead of just its stretch — each piece is a segment or ray, clipped to its interval. (3) Filling a dot that should be open at a jump — the open dot marks the height a piece approaches but never reaches. The two interactive figures let a learner walk x across the joints and watch the active piece, the dot type, and the computed value update together — the safest way to build the "find the stretch first, then apply its rule" habit.

eastmath.com · Stage 21 · 21.6 Piecewise Functions · Reasoning, one step at a time