Inequalities and Piecewise Functions

Piecewise Functions: Definition, Notation and Graphs

A piecewise function uses different formulas on different intervals of x. To graph one, draw each formula only on its own interval, then mark each endpoint with a closed dot if that x is included (≤ or ≥) or an open circle if it is excluded (< or >). Each x must belong to exactly one piece.

Piecewise function f(x) = x + 2 for x < 1 and f(x) = −x + 5 for x ≥ 1, with an open circle at (1, 3) on the left piece and a closed dot at (1, 4) on the right piece.

Check it yourself: every example here can be loaded into the Piecewise Function Calculator.

Open the Piecewise Function Calculator

Reading the notation

f(x) = x + 2   if x < 1     f(x) = −x + 5   if x ≥ 1

Read it as two instructions: when x is less than 1, use x + 2; when x is 1 or more, use −x + 5. The conditions on the right split the x-axis into intervals; each interval gets its own formula, called a piece or branch.

Open and closed endpoints

Condition at the endpoint Symbol Marker
strictly less or greater < or > open circle ○ (not included)
less or greater or equal ≤ or ≥ closed dot ● (included)

At x = 1 above, the first piece has x < 1, so its endpoint (1, 3) is open. The second has x ≥ 1, so (1, 4) is closed. Therefore f(1) = 4.

How to graph a piecewise function

  1. Draw each formula lightly as if it applied everywhere.
  2. Keep only the part over its interval; erase the rest.
  3. Mark each endpoint: compute the formula at the endpoint and draw ○ or ●.
  4. Check that every x in the domain is covered once and only once.
Piecewise function with pieces −1 for x < 0, x² for 0 ≤ x ≤ 2 and 6 − x for x > 2: a horizontal ray ending in an open circle at (0, −1), a parabola from a closed dot at (0, 0) to a closed dot at (2, 4), and a line starting with an open circle at (2, 4).
Draw each formula only on its interval; then fix every endpoint.
Text description of this figure

Piecewise function with pieces −1 for x < 0, x² for 0 ≤ x ≤ 2 and 6 − x for x > 2: a horizontal ray ending in an open circle at (0, −1), a parabola from a closed dot at (0, 0) to a closed dot at (2, 4), and a line starting with an open circle at (2, 4).

  1. Piece 1: y = −1 for x < 0 → ends with an open circle at x = 0.
  2. Piece 2: y = x² for 0 ≤ x ≤ 2 → closed dots at both ends.
  3. Piece 3: y = 6 − x for x > 2 → starts at (2, 4), but that point already belongs to piece 2.
Try it in the calculator

Worked example

Graph f(x) = x + 2 for x < 1 and −x + 5 for x ≥ 1.

  1. Piece 1: the line y = x + 2, kept to the left of x = 1. At x = 1 it would give 3, so draw an open circle at (1, 3).
  2. Piece 2: the line y = −x + 5, kept from x = 1 to the right. At x = 1 it gives 4: closed dot at (1, 4).
  3. The graph jumps from height 3 to height 4 at x = 1.
Try it in the calculator

Where piecewise functions appear

  • Absolute value: |x| is −x for x < 0 and x for x ≥ 0. See absolute value functions.
  • Pricing: shipping costs $5 for orders under $50 and is free from $50 up.
  • Tax brackets and phone plans with different rates above a threshold.
  • Step functions like the floor function, which jump at every integer.

The domain of a piecewise function

The domain is the union of all the intervals. If the pieces leave a gap — say one is x < 0 and the next is x > 2 — the function is undefined between 0 and 2. The piecewise function calculator warns about gaps and overlaps.

Common mistakes

  • Drawing the whole line for each piece.
  • Using the wrong marker. Check each sign separately.
  • Overlapping intervals, such as x ≤ 1 and x ≥ 1. That gives x = 1 two outputs, so it is not a function.
  • Computing the endpoint value with the wrong formula.

Next: evaluating piecewise functions and continuity at piecewise boundaries.

Questions

Is a piecewise function one function or several?

One function. It just uses a different rule on each part of its domain, like a tax table with different rates for different incomes.

Can two pieces share an endpoint?

They can meet at the same x, but only one of them may include it; otherwise that x would have two outputs.

Does the graph have to be connected?

No. Pieces can jump. Whether they connect is the question of continuity, covered in a separate guide.

Graph your own example with the Piecewise Function Calculator — free, in your browser.

Try it now

Sources and further reading

Worked examples and figures were produced and checked with the Graphing Calculator Lab engine. See the editorial policy.

Related guides

More in Inequalities and Piecewise Functions · All guides