Piecewise Function Calculator & Evaluator
Define piecewise functions with up to 4 pieces, evaluate at any x, check continuity at breakpoints, identify discontinuity types, and view a table of values. Supports standard math expressions.
Load Example
Define Pieces (2/4)
Evaluate f(x) at a Point
Supported syntax
What Is the Piecewise Function Calculator & Evaluator?
A piecewise function applies different formulas to different parts of its domain. The simplest example is the absolute value: f(x) = −x for x < 0 and f(x) = x for x ≥ 0. More complex piecewise functions appear in tax brackets, postage rates, signal processing, and physics simulations that behave differently in different regimes.
Continuity analysis is the most important property to check: a function is continuous at a breakpoint x₀ if and only if the left-hand limit, the right-hand limit, and the function value there are all equal. If the one-sided limits agree but the point is missing or has a different value, the discontinuity is removable (fixable by redefining a single point). If the limits differ, it is a jump discontinuity.
Formula
General piecewise form:
f(x) = { f₁(x), a ≤ x < b
f₂(x), b ≤ x < c
f₃(x), x ≥ c }
Continuity at breakpoint x₀:
lim(x→x₀⁻) f(x) = lim(x→x₀⁺) f(x) = f(x₀) → continuous
lim⁻ = lim⁺ ≠ f(x₀) → removable discontinuity
lim⁻ ≠ lim⁺ → jump discontinuity (|jump| = |lim⁺ − lim⁻|)
How to Use
- 1Load an example: Click "Absolute Value", "Jump Discontinuity", or "3-Piece" to see working examples instantly.
- 2Define your pieces: For each piece, enter the expression (use x as the variable), the lower bound, and the upper bound. Use -inf and inf for infinity.
- 3Set boundary types: Choose open ( or closed [ for each bound to indicate whether that endpoint is included in the interval.
- 4Evaluate at a point: Enter an x value and click Evaluate. The result shows which piece was used and the computed value.
- 5Check continuity: Click "Check Continuity" to get a report on each breakpoint — whether it is continuous, a jump, or removable.
- 6View value table: Click "Value Table" to see f(x) at nine key x-values from −3 to 3.
Example Calculation
Absolute value: f(x) = |x|
- ›Piece 1: f₁(x) = −x for (−∞, 0)
- ›Piece 2: f₂(x) = x for [0, +∞)
- ›At x₀ = 0: lim⁻ = 0, lim⁺ = 0, f(0) = 0 → continuous
- ›Graph: V-shape with vertex at origin
Jump discontinuity: f(x) = x² for x < 2; x+3 for x ≥ 2
- ›At x₀ = 2: lim⁻ = 2² = 4, lim⁺ = 2+3 = 5
- ›lim⁻ ≠ lim⁺ → jump discontinuity of magnitude 1
- ›f(2) = 5 (from piece 2, since x=2 is included there)
Understanding Piecewise Function & Evaluator
Types of Discontinuities
| Type | Condition | Fixable? | Example |
|---|---|---|---|
| Continuous | lim⁻ = lim⁺ = f(x₀) | N/A | |x| at x=0 |
| Removable | lim⁻ = lim⁺ ≠ f(x₀) | Yes — redefine one point | (x²−1)/(x−1) at x=1 |
| Jump | lim⁻ ≠ lim⁺ | No | Floor function at integers |
| Infinite | lim→ ±∞ | No | 1/x at x=0 |
Real-World Piecewise Functions
Piecewise functions appear everywhere: progressive income tax (different rates per bracket), shipping costs (flat rate below a weight threshold, per-kg above it), electric utility billing (tiered pricing for kWh consumed), and piecewise-linear activation functions in neural networks (ReLU). In physics, potential wells and step functions in quantum mechanics are piecewise by definition.
Frequently Asked Questions
What is a removable discontinuity?
A removable discontinuity happens when lim⁻ = lim⁺ but f is undefined or has a different value at that point. It is fixable by redefining f at one point. In piecewise functions this occurs when two pieces have the same limit at a boundary but the function value there differs.
What expressions can I use in the formula field?
Supported: +, −, *, /, ^ (power), abs(x), sqrt(x), sin(x), cos(x), tan(x), exp(x), ln(x), log(x), pi, e. Example: 2*x^2 + abs(x−1) or sqrt(4−x^2). Use * for multiplication: write 2*x not 2x.
How are boundaries handled when two pieces share an endpoint?
The evaluator checks pieces in order and returns the first one whose interval contains x. Boundary choices (open/closed) determine which piece claims each endpoint. For continuity, the calculator checks the limit from each side of every finite breakpoint regardless of which piece owns that point.
Can I use this for tax bracket calculations?
Yes. Tax brackets are piecewise linear. Define one piece per bracket: e.g., for a 22% bracket starting at $41,775, use expression 0.22*x - constant with the appropriate lower and upper bounds. The continuity check confirms there are no gaps between brackets.
You Might Also Like
Explore 360+ Free Calculators
From math and science to finance and everyday life — all free, no account needed.