Inequalities and Piecewise Functions

How to Evaluate a Piecewise Function

To evaluate a piecewise function at x = a, first find which condition a satisfies, then substitute a into that piece’s formula only. At a boundary value, check the inequality signs: the piece with ≤ or ≥ at that point is the one to use. If no piece includes a, the function is undefined there.

Piecewise graph with pieces 2x for x < 1, 3 for 1 ≤ x < 4 and x − 2 for x ≥ 4, showing f(−1) = −2, f(1) = 3 and f(4) = 2.

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

Open the Piecewise Function Calculator

The two-step rule

  1. Locate: which condition does the input satisfy?
  2. Substitute: use only that piece’s formula.

Never average pieces or use a neighbouring formula, even if the input is very close to a boundary.

Worked example

f(x) = 2x if x < 1;   3 if 1 ≤ x < 4;   x − 2 if x ≥ 4
Input Which condition? Formula Value
f(−1) −1 < 1 2x −2
f(0.5) 0.5 < 1 2x 1
f(1) 1 ≤ 1 < 4 3 3
f(2.7) 1 ≤ 2.7 < 4 3 3
f(4) 4 ≥ 4 x − 2 2
f(10) 10 ≥ 4 x − 2 8

The bold rows are boundary values — the ones most often answered wrongly.

Try it in the calculator
Graph of the three-piece function with x = 1 and x = 4 marked; at each boundary the closed dot shows which piece gives the value.
At a boundary, the closed dot tells you the value.
Text description of this figure

Graph of the three-piece function with x = 1 and x = 4 marked; at each boundary the closed dot shows which piece gives the value.

  1. x = 1 satisfies 1 ≤ x < 4, so f(1) = 3.
  2. x = 4 satisfies x ≥ 4, so f(4) = 4 − 2 = 2.
  3. Open circles are never the function’s value.

Boundary values

At x = 1, the first piece says x < 1, which 1 does not satisfy; the second says 1 ≤ x, which it does. So f(1) = 3, not 2·1 = 2. On the graph, (1, 2) is an open circle and (1, 3) is a closed dot.

At x = 4, the middle piece says x < 4 (excludes 4) and the last says x ≥ 4 (includes it). So f(4) = 4 − 2 = 2.

Try it in the calculator

Reading values from a graph

  1. Find the input on the x-axis.
  2. Move vertically until you hit the graph.
  3. If you land on an open circle, keep looking: the value is the closed dot (or curve) at the same x.
  4. If there is nothing at that x, the function is undefined there.

Evaluating expressions with piecewise functions

Sometimes you need several values: f(0) + f(5) = 0 + 3 = 3. Or a composition: f(f(0.5)) = f(1) = 3. Evaluate the inner value first, then locate the piece for the result.

Common mistakes

  • Using the formula of the piece that “looks right” on the graph without checking the inequality.
  • Treating an open circle as the value.
  • Substituting into every piece and listing several answers. A function has one output.
  • Overlooking gaps where no piece applies.

For whether the pieces join up, see continuity at piecewise boundaries.

Questions

What if the value matches no condition?

Then the function is undefined at that x — it is not in the domain. The calculator reports 'no branch includes this x'.

Can I read values from the graph instead?

Yes: go to the x-value and use the closed dot or the curve directly above or below it. Ignore open circles.

What about a value like f(1.0001)?

Decide the piece using the inequalities exactly: 1.0001 satisfies 1 ≤ x < 4, so f(1.0001) = 3.

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