Allday Education

Piecewise and Step Functions

A piecewise function uses different rules on different parts of the domain. One formula might apply when x<0x < 0 and a different one when x0x \geq 0 — the conditions written next to each piece tell you which rule is in charge for any given input.

Evaluating one is a two-step routine: first decide which condition your input satisfies, then use only that piece and ignore the rest. Students who miss piecewise questions almost always skip the first step and grab the wrong rule.

How to evaluate a piecewise function

Take f(x)={x+4if x<12x3if x1f(x) = \begin{cases} x + 4 & \text{if } x < 1 \\ 2x - 3 & \text{if } x \geq 1 \end{cases} and find f(2)f(-2). Check the condition first: 2<1-2 < 1, so the top rule applies, and f(2)=2+4=2f(-2) = -2 + 4 = 2. For f(5)f(5): since 515 \geq 1, the bottom rule applies, and f(5)=2(5)3=7f(5) = 2(5) - 3 = 7.

Pay close attention at the boundary. If the input lands exactly where the rules change, the inequality signs decide: a piece with x1x \geq 1 includes x=1x = 1, while a piece with x<1x < 1 does not. Exactly one piece should claim each input.

Step functions

A step function is a piecewise function that is constant on each piece, so its graph looks like stair steps — flat segments at different heights. The graph below shows one: every input from 00 up to (but not including) 22 gives an output of 22, and every input from 22 up to 44 gives an output of 44.

The dots on the graph carry real information. A closed dot means that endpoint is included in the piece; an open dot means it is not. Reading f(2)f(2) on the graph below, the point jumps to the higher step: the open dot at the end of the lower segment says x=2x = 2 belongs to the upper one, so f(2)=4f(2) = 4.

1234512345xy

Where you meet these in real life

Step functions model anything priced in chunks: parking that charges per hour or any part of an hour, shipping tiers by weight, movie tickets by age bracket. The input can vary smoothly, but the output jumps between fixed values — which is exactly what the stair-step graph shows.

Worked examples

Example 1: pick the right piece

Find f(2)f(-2) for f(x)={x+4if x<12x3if x1f(x) = \begin{cases} x + 4 & \text{if } x < 1 \\ 2x - 3 & \text{if } x \geq 1 \end{cases}

Check the condition: 2<1-2 < 1, so use the top rule
Substitute into x+4x + 4f(2)=2+4f(-2) = -2 + 4
Simplifyf(2)=2f(-2) = 2

Answer: f(2)=2f(-2) = 2

Example 2: an input at the boundary

Find f(4)f(4) for f(x)={2xif x<4x1if x4f(x) = \begin{cases} -2x & \text{if } x < 4 \\ x - 1 & \text{if } x \geq 4 \end{cases}

Check the condition: 444 \geq 4 is true, so use the bottom rule
Substitute into x1x - 1f(4)=41f(4) = 4 - 1
Simplifyf(4)=3f(4) = 3

Answer: f(4)=3f(4) = 3

Example 3: read a step function's graph

Using the step function graphed above, find f(1.5)f(1.5) and f(3)f(3).

Locate x=1.5x = 1.5: it sits on the lower stepf(1.5)=2f(1.5) = 2
Locate x=3x = 3: it sits on the upper stepf(3)=4f(3) = 4

Answer: f(1.5)=2f(1.5) = 2 and f(3)=4f(3) = 4

Try one yourself

Common questions

How do I know which piece to use?

Test your input against each condition. Exactly one should be true — use that piece and ignore the others. Never plug the input into more than one rule.

What happens right at the boundary between two pieces?

The inequality signs decide. A condition like x2x \geq 2 claims the boundary point; x<2x < 2 does not. On a graph, the same information shows up as closed dots (included) and open dots (excluded).

Is a piecewise function still a function?

Yes, as long as each input gets exactly one output. The conditions are written so the pieces never overlap — every xx belongs to one and only one rule.

What makes a step function different from other piecewise functions?

Each of its pieces is a constant, so the graph is a set of flat segments at different heights instead of slanted lines. The output jumps between values rather than changing gradually.

Want the video version?

Allday Everyday Math has video lessons, practice, and an AI tutor for every topic, Pre-Algebra through Algebra 2.

Try it for $1