Piecewise Function Evaluator Calculator
Free Piecewise function evaluator Calculator for algebra. Enter values to get step-by-step solutions with formulas and graphs.
Reviewed for accuracy by Manoj Kumar, Mathematics Educator
Piecewise Function Evaluator Calculator
Calculator
Adjust values & calculateEnter your values below. Every result is computed in your browser โ no data is sent to any server.
Formula: f(x) = { g(x) if x < c, h(x) if x >= c }
Worked example โ f(-1) = -2 | f(2) = 5 | f(5) = -1 | Jump discontinuity at x = 2
Formula
f(x) = { g(x) if x < c, h(x) if x >= c }A piecewise function uses different formulas for different intervals of the domain. The breakpoint c divides the domain into regions where different rules apply. Continuity requires g(c) = h(c). Differentiability additionally requires the slopes to match at the breakpoint.
Worked Examples
Example 1: Evaluating a Piecewise Function at Multiple Points
Problem:Given f(x) = 3x + 1 for x < 2 and f(x) = -2x + 9 for x >= 2, evaluate f(-1), f(2), and f(5).
Solution:f(-1): Since -1 < 2, use left piece: f(-1) = 3(-1) + 1 = -2 f(2): Since 2 >= 2, use right piece: f(2) = -2(2) + 9 = 5 f(5): Since 5 >= 2, use right piece: f(5) = -2(5) + 9 = -1 Continuity check at x = 2: Left limit: 3(2) + 1 = 7 Right value: -2(2) + 9 = 5 7 does not equal 5, so there is a jump discontinuity of size 2.
Result:f(-1) = -2 | f(2) = 5 | f(5) = -1 | Jump discontinuity at x = 2
Example 2: Checking Continuity of a Piecewise Function
Problem:Is f(x) = 2x + 1 for x <= 3 and f(x) = -x + 10 for x > 3 continuous at x = 3?
Solution:Left limit (as x approaches 3 from left): lim = 2(3) + 1 = 7 Right limit (as x approaches 3 from right): lim = -(3) + 10 = 7 Function value at x = 3 (left piece applies since x <= 3): f(3) = 2(3) + 1 = 7 All three values equal 7. Differentiability: Left slope = 2, Right slope = -1 Slopes differ, so the function has a corner (not differentiable) at x = 3.
Result:Continuous at x = 3 (f(3) = 7) | Not differentiable (corner point)
Frequently Asked Questions
What is a piecewise function and when is it used?
A piecewise function is a function defined by different formulas or rules for different parts of its domain. Instead of using a single expression for all inputs, the function switches between two or more expressions depending on where the input falls. For example, the absolute value function |x| is piecewise: it equals x when x >= 0 and -x when x < 0. Piecewise functions are used extensively in real-world modeling because many phenomena behave differently under different conditions. Tax brackets, shipping rates, overtime pay, and cell phone plans all use piecewise pricing. In engineering, stress-strain relationships are piecewise because materials behave differently before and after their yield point.
How do you evaluate a piecewise function at a specific point?
To evaluate a piecewise function at a specific x value, first determine which piece of the function applies by checking which condition the x value satisfies. Then substitute the x value into the corresponding formula. For example, given f(x) = 2x + 1 if x < 3 and f(x) = x^2 - 2 if x >= 3, to find f(5): since 5 >= 3, use the second piece: f(5) = 5^2 - 2 = 23. To find f(1): since 1 < 3, use the first piece: f(1) = 2(1) + 1 = 3. At the breakpoint x = 3: since 3 >= 3, use the second piece: f(3) = 9 - 2 = 7. Always pay careful attention to whether the breakpoint uses strict or non-strict inequalities.
What does it mean for a piecewise function to be continuous?
A piecewise function is continuous at a breakpoint if the left-hand limit, right-hand limit, and function value at that point all agree. In practical terms, this means there is no gap or jump in the graph at the transition point. Mathematically, if the breakpoint is at x = c, then lim(x approaches c from the left) f(x) must equal lim(x approaches c from the right) f(x) must equal f(c). For example, f(x) = 2x + 1 for x < 2 and f(x) = 5 for x >= 2 is continuous at x = 2 because 2(2) + 1 = 5 matches the value from the right piece. If these values differ, there is a jump discontinuity and the function has a visible break in its graph.
What is a jump discontinuity in a piecewise function?
A jump discontinuity occurs when the left-hand limit and right-hand limit exist at a breakpoint but do not equal each other. The function literally jumps from one value to another. For example, the Heaviside step function equals 0 for x < 0 and 1 for x >= 0. At x = 0, the left limit is 0 and the right limit is 1, creating a jump of size 1. Jump discontinuities are common in real-world models: an employee's hourly rate jumps at the overtime threshold, water utility rates jump at usage tiers, and tax rates jump at bracket boundaries. The size of the jump equals the absolute difference between the left and right limits. Functions with jump discontinuities are called piecewise continuous.
How do you determine if a piecewise function is differentiable at a breakpoint?
A piecewise function is differentiable at a breakpoint only if it satisfies two conditions: it must be continuous at that point AND the derivatives from both sides must be equal. Continuity alone is not sufficient. For example, the absolute value function f(x) = -x for x < 0 and f(x) = x for x >= 0 is continuous at x = 0 (both sides give f(0) = 0), but the left derivative is -1 and the right derivative is +1, so it is not differentiable at x = 0. The graph has a sharp corner there. For the function to be smooth (differentiable), the pieces must connect without a corner, meaning both the function values and the slopes must match at the breakpoint.
How do you graph a piecewise function?
To graph a piecewise function, graph each piece separately on its own restricted domain, then combine them into one coordinate plane. For each piece, draw the line or curve only over the interval where that formula applies. At breakpoints, use a solid dot (filled circle) to indicate the function value at that point, and an open dot (hollow circle) to indicate a value that is approached but not attained. For example, for f(x) = x + 1 if x < 2 and f(x) = -x + 5 if x >= 2, draw the line y = x + 1 only for x values less than 2 with an open circle at (2, 3), and draw y = -x + 5 for x >= 2 with a filled circle at (2, 3). This visual representation clearly shows continuity, jumps, and corners.
What is the domain and range of a piecewise function?
The domain of a piecewise function is the union of the domains of all its pieces. If the pieces cover all real numbers without gaps, the domain is all real numbers. The range is the union of all output values across all pieces, which requires analyzing each piece individually and combining the results. For example, f(x) = x^2 for x <= 0 and f(x) = 2x for x > 0 has domain (-infinity, infinity). The left piece produces outputs [0, infinity) since x^2 >= 0 for all x. The right piece produces outputs (0, infinity) since 2x > 0 for x > 0. The combined range is [0, infinity). Finding the range often requires careful analysis of each piece, including considering the boundary behavior.
How are piecewise functions used in programming and computer science?
Piecewise functions are implemented in programming using if-else statements, switch-case blocks, or conditional expressions. Every time code branches based on a condition, it is defining a piecewise computation. Activation functions in neural networks are often piecewise: ReLU (Rectified Linear Unit) equals 0 for x < 0 and x for x >= 0. Clamping functions restrict values to a range using piecewise logic. Interpolation algorithms use piecewise polynomials (splines) to create smooth curves through data points. Game physics engines use piecewise functions for collision detection and response. The mathematical concept of piecewise functions maps directly to conditional logic in code, making it one of the most practically applied mathematical concepts in software engineering.
What are common real-world examples of piecewise functions?
Real-world piecewise functions appear whenever rules or rates change at specific thresholds. Income tax is a classic example: different rates apply to different income brackets, with each bracket forming a separate linear piece. Shipping costs often follow a step function based on weight tiers. Utility companies charge different rates for different usage levels, with lower rates for basic usage and higher rates above certain thresholds. Parking garage fees might be free for the first hour, then a flat rate per additional hour up to a daily maximum. Cell phone plans with different rates for data usage within and beyond the plan limit are piecewise. Even the human body follows piecewise behavior: heart rate has different formulas during rest, exercise, and recovery.
How do you integrate or differentiate a piecewise function?
To differentiate a piecewise function, differentiate each piece separately on its own interval using standard rules. At breakpoints, the derivative may not exist if the function has a corner or jump. To integrate a piecewise function over an interval that crosses a breakpoint, split the integral at the breakpoint and integrate each piece separately, then add the results. For example, integrating f(x) = 2x for x < 1 and f(x) = 3 for x >= 1 from 0 to 3: split into integral from 0 to 1 of 2x dx (= 1) plus integral from 1 to 3 of 3 dx (= 6), giving a total of 7. This splitting technique is essential because you cannot integrate a single formula across a domain where different formulas apply.
References
Reviewed for accuracy by Manoj Kumar, Mathematics Educator ยท Editorial policy
Related Calculators
๐งฎBessel Function Calculator
Calculate bessel function with inputs, formulas, and instant results.
๐งฎComposite Function Calculator
Calculate composite function with inputs, formulas, and instant results.
๐งฎError Function Calculator
Calculate error function with inputs, formulas, and instant results.
๐งฎFunction Domain Calculator
Calculate function domain with inputs, formulas, and instant results.
๐งฎFunction Range Calculator
Calculate function range with inputs, formulas, and instant results.
๐งฎGamma Function Calculator
Calculate gamma function with inputs, formulas, and instant results.
๐งฎInverse Function Calculator
Calculate inverse function with inputs, formulas, and instant results.
๐งฎAverage Value of Function Calculator
Calculate average value of function with inputs, formulas, and instant results.