Piecewise Function Calculator

Evaluate a simple two-piece function at a chosen x-value. This educational calculator shows the formula, result, and step-by-step interpretation.

High SchoolFunctions

Calculator

What this calculator teaches

Piecewise functions model rules that change at thresholds, intervals, or conditions.

Use the result as a learning aid. For classwork, still show the formula and intermediate reasoning so the final answer is not just a black-box number.

How Piecewise Functions Work

A piecewise function uses different formulas on different parts of its domain. This calculator models two linear pieces separated by a split value c. For x<c, it uses the left rule m₁x+b₁; for x≥c, it uses the right rule m₂x+b₂. The inequality is part of the definition, not just a note, because it determines which formula applies exactly at the boundary.

Piecewise definitions occur naturally in tax brackets, shipping charges, absolute value, step functions, control systems, and models where behavior changes after a threshold. To evaluate one, first decide which interval contains x, then ignore the other formulas and substitute into the selected rule.

RegionRule used
x < cf(x)=m₁x+b₁
x ≥ cf(x)=m₂x+b₂

A piecewise function may be continuous or discontinuous at c. Continuity requires the left-hand value m₁c+b₁ to equal the right-hand value m₂c+b₂. Equal values do not require equal slopes; if the slopes differ, the graph has a corner. If the values differ, the graph has a jump at the split.

Check the boundary separately. For a split at c, evaluate the left expression at c and the right expression at c even though only one rule may formally include that point. Comparing those two values tells you whether the pieces meet. If they match, the function can be continuous at c; if they differ, the graph has a jump.

Then compare the slopes. Equal boundary values with different slopes create a corner, while equal values and equal slopes make the join smoother. In applied models, the split often represents a policy threshold or regime change, so the choice of < versus ≤ is meaningful. Always copy the inequality exactly before evaluating a boundary input.

Formula & Symbols

ConceptFormula or rule
Piecewise ruleuse one formula for x < c and another for x ≥ c

Worked example

Example: If x is less than the split value, use the left formula; otherwise use the right formula.
Example 2: If f(x)=2x+1 for x<3 and f(x)=x+4 for x≥3, then f(2)=5.
Example 3: For the same function, f(3)=7 because the right-hand rule includes x=3.
Example 4: With left rule x and right rule 2x at c=0, f(-2)=-2 while f(2)=4.
Example 5: If both rules give 5 at c=2, the function can be continuous there even when their slopes differ.

Common mistakes

⚠️
Using the wrong input format

Keep lists comma separated, matrices as rows separated by semicolons, and modular inputs as integers.

⚠️
Ignoring assumptions

Some methods require positive probabilities, valid moduli, independent trials, or small educational input sizes.

⚠️
Using the wrong inequality at the boundary

The calculator assigns x=c to the right-hand piece because its condition is x≥c.

⚠️
Substituting into both formulas

Only one rule applies to a given input. Determine the interval first, then evaluate the matching expression.

FAQ

Can I use decimals?
Most numerical calculators allow decimals, but modular arithmetic and coding-theory tools usually require integers or binary strings.
Is this for homework checking?
Yes. The page is designed to show both the answer and the reasoning pattern.
Why does the result sometimes say approximate?
Some probability, floating-point, and numerical methods naturally produce approximations.
Can a piecewise function be continuous?
Yes. At the split, continuity requires the left-hand and right-hand values to agree.
Can the graph have a corner?
Yes. If the pieces meet but have different slopes, the function is continuous but not differentiable at that point.
What happens exactly at the split value?
This calculator uses the right-hand rule because the right condition is x≥c.
Is absolute value a piecewise function?
Yes. |x| can be written as -x for x<0 and x for x≥0.

Related calculators

These links will work after the calculators are registered in the final Math layout update.

Formula Explorer connections

Interpretation: This formula describes an algebraic relationship among variables, functions, equations, roots or sequences. Assumption: Respect the expression’s domain and excluded values. Check roots in the original equation because transformations can introduce extraneous solutions.

Polynomial Calculator →Polynomial Long Division Calculator →Polynomial Roots Calculator →Math Formula Explorer →