3 Piecewise Function Calculator
Define three linear pieces with two breakpoints, then evaluate f(x) at up to five x-values with full step-by-step working.
A piecewise function is one of the most practical ideas in mathematics: instead of a single rule that works everywhere, it switches between different rules depending on where you are on the number line. Tax brackets work this way, shipping rates work this way, and many pricing plans work this way. The 3 Piecewise Function Calculator above handles the most common classroom and real-world case — a function built from three straight-line pieces — and evaluates it at any x-values you choose, showing exactly which piece applied and every step of the arithmetic.
Each piece is a straight line described by a slope and an intercept, so f(x) = m·x + c on that piece. Two breakpoints divide the number line into three regions: Piece 1 handles everything below the first breakpoint, Piece 2 handles the middle region, and Piece 3 handles everything from the second breakpoint onward. You enter the six numbers that define the three lines, the two breakpoints, and up to five x-values, and the calculator returns each f(x) with a full breakdown of the substitution and simplification.
What the 3 Piecewise Function Calculator Does
This calculator evaluates a three-piece linear piecewise function. You define Piece 1 with a slope m₁ and intercept c₁, Piece 2 with slope m₂ and intercept c₂, and Piece 3 with slope m₃ and intercept c₃. You also define two breakpoints, a and b, with a smaller than b. The calculator then applies the rule: use Piece 1 when x is less than a, use Piece 2 when x is at least a but less than b, and use Piece 3 when x is at least b.
For every x-value you enter, the result panel shows three things: the final value f(x), a badge naming the piece that was used, and the complete step-by-step working — the substitution of x into that piece’s formula, the multiplication, and the final addition. The top of the result panel also restates your function in standard piecewise notation so you can double-check that what you typed matches what you intended. If the breakpoints are out of order, or any field is missing, the calculator explains the problem in a clear error message instead of guessing.
How to Use the 3 Piecewise Function Calculator
Start with the three piece cards. In Piece 1, enter the slope and intercept of the leftmost line — for example, a slope of 2 and an intercept of 3 gives f(x) = 2x + 3 on that piece. Then enter breakpoint a, the x-value where Piece 1 stops and Piece 2 starts. Fill in Piece 2 the same way, then breakpoint b, then Piece 3. The only ordering rule is that a must be less than b; the calculator checks this for you.
Next, enter the x-values you want to evaluate in the boxes under “Values of x to evaluate”. The first box is required — you need at least one x. If you want more, press the “+ Add x” control to reveal up to four extra rows (five x-values in total), each with its own remove control if you change your mind. Empty extra rows are simply skipped, so you never have to fill in rows you do not need.
Press Calculate. Each evaluation appears as its own card showing f(x), the piece number, and the arithmetic. Use Reset when you want to start over with a fresh function. A useful habit is to evaluate the breakpoints themselves: try x = a and x = b to confirm which piece claims the boundary. In this calculator, a boundary point always belongs to the piece on its right — x = a uses Piece 2, and x = b uses Piece 3 — which matches the standard convention used in most textbooks.
The Math Behind Piecewise Evaluation
Evaluating a piecewise function is a two-step process. Step one is selection: compare x with the breakpoints to find the active piece. Step two is substitution: plug x into that piece’s formula and simplify. There is no deeper magic — the only skill involved is being careful about which region x falls into, especially near the boundaries.
Formally, the calculator implements this definition:
f(x) = m₁·x + c₁ when x < a
f(x) = m₂·x + c₂ when a ≤ x < b
f(x) = m₃·x + c₃ when x ≥ b
The comparisons are strict on the left edge of each region and inclusive on the right edge’s lower bound. That means exactly one piece is ever active for any real number x — the regions tile the number line with no gaps and no overlaps. Notice that the pieces do not have to connect: the function is allowed to jump at a breakpoint. Piece 1 might give f(a) approaching one value from the left while Piece 2 gives a completely different value at x = a itself. The calculator reports whatever the definition says, jumps included, because that is what the mathematics requires.
Worked Examples With Full Arithmetic
Example 1 — one x in each piece. Define the function with Piece 1: slope 2, intercept 3 (f(x) = 2x + 3); breakpoint a = 1; Piece 2: slope −1, intercept 5 (f(x) = −x + 5); breakpoint b = 4; Piece 3: slope 0.5, intercept −2 (f(x) = 0.5x − 2). Now evaluate at x = 0, x = 2, and x = 5.
For x = 0: compare with the breakpoints. Is 0 < 1? Yes, so Piece 1 applies. Substitute: f(0) = 2 × 0 + 3 = 0 + 3 = 3. For x = 2: is 2 < 1? No. Is 1 ≤ 2 < 4? Yes, so Piece 2 applies. Substitute: f(2) = −1 × 2 + 5 = −2 + 5 = 3. For x = 5: is 5 < 1? No. Is 5 < 4? No. So we fall through to Piece 3, which covers x ≥ 4. Substitute: f(5) = 0.5 × 5 − 2 = 2.5 − 2 = 0.5. The calculator shows exactly these three steps, and you can verify each one with mental arithmetic.
Example 2 — boundary points. Using the same function, evaluate at the breakpoints themselves, x = 1 and x = 4, plus a negative value x = −3. For x = 1: the first test, 1 < 1, is false (it is not strictly less), so we move on. The second test, 1 ≤ 1 < 4, is true — Piece 2 claims the boundary. f(1) = −1 × 1 + 5 = −1 + 5 = 4. For x = 4: the tests 4 < 1 and 4 < 4 both fail, so Piece 3 applies: f(4) = 0.5 × 4 − 2 = 2 − 2 = 0. For x = −3: −3 < 1 is true, Piece 1: f(−3) = 2 × (−3) + 3 = −6 + 3 = −3. This example is worth studying because boundary mistakes are the most common error students make with piecewise functions — always check whether the inequality at the breakpoint is strict or inclusive.
Understanding Your Results
Each result card answers three questions: what is the value, which piece produced it, and why that piece was chosen. The “why” line states the inequality the x-value satisfied, such as “Piece 2 applies because 2 satisfies 1 ≤ x < 4". If a result surprises you, that line is the first place to look — it tells you whether the surprise came from picking the wrong piece or from the arithmetic inside the piece.
The definition summary at the top of the results is equally important. It renders your function the way a textbook would write it, for example “Piece 2: f(x) = −x + 5, 1 ≤ x < 4". Compare it with the function you meant to enter. Most "wrong answers" from this calculator turn out to be right answers to a mistyped function — a sign error in an intercept, or the two breakpoints swapped. The summary makes those typos visible before you trust the numbers.
Values are rounded to four decimal places, which is plenty for checking homework and for applied work like pricing models. If you see a jump between f(3.999) and f(4), that is not a bug: the function genuinely changes definition at the breakpoint, and different pieces can give different values there. Only worry if the jump appears where you expected the pieces to join smoothly.
Common Mistakes to Avoid
The most frequent mistake is entering the breakpoints in the wrong order, with a larger than b. The number line must read Piece 1, then Piece 2, then Piece 3 from left to right, so a has to be the smaller breakpoint. The calculator refuses to compute until this is fixed, which is deliberate: evaluating with crossed breakpoints would silently apply the wrong piece to every x.
The second most frequent mistake is mishandling boundary points by hand. Remember the rule this calculator follows: x = a belongs to Piece 2 and x = b belongs to Piece 3. If your textbook uses the opposite convention (boundaries belonging to the left piece), your hand calculations will differ from the calculator exactly at the breakpoints and nowhere else. Decide which convention your course uses and stay consistent.
Third, watch the signs when a slope or intercept is negative. Substituting x = 2 into f(x) = −x + 5 gives −2 + 5 = 3, not −7 — the negative sign belongs to the slope, and it multiplies x before anything is added. The step-by-step panel writes out the multiplication explicitly so sign slips are easy to spot. Finally, do not leave extra x-rows half-filled: a visible row containing text that is not a number triggers an error, so either complete the row or remove it.
Frequently Asked Questions
1. What is a piecewise function?
It is a function defined by different rules on different parts of its domain. Instead of one formula for all x, you get a list of formulas, each paired with the interval of x-values where it applies. The calculator above handles the three-piece linear case: three straight-line formulas joined at two breakpoints.
2. Why would anyone use a piecewise function?
Because many real rules change with the input. Income tax uses different rates in different brackets, shipping costs jump at weight thresholds, and phone plans charge one rate up to a data cap and another beyond it. Piecewise functions are the natural mathematical language for “the rule depends on where you are”.
3. What do the slope and intercept of a piece mean?
Each piece is a straight line f(x) = m·x + c. The slope m controls how steeply the line rises or falls — it is the rate of change on that piece. The intercept c is where that line would cross the y-axis if it were extended. Together they fully determine the piece’s behavior on its interval.
4. Which piece is used at exactly x = a?
Piece 2. The first region is x < a (strictly less than), so the breakpoint itself falls into the second region, a ≤ x < b. Likewise, x = b belongs to Piece 3. This "boundaries belong to the right" convention is the one most textbooks use, and the calculator states the satisfied inequality for every evaluation so you can see it in action.
5. Can the pieces be disconnected at the breakpoints?
Yes. Nothing in the definition requires the pieces to meet. If Piece 1 approaches 5 as x nears a from below but Piece 2 gives 9 at x = a, the function simply jumps. The calculator reports the defined value at every x, including jumps, without smoothing anything.
6. What happens if I enter a ≥ b?
The calculator shows an error and does not evaluate. With the breakpoints out of order, the three regions would overlap or leave gaps, so no consistent function exists. Swap the breakpoint values so that a is the smaller one and calculate again.
7. How many x-values can I evaluate at once?
Up to five. The first x box is required; press “+ Add x” to reveal up to four more rows. Each added row can be removed individually. Empty extra rows are ignored, so fill in only as many as you need.
8. How do I check my answer by hand?
Pick one result, find its piece from the badge, and redo the two steps yourself: first confirm x really satisfies that piece’s inequality, then substitute x into the piece formula and simplify. The step-by-step line in the result shows the substitution, the multiplication, and the final addition separately, so you can compare each stage.
9. Why does f(1) use Piece 2 in the worked example?
Because 1 is not strictly less than the breakpoint a = 1, the first test fails, and 1 satisfies 1 ≤ x < 4, so the second piece applies: f(1) = −1 × 1 + 5 = 4. This is the boundary rule in action — test it yourself in the calculator with x = 1 and x = 4.
10. Can slopes or intercepts be decimals or negatives?
Yes. Any real numbers work: decimal slopes like 0.5, negative intercepts like −2, and negative x-values are all fine. Results are rounded to four decimal places to keep long decimals readable.
11. Does the calculator draw the graph?
No — it is an evaluator, not a grapher. It tells you exact function values at the x-values you choose, with full working. For the picture, plot the three line segments on their intervals yourself; the evaluated points make excellent anchor points for the sketch.
12. What is the domain of the function?
All real numbers. The three regions — x < a, a ≤ x < b, and x ≥ b — cover the entire number line with no gaps, so every x you enter has exactly one active piece and one defined value.
13. Can I use this for tax brackets or pricing tiers?
For simple cases, yes. A three-tier pricing scheme maps neatly onto three pieces: enter each tier’s rate as a slope and its base charge as an intercept, with the tier thresholds as breakpoints. Just remember each piece must be linear (a straight line) — percentage-of-excess calculations with cumulative bases need an extra step outside the calculator.
14. Why do I get an error about a non-numeric x?
One of the visible x-rows contains text that is not a number. Either type a valid number into that row or remove the row with its × control. Hidden rows are never checked, so collapsing rows you do not need is always safe.
15. Is a piecewise function still “one function”?
Yes. A function is defined by giving exactly one output for each input, and a piecewise definition does exactly that — it just uses different recipes in different neighborhoods. The vertical-line test still applies: as long as each x maps to a single y, you have one perfectly good function.
Final Thoughts
Piecewise functions look complicated in textbooks but evaluate in two simple steps: find the right piece, then substitute. The 3 Piecewise Function Calculator automates both steps and shows its work, which makes it ideal for checking homework, testing boundary cases, and building intuition for how breakpoints control a function’s behavior. Enter your three pieces and breakpoints above, evaluate a few x-values on each side of the boundaries, and the logic of piecewise definitions will quickly feel like second nature.