MathsAdvanced Equations

Piecewise Function Calculator &
evaluator.

Build a function from pieces, find its value at any x, and test each break.

How it's worked out

A piecewise function uses more than one formula, each on its own interval of x. To find f(x), test the conditions in order and use the first one that holds. Only that piece is used.

f(x)\displaystyle f(x)=x2 if x\displaystyle {}= x^2 \text{ if } x<0\displaystyle {}< 0
f(x)\displaystyle f(x)=2x+1 if x\displaystyle {}= 2x + 1 \text{ if } x≥0\displaystyle {}\ge 0

An end written with ≤ or ≥ is included and gets a filled dot on the graph. An end written with < or > is left out and gets a hollow dot. A point where one piece hands over to the next is a breakpoint.

At each breakpoint b the tool finds the left-hand limit, the value the left piece heads to, and the right-hand limit. It finds them numerically, by trying x closer and closer to b. Then it compares them with f(b). Three things must hold for the function to be continuous at b.

  • f(b) is defined, so some piece includes b.
  • The left and right limits exist and are equal.
  • That shared limit equals f(b).

When the two limits differ, the break is a jump. When they agree but f(b) is missing or different, it is a removable hole that one point could fill. When a side runs off to infinity, the break is infinite.

Worked examples

Sam checks a phone bill with a data tier

Sam's plan costs a flat $25 for under 2 GB. From 2 GB on, it adds $10 for each GB above 2. With x as the gigabytes used, the cost is two pieces.

C(x)\displaystyle C(x)=25 if 0\displaystyle {}= 25 \text{ if } 0<x\displaystyle {}< x<2\displaystyle {}< 2
C(x)\displaystyle C(x)=25+10(x−2) if x\displaystyle {}= 25 + 10(x - 2) \text{ if } x≥2\displaystyle {}\ge 2

Sam used 4 GB, so the second piece applies and the bill is $45. A month at 1.5 GB costs $25. At 2 GB both sides head to $25, so the price is continuous there: no sudden jump in the bill.

Open this example in the tool

A jump where the pieces meet

With x² for x < 0 and 2x + 1 for x ≥ 0, the value at x = 1 comes from the second piece: f(1) = 3. At x = −0.5 the first piece gives 0.25.

At 0 the left side heads to 0 and the right side to 1. The limits differ, so this is a jump of 1. The graph shows a hollow dot at (0, 0) and a filled one at (0, 1), because 0 belongs to the second piece.

Open this example in the tool

A hole filled with the wrong value

Here the same formula sits on both sides of 1, and a third piece sets f(1) = 3 on its own.

f(x)\displaystyle f(x)=x2−1x−1 if x\displaystyle {}= \frac{x^2 - 1}{x - 1} \text{ if } x≠1\displaystyle {}\ne 1

For any x other than 1 the fraction equals x + 1, so both sides head to 2. At x = 1.001 the value is 2.001. But f(1) is 3, so the break is removable: setting f(1) to 2 would close it.

Open this example in the tool

Reading your result

Which piece was used. The answer names the piece and its condition. If two pieces overlap, the first one listed wins, and a note says so. If no piece covers x, the value is not defined there.

Continuous but not smooth. The pieces −x and x meet at 0, where both sides head to 0, so |x| is continuous. Yet the graph has a sharp corner there, so it has no slope at 0. Continuity does not mean you can take a derivative.

Infinite breaks. With 1/x for x < 0, the left side runs off to −∞ at 0, so the break is infinite: a vertical asymptote. No single point can fix that.

Limits found by trying values. The left and right limits come from x values a tiny step from the breakpoint. That is reliable for the formulas met in class, but a function that swings wildly near a point may be reported as having no limit.

Common mistakes

  • Using both pieces at a shared end. At x = 0 with x < 0 and x ≥ 0, only the second piece applies. Including the end in both makes the rule give two values, so it is not a function.
  • Judging dots by height. Whether a dot is filled depends on the condition, not on which end sits higher on the graph.
  • Setting values equal at the wrong place. To join x² and kx at 2, match their values at x = 2, which gives k = 2. With k = 3 the right side heads to 6 instead of 4, a jump. With k = 2 the function is continuous at 2.
  • Forgetting the domain. A plan priced only for x above 0 is not defined at 0. The tool lists any gap that no piece covers.

Questions people ask

Write each side's limit at the breakpoint in terms of k and set them equal. For x² when x < 2 and kx when x ≥ 2, the left side heads to 4 and the right side to 2k, so k = 2. Enter that k and check that the breakpoint is listed as continuous.

Sources