Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools


Piecewise Function Builder & Visualizer


Piecewise builderf(x) = piecewise (2 pieces)
×
880 × 460
piece (numbered at left endpoint)closed endpointopen endpoint
Well-definedness + boundary reporton viewport [-5, 5]
Continuous on viewport — pieces tile cleanly and agree at every boundary.continuous
continuousat x = 0left = right = f(x) = 0
Appliedpieces=2domains tile ⇒ well-defined





Key Terms



Key Terms

Piecewise function — a single function defined by several formulas, each applied on its own interval of the domain.

Piece — one formula together with the interval on which it acts. Each piece is a function from a small catalog (linear, quadratic, x|x|, x\sqrt{x}, 1/x1/x, sinx\sin x, cosx\cos x, exe^x, etc.) restricted to [a,b][a, b].

Endpoint kind — each interval boundary is either closed (the endpoint belongs to that piece, drawn as a filled dot) or open (the endpoint does not belong to that piece, drawn as an empty circle).

Well-defined — every xx in the domain is covered by exactly one piece. No overlaps (two pieces claiming the same xx) and no gaps (some xx with no piece).

Boundary — a value of xx where one piece ends and another begins. The behavior at a boundary is classified as continuous, removable, or jump.

Getting Started

The page opens with the absolute value preset already loaded — two pieces, x-x for x[5,0)x \in [-5, 0) and xx for x[0,5]x \in [0, 5], joining at the origin to form x|x|. The graph shows both pieces with open and closed endpoint markers honoring the interval kinds.

To explore quickly:

• Open the Presets dropdown in the left panel and pick a different shape — Heaviside step, Sign function, Sawtooth, Removable hole, or Jump discontinuity.

• Each preset loads a complete set of pieces that demonstrates a specific behavior. Switching presets replaces the current definition entirely.

• Use Empty (start over) to clear all pieces and build from scratch.

• The Reset button next to the Pieces label reloads whichever preset was active when the page opened.

The graph viewport is fixed at x[5,5]x \in [-5, 5]; the vertical range adjusts automatically to fit the pieces currently in use.

Editing Individual Pieces

Each piece in the editor has its own row with three controls:

Function selector — the dropdown showing the current shape (for example, xx, x2x^2, x|x|, sinx\sin x). Change it to swap the formula on this piece without touching its interval.

Interval bounds — two numeric inputs for the left and right endpoint of the piece, with 0.50.5-step increments. Type any decimal value within the viewport.

Endpoint toggle buttons — the bracket buttons on either side of the bounds. Click [[ to make the left endpoint closed, (( to make it open. Same for ]] and )) on the right.

The small numbered circle at the start of each row tells you which piece this is — pieces are numbered 1,2,3,1, 2, 3, \dots from top to bottom in the editor, matching the labels in the boundary report.

Remove a piece with the ×\times button on the right side of its row.

Adding New Pieces

The Add piece section at the bottom of the left panel adds a new piece to the end of the list:

• Pick a function shape from the f(x) = dropdown.

• Click + Add. The new piece appears below the existing ones with an interval that starts where the last piece ended and extends 22 units to the right (clipped to the viewport).

• The new piece's left endpoint is set to open if the previous piece's right endpoint was closed, and vice versa — a sensible default that avoids immediate overlap. Adjust the kinds afterward if you want a gap or an explicit overlap to see how the tool reacts.

You can build a definition with as many pieces as the viewport will fit. There's no upper limit imposed by the tool itself.

Open vs Closed Endpoints

At every boundary between two pieces, exactly one of them should own the boundary point. That's how the brackets in interval notation work, and that's how the tool tracks ownership.

Filled dot (closed endpoint) — the piece owns this xx value. The interval is written with a square bracket: [a,b][a, b] or [a,b)[a, b).

Empty circle (open endpoint) — the piece does not own this xx value. The interval is written with a parenthesis: (a,b)(a, b) or (a,b](a, b].

Rule of thumb at a shared boundary $x = k$: if piece A ends at kk and piece B begins at kk, one side should close and the other should open. Two closed endpoints at the same xx create an overlap — two pieces claiming the same value. Two open endpoints create a gap — neither piece covers that xx. The tool flags both as red rows.

The Verdict Panel

