Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools

Piecewise Function Calculator

How to use
  1. Type the left piece in the L(x)L(x) box and the right piece in the R(x)R(x) box, for example x2x^2 and 2x−12x - 1. Learn more about entering the pieces
  2. Set Break at x =: the left piece is used for xx below this number, the right piece from this number on.
  3. Read the function written with a brace under The function, and the verdict under At the break: smooth, a corner, or a jump and its size. Learn more about reading the answer
  4. Look at the graph: the left piece is blue and ends in a hollow dot, the right piece is amber and starts with a filled dot.

Piecewise function
The function
p(x)={x2x<1x+2x≥1\displaystyle p(x) = \begin{cases} {x}^{2} & x < 1 \\ x+2 & x \geq 1 \end{cases}
At the break x = 1
jump of 2\displaystyle \text{jump of } 2
How it was found

From the left, the left piece heads for 11. At the break and to its right, the right piece gives 33.

The two values differ, so lim⁡x→1p(x)\lim_{x \to 1} p(x) does not exist: a jump of 22.

Adding −2-2 to the right piece would close it.

The right piece owns the break point (filled dot); the left piece stops just short of it (hollow dot).

Drawn by the tool
x2,x<1{x}^{2}, \quad x < 1read-only
x+2,x≥1x+2, \quad x \geq 1read-only
x2,x<1{x}^{2}, \quad x < 1
x+2,x≥1x+2, \quad x \geq 1


Building a piecewise function

DemoBuild a piecewise function
Step 0 of 4
The calculator builds a function from two pieces and one break point cc:

p(x)={L(x)x<cR(x)x≥cp(x) = \begin{cases} L(x) & x < c \\ R(x) & x \geq c \end{cases}


Type the formula used on the left in the L(x)L(x) box, the formula used on the right in the R(x)R(x) box, and the break point in Break at x =. Each piece can be any formula: a constant, a line, a parabola, a root, a sine.

The graph shows each piece only on its own side. Change the break point and the place where one formula hands over to the other slides along the xx-axis.

Reading the answer

DemoJump, corner, smooth
Step 0 of 4
    The function shows p(x)p(x) in the usual brace notation, each formula with the condition that tells when it is used.

    At the break gives one of three verdicts:

  • Continuous and smooth: the pieces meet at the same height and with the same slope.
  • Continuous, with a corner: they meet at the same height, but the slope changes suddenly.
  • Jump of a given size: the left piece heads for one height and the right piece starts at another. The size is the distance between the two.

  • On the graph the left piece is blue and the right piece amber. At the break, the right piece carries a filled dot, because x=cx = c belongs to it; the left piece ends in a hollow dot, because it stops just short of cc. When the pieces join, the two dots coincide.

    How it was found gives the two heights at the break, the two slopes when they matter, and, for a jump, the number that would close it.

What a piecewise function is

A piecewise function is a single function defined by different formulas on different parts of its domain. To evaluate it, first decide which part the input is in, then use that part's formula.

For

p(x)={x2x<12x−1x≥1p(x) = \begin{cases} x^2 & x < 1 \\ 2x - 1 & x \geq 1 \end{cases}


p(−2)p(-2) uses the first line, since −2<1-2 < 1: p(−2)=4p(-2) = 4. p(3)p(3) uses the second: p(3)=5p(3) = 5. And p(1)p(1) uses the second too, because the condition x≥1x \geq 1 includes 11: p(1)=1p(1) = 1.

It is still one function: every input gets exactly one output, because the conditions do not overlap.
x2x^2 for x<1x < 1 (blue), then 2x−12x - 1 from 11 on (amber).

Who owns the break point

Exactly one piece must include the break point, otherwise the function would have two values there, or none.

In this calculator the right piece owns it: the conditions are x<cx < c and x≥cx \geq c. On the graph that is the filled dot at the start of the right piece and the hollow dot at the end of the left one.

The choice matters only when there is a jump. If the pieces meet at the same height, the value at cc is the same whichever piece supplies it.
A step from 11 to 33 at x=2x = 2: the value there is 33, the filled dot.

Continuity at the break

A piecewise function is continuous at the break when the graph can be drawn through it without lifting the pen. That needs the two pieces to arrive at the same height:

lim⁡x→c−L(x)=R(c).\lim_{x \to c^-} L(x) = R(c).


With L(x)=x+1L(x) = x + 1, R(x)=x−1R(x) = x - 1 and c=0c = 0: the left piece heads for 11, the right piece starts at −1-1. The heights differ, so there is a jump of 22, and the limit of pp at 00 does not exist.

To make two pieces fit, set the heights equal and solve. For L(x)=x2L(x) = x^2 and R(x)=x+kR(x) = x + k at c=1c = 1: 1=1+k1 = 1 + k, so k=0k = 0.
x+1x + 1 on the left, x−1x - 1 on the right: a jump of 22 at 00.

Corners and smooth joins

Meeting at the same height is not the whole story. ∣x∣|x| is the piecewise function with L(x)=−xL(x) = -x, R(x)=xR(x) = x and break at 00. The pieces meet at (0, 0)(0,\ 0), but the slope is −1-1 on the left and 11 on the right: the graph has a corner, and the function has no derivative there.

A join is smooth when the slopes agree as well. x2x^2 and 2x−12x - 1 at c=1c = 1 both have the value 11 and both have the slope 22: the line continues the parabola as its tangent, and the eye cannot find the break.

So there are two conditions, one after the other: equal heights for continuity, then equal slopes for smoothness.
∣x∣|x| as two pieces: continuous at 00, with a corner.

Where piecewise functions appear

  • Absolute value: ∣x∣|x| is −x-x for x<0x < 0 and xx for x≥0x \geq 0.
  • Step functions: a constant on each stretch, with a jump between them, such as a postage price by weight.
  • Rates that change at a threshold: a tax of one percentage up to some income and a higher one above it; a phone plan with a flat fee up to a limit and a charge per unit after it.
  • Motion in stages: a constant speed, then braking.

  • In each case the rule itself changes at a known point, and a single formula would hide that.

Common mistakes

  • Using both formulas at the break. Only the piece whose condition includes cc gives the value there.
  • Drawing each formula over the whole axis. Each piece is drawn only where its condition holds.
  • Forgetting the dots. A hollow dot marks a height that is approached but not taken; a filled dot marks the actual value.
  • Calling a corner a discontinuity. ∣x∣|x| is continuous at 00; it is only not smooth.
  • Checking continuity with the wrong value. Compare what the left piece heads for at cc with what the right piece gives at cc, not values somewhere nearby.