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.

The Absolute Value Preset

The gallery's opening preset builds x|x| from two linear pieces: x-x on [5,0)[-5, 0) and xx on [0,5][0, 5] — the standard first example of a piecewise definition.
-5-335-33the absolute value, built from two pieces
Absolute value, frozen

Two linear pieces meeting at the origin, the filled dot swallowing the open circle: left limit, right limit, and value agree.

The seam at x=0x = 0 is where the verdict panel earns its keep: the left piece approaches 00, the right piece starts at 00, and the value belongs to the right piece — left limit, right limit, and value all agree, so the verdict is continuous. A filled dot swallows the open circle at the joint.

The result is a function smoother in definition than in geometry: perfectly continuous, yet with a corner where the slope snaps from 1-1 to +1+1. Continuity and differentiability part ways exactly here.

Rebuilding a familiar function from pieces is the preset's real lesson: many "single" functions are piecewise underneath.

The Heaviside Step

The Heaviside preset is the minimal jump: 1-1 on [5,0)[-5, 0), then 11 on [0,5][0, 5] — one boundary, two constant pieces, and no way to bridge them.
-5-335-33the Heaviside step
Heaviside step, frozen

One boundary, two constants: the open circle at (0, −1) against the filled dot at (0, 1) is the minimal jump.

At x=0x = 0 the left limit is 1-1, the right limit (and value) is 11: a jump discontinuity, flagged by the verdict panel with both one-sided limits spelled out. The open circle at (0,1)(0, -1) against the filled dot at (0,1)(0, 1) is the whole story in two markers.

No repair is possible — redefining the value at one point cannot close a gap between two different limits. Contrast the removable hole, where a one-point fix genuinely works.

The step function is the atom of switching: signal processing, control theory, and probability all build on it.

The Sign Function

The sign preset needs three pieces, one of them extreme: 1-1 on [5,0)[-5, 0), the single point {0}\{0\} mapped to 00, and 11 on (0,5](0, 5].
-5-335-33the sign function (three pieces)
Sign function, frozen

Three pieces including a single-point interval: the lone filled dot at the origin between two open circles.

The middle piece is a degenerate closed interval — one point of domain, drawn as a lone filled dot at the origin between two open circles. The builder accepts it because a single-point interval [0,0][0, 0] with both ends closed is a perfectly legal piece.

The verdict is a double jump: left limit 1-1, right limit 11, value 00 — three different numbers meeting at one xx. Neither one-sided limit matches the value, so this is a jump, not a removable point.

The Heaviside step is sign's two-piece sibling; sign adds the honest middle value that makes the function odd.

The Sawtooth

The sawtooth chains three parallel lines — x+2x + 2, xx, x2x - 2 — each resetting where the previous one leaves off, producing the repeating ramp of signal generators.
-5-335-33a three-piece sawtooth
Sawtooth, frozen

Three parallel ramps, each restarting two units lower — two identical jump events in one window.

Every seam is the same event: the outgoing piece climbs to an open circle, the incoming piece restarts 22 lower with a filled dot. Two jump discontinuities in one window, each reported separately in the boundary report.

All three pieces share slope 11 — the discontinuity is entirely in the values, not the direction. A sawtooth is a linear function that keeps getting interrupted.

Periodic resets like this are how oscilloscopes sweep and how modular arithmetic looks when graphed — the fractional-part function xxx - \lfloor x \rfloor is an infinite sawtooth.

The Removable Hole

The hole preset splits the line y=xy = x at x=1x = 1 into [5,1)[-5, 1) and (1,5](1, 5] — both pieces open at the seam, so the point x=1x = 1 belongs to no piece at all.
-5-335-33a removable hole at x = 1
Removable hole, frozen

An unbroken line except for one open circle at x = 1: both limits agree, only the value is missing.

Both one-sided limits equal 11; only the value is missing. The verdict panel classifies the seam as a gap — the function is simply undefined there — and the plot shows the cleanest possible puncture: one open circle on an otherwise unbroken line.

The fix is one click: close either endpoint and the hole fills, the verdict flipping to continuous. That repairability is what "removable" means — and precisely what the jump lacks, where no single value can reconcile two different limits.

Removable singularities are the piecewise picture of the rational-function situation (x1)(x+2)x1\frac{(x-1)(x+2)}{x-1}: identical to a simpler function everywhere except one missing point.

The Jump Discontinuity

The jump preset runs x+1x + 1 into x1x - 1 at x=0x = 0: two parallel lines offset by 22, meeting at a seam they cannot share.
-5-335-33a jump at x = 0
Jump discontinuity, frozen

Two parallel lines offset by 2: the gap between the one-sided limits is the jump height itself.

Left limit 11, right limit 1-1, value 1-1: the verdict reads well-defined, with jumps — every input has exactly one output, so this is a legitimate function; it just is not continuous. Well-definedness and continuity are separate certificates, and this preset holds one without the other.

The jump height (22 here) is the gap between the one-sided limits — the quantity the boundary report states as "left = 1, right = −1".

Together with the hole, this preset completes the discontinuity taxonomy the tool can produce: value missing (gap), value wrong (removable), limits disagreeing (jump).