Piecewise Functions: Graphs, Continuity & Examples

#Calculus
TL;DR
Piecewise functions use different sub-rules on different parts of the domain, written with a single brace as f(x)={…f(x) = \begin{cases} \dots \end{cases}. To evaluate one, pick the rule whose condition matches the input. At a breakpoint x=cx = c the function is continuous when the left limit, the right limit, and f(c)f(c) all agree, and differentiable when the one-sided derivatives also agree. Continuity does not guarantee differentiability: ∣x∣|x| is continuous at 00 but has a corner there.
BT
Bhanzu TeamLast updated on September 23, 202613 min read

What Is A Piecewise Function?

A piecewise function is a single function defined by different sub-rules on different parts of its domain. Each sub-rule comes with a condition that says which inputs it governs, and the pieces are collected under one brace:

f(x)={x2if x≤1 2x−1if x>1f(x) = \begin{cases} x^2 & \text{if } x \le 1 \ 2x - 1 & \text{if } x > 1 \end{cases}

Read it as an instruction: if the input is 11 or smaller, apply x2x^2; if the input is larger than 11, apply 2x−12x - 1. The value x=1x = 1 where the rule changes is called a breakpoint (or boundary point). Everything difficult about piecewise functions happens at the breakpoints, so the conditions there have to be read exactly, including whether the boundary uses ≤\le or <<.

The idea sits inside the broader family of types of functions: a piecewise function is not a new kind of object, it is an ordinary function whose formula simply changes from region to region. Many familiar functions are secretly piecewise, including the absolute value and every step function.

How Do You Evaluate A Piecewise Function?

To evaluate a piecewise function, find the single condition the input satisfies, then substitute into that rule and no other. Using the wrong piece at the boundary is the most common error, so check the condition before you compute.

Take a three-rule example:

g(x)={−xif x<0 x2if 0≤x≤2 5if x>2g(x) = \begin{cases} -x & \text{if } x < 0 \ x^2 & \text{if } 0 \le x \le 2 \ 5 & \text{if } x > 2 \end{cases}

Example 1: Evaluate g(−3)g(-3), g(0)g(0), g(2)g(2), and g(4)g(4).

g(−3):;−3<0  ⟹  g(−3)=−(−3)=3g(-3): ; -3 < 0 \implies g(-3) = -(-3) = 3

g(0):;0≤0≤2  ⟹  g(0)=02=0g(0): ; 0 \le 0 \le 2 \implies g(0) = 0^2 = 0

g(2):;0≤2≤2  ⟹  g(2)=22=4g(2): ; 0 \le 2 \le 2 \implies g(2) = 2^2 = 4

g(4):;4>2  ⟹  g(4)=5g(4): ; 4 > 2 \implies g(4) = 5

Final answer: g(−3)=3g(-3) = 3, g(0)=0g(0) = 0, g(2)=4g(2) = 4, g(4)=5g(4) = 5.

The only judgement call is at x=0x = 0 and x=2x = 2. Because the middle rule owns both endpoints (0≤x≤20 \le x \le 2), the squares win there, not the neighbouring pieces.

How Do You Graph A Piecewise Function?

To graph a piecewise function, draw each rule only over the interval its condition allows, then mark the endpoints. A filled (closed) dot means the endpoint is included (≤\le or ≥\ge); an open (hollow) dot means it is excluded (<< or >>).

Consider a function built to jump:

h(x)={x+1if x<1 x2if x≥1h(x) = \begin{cases} x + 1 & \text{if } x < 1 \ x^2 & \text{if } x \ge 1 \end{cases}

  • Draw y=x+1y = x + 1 for every xx up to 11. As xx approaches 11 from the left, the height approaches 1+1=21 + 1 = 2, but x=1x = 1 is excluded, so place an open dot at (1,2)(1, 2).

  • Draw y=x2y = x^2 from x=1x = 1 onward. At x=1x = 1 the height is 12=11^2 = 1, and x=1x = 1 is included, so place a closed dot at (1,1)(1, 1).

The graph lifts from height 11 to height 22 at the boundary, a jump discontinuity. Geometrically, you cannot draw hh through x=1x = 1 without lifting your pen, which is the visual signature of a break.

Is A Piecewise Function Continuous At A Breakpoint?

A piecewise function is continuous at a breakpoint x=cx = c when three things hold at once:

  1. f(c)f(c) is defined (the piece that owns cc produces a value).

  2. The two-sided limit exists, which for a breakpoint means the left and right limits agree: lim⁡x→c−f(x)=lim⁡x→c+f(x)\lim_{x \to c^-} f(x) = \lim_{x \to c^+} f(x).

  3. That common limit equals the function value: lim⁡x→cf(x)=f(c)\lim_{x \to c} f(x) = f(c).

Geometrically, all three together say the graph arrives at the same height from both sides and actually lands there, so no pen-lift is needed.

Example 2: Check continuity of ff at the breakpoint x=1x = 1, where f(x)={x2x≤1 2x−1x>1f(x) = \begin{cases} x^2 & x \le 1 \ 2x - 1 & x > 1 \end{cases}

f(1)=12=1(the x≤1 piece owns x=1)f(1) = 1^2 = 1 \quad (\text{the } x \le 1 \text{ piece owns } x = 1)

lim⁡x→1−f(x)=lim⁡x→1−x2=1\lim_{x \to 1^-} f(x) = \lim_{x \to 1^-} x^2 = 1

lim⁡x→1+f(x)=lim⁡x→1+(2x−1)=2(1)−1=1\lim_{x \to 1^+} f(x) = \lim_{x \to 1^+} (2x - 1) = 2(1) - 1 = 1

All three values equal 11, so ff is continuous at x=1x = 1. Compare this with hh from the graphing section, where the left limit was 22 and the value was 11: unequal, so hh fails condition 3 and is discontinuous. For the wider picture of where this breaks, see discontinuous functions.

Is A Piecewise Function Differentiable At A Breakpoint?

Continuity is necessary but not sufficient for differentiability. A piecewise function is differentiable at a breakpoint x=cx = c when it is continuous there and the one-sided derivatives match:

lim⁡x→c−f′(x)=lim⁡x→c+f′(x)\lim_{x \to c^-} f'(x) = \lim_{x \to c^+} f'(x)

Geometrically, the derivative is the slope of the tangent line, so this condition says both pieces arrive at the join with the same slope, leaving one smooth tangent instead of a corner. A single well-defined tangent means the graph is smooth through the breakpoint. The derivative itself is the tool doing the checking.

Example 3: Is the same ff differentiable at x=1x = 1?

Differentiate each piece:

f′(x)={2xx<1 2x>1f'(x) = \begin{cases} 2x & x < 1 \ 2 & x > 1 \end{cases}

Left slope: lim⁡x→1−2x=2Right slope: lim⁡x→1+2=2\text{Left slope: } \lim_{x \to 1^-} 2x = 2 \qquad \text{Right slope: } \lim_{x \to 1^+} 2 = 2

The slopes agree at 22, and we already showed ff is continuous at x=1x = 1, so ff is differentiable there with f′(1)=2f'(1) = 2. This function is both continuous and smooth at its breakpoint.

Example 4: The absolute value function is continuous but not differentiable at 00.

Written piecewise, the absolute value function is:

∣x∣={−xif x<0 xif x≥0|x| = \begin{cases} -x & \text{if } x < 0 \ x & \text{if } x \ge 0 \end{cases}

Continuity at 00: the left limit is lim⁡x→0−(−x)=0\lim_{x \to 0^-}(-x) = 0, the right limit is lim⁡x→0+x=0\lim_{x \to 0^+} x = 0, and ∣0∣=0|0| = 0, so all three agree and ∣x∣|x| is continuous at 00.

Differentiability at 00: differentiate each piece and read the one-sided slopes.

ddx(−x)=−1ddx(x)=+1\frac{d}{dx}(-x) = -1 \qquad \frac{d}{dx}(x) = +1

Left slope =−1≠+1=right slope\text{Left slope } = -1 \neq +1 = \text{right slope}

The slopes disagree, so ∣x∣|x| is not differentiable at 00. The graph makes a sharp corner (a V) there, and a corner has no single tangent line. This is the standard proof that continuity does not imply differentiability.

Table: Reading the breakpoint of a piecewise function.

At the breakpoint x=cx = c

Left = right limit = f(c)f(c)?

One-sided slopes equal?

Result

Jump (like hh above)

No

Not applicable

Discontinuous

Corner (like ∣x∣\lvert x\rvert)

Yes

No

Continuous, not differentiable

Smooth join (like ff above)

Yes

Yes

Continuous and differentiable

What Are Absolute Value And Step Functions As Piecewise Functions?

Two of the most-used functions in a first calculus course are piecewise underneath.

  • Absolute value, ∣x∣|x|, is the two-piece function above. It is the model example of a continuous function with a corner, and it appears wherever a distance or a magnitude is needed.

  • The Heaviside step function turns something on at a threshold:

H(x)={0if x<0 1if x≥0H(x) = \begin{cases} 0 & \text{if } x < 0 \ 1 & \text{if } x \ge 0 \end{cases}

HH jumps from 00 to 11 at the origin, so it is discontinuous at 00. It models a switch flicking on, a force applied at an instant, or a signal starting.

  • The greatest integer (floor) function, ⌊x⌋\lfloor x \rfloor, rounds down to the nearest integer and is a whole staircase of pieces, one flat step on each unit interval, jumping at every integer. It is covered in full at greatest integer function and floor and ceiling function. A close relative, the signum function, reports only the sign of its input as −1-1, 00, or +1+1.

Why Do The Continuity And Differentiability Tests Work?

The two breakpoint tests are not arbitrary rituals. Each measures whether a specific kind of gap exists at the join.

  • The continuity test asks whether the two pieces reach the same height at the boundary. If the left piece climbs toward one value and the right piece starts at another, there is literally a vertical gap in the graph, and no amount of algebra hides it.

  • The differentiability test asks whether the two pieces arrive at the same slope. Even when the heights match, the pieces can meet at an angle, and an angle has no single tangent direction. The derivative from the left and the derivative from the right are then two different numbers, so the derivative at the corner does not exist.

This is why order matters: you check continuity first, because a broken graph cannot possibly be smooth. Differentiability is the stricter demand, height-agreement plus slope-agreement, which is exactly why a continuous corner like ∣x∣|x| still fails it. Continuity buys you an unbroken curve; differentiability then buys you a smooth one on top of that.

Who Shaped The Idea Of Piecewise Functions?

For a long time a "function" meant a single formula, and anything defined by parts looked like a mathematical cheat. That prejudice was overturned in the nineteenth century.

Two more figures shaped the tools this article uses:

  • Augustin-Louis Cauchy (1789–1857, France) defined continuity through limits, giving the exact three-part test that decides what happens at a breakpoint.

  • Oliver Heaviside (1850–1925, England) put the step function to work in physics and electrical engineering, making the humble two-piece switch one of the most-applied piecewise functions in science.

Where Are Piecewise Functions Used In The Real World?

Piecewise rules appear wherever behaviour changes past a threshold.

  • Taxation and economics: progressive income tax applies one marginal rate up to a limit and a higher rate above it. The tax owed is continuous at each threshold but has a corner, so it is a real-world case of continuous-yet-not-differentiable.

  • Shipping and utilities: postage that costs one price up to a weight and jumps at the next tier is a step function, discontinuous at each boundary.

  • Physics and engineering: a force switched on at an instant, or a circuit powered up, is modelled with the Heaviside step; control systems are full of such switches.

  • Computer graphics and machine learning: the ReLU activation max⁡(0,x)\max(0, x) used across neural networks is exactly the piecewise function that is 00 for negative inputs and xx otherwise, and it has a corner at 00 just like ∣x∣|x|.

  • Everyday pricing: phone plans, parking rates, and bulk discounts all switch rules at set thresholds.

One structure, a rule that changes at a boundary, runs tax codes, shipping tables, circuits, and the activations inside modern machine learning.

What Are The Most Common Mistakes With Piecewise Functions?

These three errors account for most lost marks, confirmed against VarsityTutors' continuity-and-piecewise lesson, the NumberAnalytics guide on piecewise continuity, and the Grokipedia entry on piecewise functions, and they match the questions students actually ask.

Using the wrong piece at the boundary.

Where it slips in:

At a breakpoint, a student grabs the neighbouring rule instead of the one whose condition actually contains the point, misreading ≤\le as <<.

Don't do this:

Do not guess which piece owns the endpoint. The inequality decides it, and only one piece may claim any given input.

The correct way:

Read the condition first. For gg above, x=2x = 2 satisfies 0≤x≤20 \le x \le 2, so use x2x^2 to get g(2)=4g(2) = 4, not the x>2x > 2 rule.

Confusing "defined in pieces" with "continuous."

Where it slips in:

A student assumes that because the function has a formula everywhere, its graph must connect at the breakpoints.

Don't do this:

Do not skip the limit check. A piecewise-defined function is often discontinuous, exactly where the pieces reach different heights.

The correct way:

Test all three conditions at each breakpoint: left limit, right limit, and f(c)f(c) must be equal. If they are not, the function jumps there.

Assuming continuity implies differentiability.

Where it slips in:

Having shown a function is continuous at a breakpoint, a student concludes the derivative exists there too.

Don't do this:

Do not stop at continuity. A continuous graph can still have a corner, and a corner has no derivative.

The correct way:

After continuity passes, compare the one-sided derivatives. For ∣x∣|x| at 00 they are −1-1 and +1+1, so despite being continuous the function is not differentiable there.

Practice Problems On Piecewise Functions

Answers follow each problem.

  1. For f(x)={x2+1x<0 2xx≥0f(x) = \begin{cases} x^2 + 1 & x < 0 \ 2x & x \ge 0 \end{cases}, find f(−2)f(-2) and f(3)f(3).
    (Answer: f(−2)=(−2)2+1=5f(-2) = (-2)^2 + 1 = 5; f(3)=2(3)=6f(3) = 2(3) = 6.)

  2. Is the function in Problem 1 continuous at x=0x = 0?
    (Answer: left limit =02+1=1= 0^2 + 1 = 1, right limit =2(0)=0= 2(0) = 0, f(0)=0f(0) = 0; since 1≠01 \neq 0 it is discontinuous, a jump of size 11.)

  3. Find aa so that f(x)={ax+1x≤2 x2+3x>2f(x) = \begin{cases} ax + 1 & x \le 2 \ x^2 + 3 & x > 2 \end{cases} is continuous at x=2x = 2.
    (Answer: left value =2a+1= 2a + 1, right limit =22+3=7= 2^2 + 3 = 7; set 2a+1=72a + 1 = 7, so a=3a = 3.)

  4. Is f(x)={x2x≤1 2x−1x>1f(x) = \begin{cases} x^2 & x \le 1 \ 2x - 1 & x > 1 \end{cases} differentiable at x=1x = 1?
    (Answer: yes; it is continuous there and the one-sided slopes are 2x∣1=22x\big|_{1} = 2 and 22, which match, so f′(1)=2f'(1) = 2.)

  5. Evaluate the floor function at ⌊2.7⌋\lfloor 2.7 \rfloor and ⌊−1.3⌋\lfloor -1.3 \rfloor.
    (Answer: ⌊2.7⌋=2\lfloor 2.7 \rfloor = 2; ⌊−1.3⌋=−2\lfloor -1.3 \rfloor = -2, since floor rounds down.)

  6. A two-bracket tax charges 10%10\% on income up to 10,00010{,}000 and 12%12\% on the amount above. Write the tax T(x)T(x) as a piecewise function and state whether it is continuous at 10,00010{,}000.(Answer: T(x)={0.10x0≤x≤10000 1000+0.12(x−10000)x>10000T(x) = \begin{cases} 0.10x & 0 \le x \le 10000 \ 1000 + 0.12(x - 10000) & x > 10000 \end{cases}; at x=10000x = 10000 both pieces give 10001000, so it is continuous, though the slopes 0.100.10 and 0.120.12 differ, giving a corner.)

Where Should You Go Next After Piecewise Functions?

Piecewise functions sit right where algebra meets calculus, and several natural doors open from here.

  1. Discontinuous functions. Classify the breaks a piecewise function can have, jump, removable, and infinite discontinuities.

  2. Absolute value function. The cleanest example of a continuous function with a corner, studied on its own.

  3. Greatest integer function. A full staircase of pieces, the model step function for practising breakpoints.

If your child is meeting continuity and differentiability for the first time, a live Bhanzu trainer builds piecewise functions from the graph up, so the breakpoint tests come from seeing the corner rather than memorising a rule, in the Bhanzu math tutoring program.

Was this article helpful?

Your feedback helps us write better content

Frequently Asked Questions

What is a piecewise function in simple terms?
A piecewise function is one function made of several rules, each used on its own part of the domain. You choose the rule whose condition matches the input, then apply only that rule.
How do you know which piece to use?
Read the inequality attached to each rule and find the one the input satisfies. Every input belongs to exactly one piece, so a boundary like ≤\le versus << decides which rule owns the endpoint.
Are piecewise functions always continuous?
No. Being defined in pieces says nothing about continuity. A piecewise function is continuous at a breakpoint only when the left limit, right limit, and function value all agree there; otherwise the graph jumps.
Can a piecewise function be differentiable at a breakpoint?
Yes, when it is both continuous there and the one-sided derivatives match, as with x2x^2 joined to 2x−12x - 1 at x=1x = 1. If the slopes differ, as with ∣x∣|x| at 00, the function has a corner and is not differentiable.
Is the absolute value function a piecewise function?
Yes. The absolute value function equals −x-x for negative inputs and xx for non-negative inputs, so it is a two-piece function. It is continuous everywhere but not differentiable at 00, where its graph forms a corner.
What is the difference between continuity and differentiability for piecewise functions?
Continuity requires the pieces to meet at the same height (no gap); differentiability also requires them to meet at the same slope (no corner). Differentiability is the stronger condition, so every differentiable point is continuous, but not the reverse.
✍️ Written By
BT
Bhanzu Team
Content Creator and Editor
Bhanzu’s editorial team, known as Team Bhanzu, is made up of experienced educators, curriculum experts, content strategists, and fact-checkers dedicated to making math simple and engaging for learners worldwide. Every article and resource is carefully researched, thoughtfully structured, and rigorously reviewed to ensure accuracy, clarity, and real-world relevance. We understand that building strong math foundations can raise questions for students and parents alike. That’s why Team Bhanzu focuses on delivering practical insights, concept-driven explanations, and trustworthy guidance-empowering learners to develop confidence, speed, and a lifelong love for mathematics.
Related Articles
Book a FREE Demo ClassBook Now →