Learn
Lesson · Lines, Functions and Graphs · Functions

Piecewise Functions

A piecewise function splits its domain into pieces and gives a separate formula on each. It is one function, not several: the conditions decide which formula applies, and no input may receive conflicting outputs.

-x - 1 if x < -1 f(x) = x^2 if -1 <= x < 2 8 - 2x if x >= 2 overlap is safe only where the formulas agree
One function in three lines

Core ideas

What this lesson establishes

The definition in “What a Function Is” says nothing about a function being given by a single formula. It never did; this lesson takes the permission.

1

The conditions do the choosing

To evaluate, first read the conditions and find the one your input satisfies; only then use the matching formula. Evaluating first and checking the condition afterwards produces an answer from the wrong branch, and it will look reasonable.

2

The pieces must not conflict

If two conditions accept the same input and the formulas disagree there, the rule assigns two outputs and is not a function. Watch the endpoints: x ≤ 3 and x ≥ 3 overlap at 3, while x < 3 and x ≥ 3 do not. If overlapping formulas agree wherever they overlap the rule is still a function, but exclusive conditions make that fact visible.

3

A gap is legal; it just shrinks the domain

x < 3 paired with x > 3 defines a perfectly good function whose domain omits 3. That is a domain statement, not an error. Only an overlap with disagreeing values breaks the definition.

The material

Reading, evaluating and drawing a piecewise rule

The notation, the endpoint discipline, and what happens where two pieces meet.

Definition · Piecewise function

A piecewise function is defined by splitting its domain into pieces and giving a formula for each piece. The cleanest definition uses conditions that partition the domain, so each input selects exactly one piece. Overlap is also legal when every formula that applies gives the same output; conflicting outputs are what violate the function definition.

The most familiar example was written down long before the notation was: absolute value. |x| is x when x is at least zero and −x when x is negative, which is two formulas and a condition. “Absolute Value” in Foundations of Algebra called the two cases a definition; the piecewise brace is that definition typeset.

x if x >= 0 |x| = -x if x < 0 |-7| = -(-7) = 7 the second line, because -7 < 0 | 7| = 7 the first line

Note that the second formula, −x, produces positive outputs. It looks as though it should produce negative ones, and that reading is what makes |x| = −x seem wrong. The minus sign is applied to an input that is already negative.

A three-piece example

Take the function in the box at the top of this page: −x − 1 below −1, x² from −1 up to but not including 2, and 8 − 2x from 2 upward. The conditions cover every real number once, so the domain is every real number.

f(-3) = -(-3) - 1 = 2 -3 < -1 first piece f(-1) = (-1)^2 = 1 -1 <= -1 < 2 second piece f( 0) = 0^2 = 0 second piece f( 2) = 8 - 2(2) = 4 2 >= 2 third piece f( 5) = 8 - 2(5) = -2 third piece the wrong branch at x = -1: 8 - 2(-1) = 10 condition fails

The last line is the error this lesson exists to prevent. 10 is a real number produced by a real formula belonging to this very piecewise definition, and nothing about it looks suspect. It is not f(−1), because the condition x ≥ 2 rules that branch out. The number 10 is in fact produced elsewhere by this function; branch selection decides the value at the requested input, not whether the number appears anywhere in the range.

What happens at a join

At x = −1 the two neighbouring formulas disagree. Approaching from the left, −x − 1 heads toward 0; the value the function actually takes there is (−1)² = 1. The graph steps up by 1, and it is drawn with an open circle at (−1, 0) and a filled circle at (−1, 1).

At x = 2 they agree. The left formula x² heads toward 4, and the right formula gives 8 − 2(2) = 4. The two pieces meet, so the graph connects with no break and no circles are needed. Whether a join is a step or a connection is settled by arithmetic, not by how the formulas look.

join at x = -1 left formula -x - 1 -> 0 value used x^2 -> 1 step of 1 join at x = 2 left formula x^2 -> 4 value used 8 - 2x -> 4 they meet

Endpoints, and where the dot goes

  • A filled circle marks a point the function attains. Every input in the domain gets exactly one filled circle in the whole picture.
  • An open circle marks a point the graph approaches but does not include, because the condition on that piece excluded the endpoint.
  • A vertical stack of two different filled circles is impossible. Two filled circles above the same input would be two outputs, and the vertical line test from “What a Function Is” rules it out on sight. Two pieces that include the same identical point still contribute only one point.
Example · Overlap, gap, and neither

{x + 1 if x ≤ 3; 2x if x ≥ 3} is not a function: at 3 the first line says 4 and the second says 6. {x + 1 if x < 3; 2x if x > 3} is a function whose domain omits 3. {x + 1 if x ≤ 3; 2x if x > 3} is a function on every real number. Three rules, one symbol apart, and only the first is broken.