Below the graph, the boxed verdict panel summarizes the current definition with a single classification:

Continuous on viewport — pieces tile cleanly and agree at every boundary.

Well-defined, with jumps — pieces tile cleanly but the values disagree at one or more boundaries.

Well-defined, with removable points — limits agree but the assigned value at the boundary is different.

Not fully defined — at least one xx in the viewport has no piece covering it (a gap).

Not well-defined — at least one xx is claimed by two different pieces (an overlap). This is not a function at all.

A green check means the definition does qualify as a function; a red cross means it doesn't. The tag on the right (continuous, has jumps, has gaps, overlap) gives a one-word summary you can scan at a glance.

Reading the Boundary Report

Underneath the verdict, every interior boundary of the current definition gets its own row with a label and a brief explanation:

continuous (blue) — the left limit, right limit, and the assigned value all match. The function passes smoothly through the seam.

removable (deep blue) — the left and right limits agree but f(k)f(k) is something different. The discontinuity could be removed by reassigning the value at that single point.

jump (red) — the left limit and the right limit are different numbers. No single value of f(k)f(k) can patch this.

overlap (red) — two pieces both close at the same xx. Not a function — undefined.

gap (red) — adjacent pieces are both open at the same xx, or some interior interval has no piece. The function isn't defined there.

Each row lists the xx value of the boundary and the actual one-sided values that produced the classification.

What Is a Piecewise Function

A piecewise function is one function written as several formulas, each applied on a different part of the domain. It's a single object — f(x)f(x) — that just happens to be described by a different rule depending on where xx lies.

The standard notation collects the cases in a brace:

f(x)={f1(x)if xI1f2(x)if xI2f(x) = \begin{cases} f_1(x) & \text{if } x \in I_1 \\ f_2(x) & \text{if } x \in I_2 \\ \vdots \end{cases}


For this to define a function, the intervals I1,I2,I_1, I_2, \dots must partition the intended domain — every xx in the domain belongs to exactly one IkI_k. That's the well-definedness condition the tool checks.

For a deeper treatment of piecewise function theory, see the piecewise functions page.

Continuity at a Boundary

Even when the pieces tile the domain correctly, the function may not be continuous at the seams. At an interior boundary x=kx = k between piece A (ending at kk) and piece B (starting at kk):

f(k)=f(k+)=f(k)f(k^{-}) = f(k^{+}) = f(k)continuous. The left limit, right limit, and value all match. The graph passes through the seam without a break.

f(k)=f(k+)f(k)f(k^{-}) = f(k^{+}) \ne f(k)removable discontinuity. The two-sided limit exists; only the assigned value at kk is off. Redefining f(k)f(k) to the common limit removes the discontinuity.

f(k)f(k+)f(k^{-}) \ne f(k^{+})jump discontinuity. The two one-sided limits are different. No single value at kk can repair it.

For the full theory of limits and continuity, see the continuity page.

Common Piecewise Patterns

Several standard functions are defined piecewise even when their name suggests a single formula. The presets in this tool walk through the canonical examples:

Absolute value x|x| — two linear pieces meeting at the origin, x-x on the left and xx on the right. Continuous everywhere, not differentiable at 00.

Heaviside step — constant 00 (or 1-1) on the left of 00 and constant 11 on the right. The simplest jump discontinuity, used as a building block in signal analysis.

Sign function1-1, 00, +1+1 on three pieces, with the middle piece being a single-point closed interval at the origin.

Sawtooth — linear pieces that reset at fixed intervals, producing a series of jumps.

Removable hole — two pieces that agree on the limit at the seam but assign different values, isolating the removable case.

Related Concepts

Functions — the general theory of functions, domain, range, and notation. The foundation behind piecewise definitions.

Continuity — the formal definition of continuous functions and the classification of discontinuities (jump, removable, essential).

Limits — one-sided and two-sided limits, the machinery used to classify boundary behavior on piecewise functions.

Domain and range — how the domain of a piecewise function is the union of the individual piece domains.

Absolute value function — a canonical piecewise example, with its own page covering algebraic properties and graphing.

Step functions — piecewise constants used to model on/off behavior, indicator functions, and quantized signals.

Visual tools for functions — other interactive visualizers covering composition, transformations, inverses, and graphing.