2
2
5
3
0
2
2
5
3
0
A piecewise function is defined by different formulas on different intervals of its domain. These functions appear naturally whenever a rule changes at a boundary: tax brackets switch rates at income thresholds, shipping costs jump at weight limits, and material stress follows different laws before and after the yield point. The general two-piece form is:
$$f(x) = \begin{cases} ax + b & \text{if } x < t \\ cx + d & \text{if } x \geq t \end{cases}$$
Our Piecewise Function Calculator evaluates this function at any point, tells you which piece was used, and performs an automatic continuity check at the threshold $$t$$. Continuity — whether the two pieces connect seamlessly — is a critical concept in calculus, and this tool makes it visual and concrete.
Understanding piecewise functions is essential for courses ranging from precalculus through real analysis. They also form the foundation of spline interpolation in numerical methods, where smooth curves are built from piecewise polynomials joined at knots. In machine learning, the ReLU activation function $$\max(0, x)$$ is a piecewise linear function. Mastering the basics here opens doors to these advanced topics.
The calculator applies a simple decision rule based on your threshold $$t$$:
If $$x < t$$: Use Piece 1: $$f(x) = ax + b$$.
If $$x \geq t$$: Use Piece 2: $$f(x) = cx + d$$.
Continuity Check: The function is continuous at $$x = t$$ if and only if the left-hand limit equals the right-hand limit: $$\lim_{x \to t^-} f(x) = \lim_{x \to t^+} f(x)$$. For linear pieces, this simplifies to $$at + b = ct + d$$. The calculator evaluates both sides and flags whether they match.
The left limit is computed as $$a \cdot t + b$$ (approaching from below), and the right limit as $$c \cdot t + d$$ (the value at and beyond the threshold). If these differ, there is a jump discontinuity of magnitude $$|\text{left} - \text{right}|$$.
The f(x) Result gives the function value at your chosen point. Piece Used tells you which formula was applied (1 for $$x < t$$, 2 for $$x \geq t$$). The Left Limit and Right Limit at the threshold reveal whether the two pieces meet. If they are equal, the function is continuous (output = 1); if they differ, there is a jump discontinuity (output = 0). A discontinuity means the function has a "break" at the threshold, which has implications for differentiability and integrability.
Inputs
Results
At threshold x = 2: left limit = 2(2)+1 = 5, right limit = −1(2)+7 = 5. Continuous! At x = 3: piece 2 gives −1(3)+7 = 4.
Inputs
Results
At threshold x = 1: left = 1(1)+0 = 1, right = 3(1)−2 = 1. Actually continuous here. At x = 0.5: piece 1 gives 0.5.
A piecewise function is defined by different expressions on different parts of its domain. Each "piece" applies over a specific interval. Common examples include the absolute value function $$|x|$$ (which equals $$x$$ for $$x \geq 0$$ and $$-x$$ for $$x < 0$$), tax bracket formulas, and utility rate schedules.
A piecewise function is continuous at a boundary point $$t$$ if three conditions hold: (1) $$f(t)$$ is defined, (2) $$\lim_{x \to t} f(x)$$ exists, and (3) the limit equals the function value. For two linear pieces, this reduces to checking whether $$at + b = ct + d$$. If the left and right limits match, the function is continuous at that point.
A piecewise function can only be differentiable at the threshold if it is first continuous there and, additionally, the derivatives from both sides match. For linear pieces, the left derivative is $$a$$ (the slope of piece 1) and the right derivative is $$c$$ (the slope of piece 2). Differentiability requires both $$at + b = ct + d$$ and $$a = c$$.
Piecewise functions model many real scenarios: (1) progressive tax systems where different rates apply to different income brackets, (2) shipping costs that jump at weight thresholds, (3) overtime pay (regular rate below 40 hours, 1.5x rate above), (4) utility pricing with tiered rates, and (5) the absolute value function used in distance calculations.
A jump discontinuity occurs when the left-hand limit and right-hand limit at a point both exist but are not equal. The function "jumps" from one value to another at the boundary. The size of the jump is the absolute difference between the two limits: $$|\lim_{x \to t^-} f(x) - \lim_{x \to t^+} f(x)|$$.
This calculator handles the standard two-piece case, which covers most precalculus problems. For more pieces, you can chain evaluations: use the calculator to analyze each boundary point separately, checking continuity at each threshold. The underlying principle is the same — compare left and right limits at every boundary.
Roboculator Team
The Roboculator Team explains calculations, planning tools, and practical formulas in clear language for real-life situations.
How helpful was this calculator?
Be the first to rate!
Function Transformations Calculator
Precalculus & Advanced Math
Composite Function Calculator
Precalculus & Advanced Math
Parametric Equation Calculator
Precalculus & Advanced Math
Polar Equation Calculator
Precalculus & Advanced Math
Conic Sections Calculator
Precalculus & Advanced Math
Hyperbola Calculator
Precalculus & Advanced Math