An overlap is harmless when the formulas happen to agree on it. {2x if x ≤ 3; x + 3 if x ≥ 3} names 3 twice, but both lines give 6, so each input still has one output. This is worth knowing and not worth relying on: writing the conditions so they cannot overlap removes the need to check.

Interactive

Piecewise definitions

Open and closed endpoints, and the joins between pieces

A function
fthe second curvedashed: y = x, or a discarded halfwhere it fails

Method

Evaluating and sketching a piecewise rule

The order is condition, then formula. Reversing it is the whole error.

1

Check the conditions cover the input once

Before anything else, confirm that the pieces do not overlap and see where they leave gaps. A gap tells you the domain; an overlap with disagreeing formulas tells you the rule is not a function.

2

Find the condition your input satisfies

Compare the input against each condition in turn. Write down which piece won before evaluating anything, so the choice is a decision rather than an assumption.

3

Evaluate only the matching formula

The other formulas are not merely unhelpful, they are not part of the answer. At x = −1 the third formula returns 10, but its condition fails, so 10 is not f(−1).

4

At each join, evaluate both neighbours

Compute the left formula and the right formula at the cut point. Equal values mean the graph connects; different values give the size of the step, and tell you which endpoint gets the open circle.

Which piece, and what happens there

Score 0 / 0

One three-piece function, evaluated and joined

The function from the top of the page, at six inputs and both of its joins.

-x - 1 if x < -1 f(x) = x^2 if -1 <= x < 2 8 - 2x if x >= 2 input condition met formula value ----- ------------- ------- ----- -3 -3 < -1 -(-3) - 1 2 -2 -2 < -1 -(-2) - 1 1 -1 -1 <= -1 < 2 (-1)^2 1 0 -1 <= 0 < 2 0^2 0 2 2 >= 2 8 - 2(2) 4 5 5 >= 2 8 - 2(5) -2 joins x = -1 left -x - 1 -> 0 open circle at (-1, 0) value x^2 -> 1 filled circle at (-1, 1) the graph steps up by 1 x = 2 left x^2 -> 4 value 8 - 2x -> 4 the pieces meet; no circles

The row for x = −1 is the one to check twice. It sits on the boundary, and the condition that wins is the one written with ≤. Change that symbol to < and −1 leaves the domain entirely.

The two joins behave differently for a reason visible in the arithmetic and nowhere else. −x − 1 and x² disagree at −1; x² and 8 − 2x agree at 2. Nothing about the shapes of the formulas predicts this, so both joins have to be computed.

Reading a range off the picture: the third piece runs from 4 downward without bound, and the first piece runs from just above 0 upward without bound, so between them every real number is produced. The range is every real number, even though no single piece has that range.

For a faded rehearsal, define g(x) by 2x + 1 for x < 0, x² + 1 for 0 ≤ x < 3, and 7 − x for x ≥ 3. The condition for x = 0 is supplied: use the middle piece. Evaluate at −2, 0 and 3; compute both formulas at each join; then draw the open and filled endpoints and state which join connects and which jumps.

Common mistakes

1
Evaluating first and checking the condition afterwardsSubstituting into whichever formula is nearest gives a plausible number from the wrong branch. At x = −1 the third formula returns 10, but that is not f(−1) because the condition fails. Read the conditions first.
2
Writing both endpoint conditions with a non-strict signx ≤ 3 beside x ≥ 3 claims 3 twice. If the formulas disagree there, the rule is not a function at all. Prefer exactly one included endpoint; if both include it, verify that the outputs agree.
3
Assuming a join is a breakTwo different formulas can meet. At x = 2, x² and 8 − 2x both give 4, so the graph connects and neither endpoint needs a circle. Evaluate both sides rather than drawing a jump because the formulas look different.

Check your understanding

✓
Finish when you evaluate by reading the condition first, and can say at each join whether the graph steps or connects, with the two numbers that settle it.

Given a two- or three-piece definition you should evaluate at any input including the cut points, decide whether the conditions partition the domain or agree on any overlap, sketch the graph with open and filled circles in the right places, and state the domain and range. Recognising |x| as a piecewise function is the check that the idea has landed.

Note: Piecewise definitions are how a domain restriction becomes visible in a formula, and “Inverse Functions” uses exactly that device: a function is cut down to a piece on which it can be inverted. “Transformations of Graphs” leaves formulas alone and asks a different question: what moving the graph does to the rule.

Kept in this browser only, for you. Nothing is sent anywhere and nothing checks it. Carry it to another device.

Feedback and recommendations

Something to change about this lesson? Write it down, tick it off when it is handled, and export the list when you want to act on it. Kept in this browser only: nothing is sent anywhere, and nobody is notified.

No recommendations yet for this lesson.