Skip to content
One hour with George, then a written plan the next working day. Book yours.

Piecewise function practice

A piecewise function switches formulas depending on which stretch of inputs you are in. To evaluate it, find which interval the input belongs to and use that rule only. To graph it, draw each rule on its own interval and mark each end as open or closed. The domain gathers every interval that has a rule, and the range is read off the finished graph.

For students and parents planning test prep or coursework: one hour with George Li, one to one by video, is $180, $200 or $160, by subject. You leave with a written plan within one working day.

Book your first session
Our own practice item
Evaluate, graph and find the range of a three-piece function

Let f(x) = 1 - x when x < 0, f(x) = 1 when 0 <= x <= 2, and f(x) = (x - 2)^2 + 1 when x > 2. Find f(-3), f(1) and f(5), then give the domain and range.

  1. For x = -3, the input is below 0, so use 1 - x: f(-3) = 1 + 3 = 4.
  2. For x = 1, the input is between 0 and 2, so f(1) = 1.
  3. For x = 5, the input is above 2, so f(5) = 9 + 1 = 10.
  4. Check the joins. At 0 the left rule gives 1 - 0 = 1 and the middle rule is 1, so there is no jump. At 2 the middle rule is 1 and the right rule gives 0 + 1 = 1, so there is no jump there either.
  5. The pieces cover every real number, so the domain is all reals.
  6. The left piece takes values above 1, the middle piece equals 1, and the right piece takes values above 1, so the smallest output is 1 and there is no largest.

Answer f(-3) = 4, f(1) = 1, f(5) = 10; domain all reals, range from 1 up, written [1, infinity).

Original problem by George Li Tutoring; the method follows the piecewise-function sections of OpenStax, Algebra and Trigonometry 2e

How do you read a piecewise rule?

The conditions on the right of each line decide which formula applies. Treat them like a set of doors with a number on each, and you may only walk through the one your input fits. A boundary value belongs to exactly one piece, so look closely at which inequality has the equal sign. At x = 0 above, the condition 0 <= x makes the middle rule the one to use, even though the left rule would also give 1.

Three habits prevent most errors. Write the interval of each piece before computing anything. Substitute into one rule only. Test the boundaries to see whether the graph is joined or has a jump.

Which special pieces appear most often?

Which special pieces appear most often?
FunctionRule in wordsSample valuesRange
Absolute value of x minus 3x - 3 when x >= 3, otherwise 3 - xThe value at x = -1 is 4All values 0 and up
Sign function-1 below zero, 0 at zero, 1 above zerosign(-7) = -1Just the three numbers -1, 0 and 1
Floor functionThe greatest integer not above xfloor(2.9) = 2, floor(-2.3) = -3All integers
Fractional partx minus floor(x)frac(2.9) = 0.9, frac(-2.3) = 0.7From 0 up to but not including 1

Negative inputs are where students slip. The floor of -2.3 is -3, because -3 is the greatest integer that does not exceed -2.3. It is not -2.

What do the floor and fractional-part graphs look like?

The floor function is a staircase. On each interval from n up to but not including n + 1, its value is the whole number n, so the graph has a closed dot at the left end and an open dot at the right. Dividing the input by 2 inside the floor stretches the stairs: floor(x / 2) holds each value for a width of 2 instead of 1, so floor(5 / 2) = 2 and floor(-1 / 2) = -1. Adding a number outside shifts the stairs up.

The fractional part, x minus floor(x), rises with slope 1 from 0 and drops back to 0 at each integer, which gives a sawtooth. Its range includes 0 but never reaches 1. Adding 1 to it lifts the whole sawtooth to the range from 1 up to but not including 2.

How do you write the rule from a graph?

Work piece by piece. Suppose the graph shows a line that comes in from the far left, passes through (-2, 3) and ends at an open dot at (1, 0), then a horizontal ray at height 2 that starts with a closed dot at x = 1 and continues right.

  1. The left piece passes through (-2, 3) and (1, 0), so its slope is (0 - 3) / (1 + 2) = -1. Its equation is y = 1 - x, used for x < 1.
  2. The right piece is the constant 2 for x >= 1.
  3. Together: f(x) = 1 - x for x < 1, and f(x) = 2 for x >= 1.

The open dot at (1, 0) matters. It tells you the point (1, 0) is not on the graph, so the condition on the left piece is x < 1, with no equal sign. The range here is the left piece's values above 0, together with the single value 2, which already lies in that set, so the range is every number above 0.

A word problem that is piecewise

Parking cost often changes by interval. Suppose a garage charges 4 dollars for any time up to one hour, and then 2 dollars for each further hour or part of an hour. The cost for t hours is 4 for t up to 1, 6 for t above 1 up to 2, 8 for t above 2 up to 3, and so on. Each piece is constant, and the joins are jumps. The question to ask is always whether the boundary time belongs to the lower or the higher charge, and the words "up to" settle it: exactly 2 hours costs 6.

Practice problems

These are original to George Li Tutoring.

  1. Let g(x) = 2x + 1 for x < 3 and g(x) = 10 - x for x >= 3. Find g(0), g(3) and g(8). Is g continuous at 3?
  2. Evaluate floor(-4.1), floor(7), and frac(3.25).
  3. Graph |x + 2| as a piecewise function and give its range.
  4. Find the range of h(x) = floor(x) + 1.

Answers: 1) g(0) = 1, g(3) = 7, g(8) = 2. At 3 the left rule gives 7 and the right rule gives 7, so g is continuous there. 2) floor(-4.1) = -5, floor(7) = 7, frac(3.25) = 0.25. 3) |x + 2| equals -(x + 2) when x < -2 and x + 2 when x >= -2, and its range is all numbers from 0 up. 4) Floor takes every integer, so adding 1 gives every integer.

If you want to check your graphs against a tutor's, the math tutoring page shows how a session works, and the packages page lists prices. The study planner places the practice across your week.

Common questions

How do I know whether to use an open or a closed dot?

Look at the inequality sign. A strict sign, such as x < 3, gives an open dot because 3 is not included. A sign with an equal part, such as x >= 3, gives a closed dot.

Can a piecewise function be continuous?

Yes. If the rules agree at every boundary, the graph has no jump or hole. Check by substituting the boundary value into both neighboring rules.

What is the domain of a piecewise function?

It is every input that at least one rule covers. If the pieces leave a gap, such as no rule for x = 3, then that value is excluded from the domain.

Why is floor(-2.3) not -2?

Because floor rounds down toward negative infinity, not toward zero. The greatest integer that does not exceed -2.3 is -3.

Sources