IB MATHEMATICS: APPLICATIONS AND INTERPRETATION • FUNCTIONS

Piecewise Functions — SL 2.5 Piecewise functions and real-world modelling

Learn how combining simple functions into pieces lets you model real-world situations that no single formula can capture.

Historical Context & Motivation

Mathematics has always tried to describe the world with neat, tidy equations. A single formula like y = 2x + 3 works beautifully for a straight line, but real life is rarely that simple. Consider the way your phone plan charges you: maybe the first 5 GB of data are included free, and then each additional GB costs $10. No single linear equation captures that billing structure. You need different rules for different intervals — and that's exactly the idea behind piecewise functions.

The need to stitch together multiple formulas has ancient roots, but the formal language we use today developed over centuries of mathematical progress. From early tax tables to modern engineering models, mathematicians have continually refined how they define functions that behave differently across distinct regions of their domain.

1700s
Euler & the Vibrating String Debate
Leonhard Euler and Daniel Bernoulli debated whether a function defined by different formulas on different intervals could truly be called a single function. This controversy pushed mathematicians to clarify the very definition of a function.
1837
Dirichlet's Modern Definition
Peter Gustav Lejeune Dirichlet proposed the modern definition of a function as a rule that assigns each input exactly one output. This definition naturally accommodated piecewise rules, since the rule could change from one interval to the next.
1900s
Engineering & Applied Modelling
Engineers began using piecewise functions extensively to model systems with thresholds — circuits that switch on at a certain voltage, materials that behave differently under varying stress, and tax codes with graduated brackets.
2000s
Digital & Data-Driven Models
Today, piecewise functions appear in machine learning (ReLU activation functions), app-based pricing models, shipping rate calculators, and environmental regulations — making them one of the most practically useful function types in modern applied mathematics.

The central question that piecewise functions answer is this: How do we write a single, well-defined function when the rule that governs it changes at certain boundary points? As you will see, the answer is both elegant and deeply practical.

Core Principles & Definitions

A piecewise function is a function that is defined by two or more sub-functions, each applying to a specific interval of the domain. Instead of one formula covering all possible input values, you use different formulas for different sections. The key is that for every input value in the domain, exactly one sub-function applies — so the piecewise function still assigns each input precisely one output, which means it is indeed a valid function.

1

Sub-functions

Each "piece" is a sub-function (linear, quadratic, constant, etc.) defined on a specific interval. The sub-functions can be any type, as long as each one has a clear rule.
2

Domain Restrictions

Each sub-function has a stated domain (e.g., x < 3 or x ≥ 3). These intervals must cover the entire domain of the piecewise function with no overlaps — so every input is claimed by exactly one piece.
3

Boundary Points

The x-values where one sub-function ends and another begins are called boundary points (or breakpoints). At a boundary, you must check which piece "owns" that value using ≤ or < notation.
4

Continuity (Optional)

A piecewise function may or may not be continuous. If the pieces connect without a gap or jump at every boundary point, the function is continuous. If there's a jump, the function is discontinuous at that point.
KEY TAKEAWAY
Think of a piecewise function like the speed limits on a road trip. From your house to the highway, the limit might be 30 mph. On the highway, it jumps to 65 mph. Through a construction zone, it drops to 45 mph. Each segment of the road has its own rule, but together they form one complete speed-limit function for your entire journey. The "boundary points" are the road signs telling you where the rule changes.

Visual Explanation

Let's look at a concrete example. Consider the piecewise function defined as follows: f(x) = x + 2 when x < 1, and f(x) = −x + 4 when x ≥ 1. The diagram below shows how these two linear pieces join at the boundary point x = 1.

The cyan segment shows f(x) = x + 2 for x < 1, drawn with an open dot at the boundary. The pink segment shows f(x) = −x + 4 for x ≥ 1, drawn with a closed (filled) dot at x = 1. The dashed amber line marks the boundary. Notice the two pieces meet at (1, 3), so this piecewise function is continuous.

In the diagram, pay close attention to the dots at the boundary point. A closed (filled) dot means the function's value is defined at that x-value by that particular piece. An open (hollow) dot means the function approaches that point but does not include it for that piece. In this example, both pieces give y = 3 when x = 1, so the function is continuous at the boundary. If the two pieces gave different y-values at x = 1, there would be a visible gap or jump in the graph, making it discontinuous.

Mathematical Framework

The standard way to write a piecewise function uses a curly brace on the left side to group the sub-functions together. Each sub-function is paired with a condition on x that describes when it applies. Let's formalize the notation and then explore two important equations you will encounter in IB exams.

GENERAL PIECEWISE NOTATION
f(x) = { g(x), if condition₁ ; h(x), if condition₂ ; k(x), if condition₃ }
Here g(x), h(x), and k(x) are sub-functions (they can be linear, quadratic, constant, or any other type). The conditions are inequalities on x that partition the domain into non-overlapping intervals.
ABSOLUTE VALUE AS A PIECEWISE FUNCTION
|x| = { x, if x ≥ 0 ; −x, if x < 0 }
The absolute value function is the most common piecewise function. For non-negative inputs it returns the input unchanged; for negative inputs it negates the input to produce a positive result.
CONTINUITY CONDITION AT A BOUNDARY
lim(x→a⁻) f(x) = lim(x→a⁺) f(x) = f(a)
For a piecewise function to be continuous at boundary point x = a, the left-hand piece and the right-hand piece must both approach the same y-value, and the function must actually equal that value at x = a. In practice at the SL level, you simply substitute x = a into both sub-functions and check whether the outputs match.
💡 IB Exam Tip
When a problem asks you to "find the value of k such that f is continuous," set the two sub-functions equal at the boundary point and solve for k. For example, if f(x) = 2x + k for x < 3 and f(x) = x² for x ≥ 3, then set 2(3) + k = 3² to get 6 + k = 9, so k = 3.

Piecewise Functions in Real-World Modelling

The IB Applications and Interpretation course emphasizes using mathematics to model real situations. Piecewise functions are especially powerful here because many real-world systems have thresholds — values at which the rules change. Below is a diagram showing a common real-world example: a tiered electricity pricing model.

This diagram models electricity pricing with three tiers. The first 100 kWh cost $0.10 per kWh (green). The next 150 kWh cost $0.08 per kWh (blue). Usage above 250 kWh costs $0.06 per kWh (pink). The slopes decrease in each tier, reflecting decreasing marginal cost. The dashed amber lines mark the boundary points between tiers.

The pricing model above is a great example of why piecewise functions are essential. No single linear equation can capture the fact that the per-unit price changes at 100 kWh and again at 250 kWh. Notice that this piecewise function is continuous — the cost never jumps abruptly, because each tier starts exactly where the previous one ended. This is a very common feature in real-world models: price, tax, and speed rules usually connect smoothly to avoid confusion.

Common real-world scenarios modelled by piecewise functions
Real-World ContextWhat ChangesBoundary Trigger
Tax bracketsTax rate applied to incomeIncome thresholds
Shipping costsRate per kg or flat feeWeight limits
Speed limits on a roadMaximum legal speedLocation along the road
Mobile data plansCost per GBData usage threshold
Depth vs. water pressurePressure equationPhase change depth

Worked Example

A parking garage charges according to the following rules. The first 2 hours cost a flat rate of $5. Each additional hour (or part thereof) after 2 hours costs $3 per hour, up to a maximum charge of $20 for the day. We want to write the cost function C(t), where t is the time in hours, and then find the cost of parking for 6 hours.

Parking Garage Cost Function
1
Step 1 — Identify the pieces and boundary pointsThere are three distinct pricing rules. For the first 2 hours, the cost is fixed at $5 regardless of whether you park for 30 minutes or the full 2 hours. After 2 hours, additional time costs $3 per hour. However, the total charge is capped at $20. We need to find at what time the $20 cap kicks in. If the cost after 2 hours is 5 + 3(t − 2), we set 5 + 3(t − 2) = 20 and solve: 5 + 3t − 6 = 20 → 3t − 1 = 20 → 3t = 21 → t = 7. So the boundary points are t = 2 and t = 7.
Boundary points: t = 2 hours and t = 7 hours
2
Step 2 — Write each sub-functionPiece 1: For 0 ≤ t ≤ 2, C(t) = 5 (a constant function). Piece 2: For 2 < t ≤ 7, C(t) = 5 + 3(t − 2) = 3t − 1. Piece 3: For t > 7, C(t) = 20 (another constant function, the daily cap).
C(t) = { 5, if 0 ≤ t ≤ 2 ; 3t − 1, if 2 < t ≤ 7 ; 20, if t > 7 }
3
Step 3 — Verify continuity at t = 2From the left: C(2) = 5. From the right: C(2) = 3(2) − 1 = 5. Both pieces give 5 at t = 2, so the function is continuous at this boundary.
Continuous at t = 2 ✓
4
Step 4 — Verify continuity at t = 7From the left: C(7) = 3(7) − 1 = 20. From the right: C(7) = 20. Both pieces give 20 at t = 7, so the function is continuous at this boundary as well.
Continuous at t = 7 ✓
5
Step 5 — Evaluate C(6)Since 2 < 6 ≤ 7, we use the second piece: C(6) = 3(6) − 1 = 18 − 1 = 17.
C(6) = $17

Strengths & Limitations of Piecewise Models

Piecewise functions are among the most versatile tools in mathematical modelling, but like any model, they have trade-offs. Understanding when they work well — and when other approaches might be better — is an important part of mathematical literacy at the IB level.

Strengths vs. limitations of piecewise function models
StrengthsLimitations
Can model systems with abrupt changes in rules (thresholds, caps, tiers)Can become cumbersome if there are many pieces — the notation gets long and harder to work with
Each piece can use any function type (linear, quadratic, exponential, constant)Discontinuities can make analysis harder — derivatives may not exist at boundary points
Closely mirrors how many real-world rules are actually stated (tax laws, pricing schedules)Not always the best fit for gradual, smooth transitions — a single polynomial or logistic curve may be more appropriate
Easy to evaluate: just identify which interval the input falls in and use that sub-functionErrors often occur at boundary points if students forget to check which inequality (< vs. ≤) applies
KEY TAKEAWAY
Piecewise functions are the mathematical equivalent of an employee handbook: different chapters (pieces) apply to different situations (intervals), and the table of contents (the boundary conditions) tells you which chapter to read. They are best used when the real-world system genuinely has distinct rules that change at specific thresholds.

Connection to Advanced Topics

Piecewise functions are not just an SL 2.5 topic — they form the foundation for several more advanced mathematical ideas that you may encounter later in your studies or in HL Mathematics. Understanding piecewise functions now will give you a head start on these concepts.

How SL 2.5 concepts extend into advanced mathematics
SL 2.5 ConceptAdvanced ExtensionWhere You'll See It
Evaluating a piecewise function at a pointLimits and left/right-hand limits at boundary pointsHL Calculus, university calculus
Checking continuity by matching outputsFormal ε-δ definition of continuityUniversity analysis
Piecewise linear modelsSpline interpolation (smooth curves through data)Computer graphics, data science
Absolute value functionReLU activation function in neural networksMachine learning, AI
Real-world modelling with thresholdsStep functions and Heaviside function in engineeringSignal processing, control systems

The key takeaway from this table is that mastering piecewise functions at the SL level gives you a concrete, intuitive entry point into some of the most powerful ideas in higher mathematics and applied science. The notion that a function can behave differently on different parts of its domain — and that we can precisely describe those behaviors — is a recurring theme throughout mathematics.

Practice Problems

PROBLEM 1CONCEPTUAL
Explain in your own words why the absolute value function |x| is considered a piecewise function. How many pieces does it have, and what are the boundary points?
PROBLEM 2BASIC CALCULATION
Consider the piecewise function f(x) = { 2x + 1, if x < 3 ; 10 − x, if x ≥ 3 }. Find f(1), f(3), and f(7).
PROBLEM 3INTERMEDIATE
A function g is defined as g(x) = { x² − 1, if x ≤ 2 ; kx + 1, if x > 2 }. Find the value of k that makes g continuous at x = 2.
PROBLEM 4APPLIED
A ride-sharing app charges $4.00 as a base fare for any ride. For the first 5 km, the charge is $1.50 per km. After 5 km, the charge drops to $1.00 per km. Write a piecewise function C(d) for the total cost in dollars, where d is the distance in km. Then calculate the total cost of a 12 km ride.
PROBLEM 5CRITICAL THINKING
A student claims that every continuous piecewise function can be replaced by a single polynomial that gives the same outputs for all x-values. Is this claim true or false? Justify your answer with an example or counterexample.

Lesson Summary

A piecewise function is defined by multiple sub-functions, each governing a specific interval of the domain. The x-values where one sub-function ends and another begins are called boundary points. To evaluate f(a), you first determine which interval a belongs to, then substitute into the corresponding sub-function. When writing the function, use strict (<, >) and non-strict (≤, ≥) inequalities carefully so that every input is assigned to exactly one piece.

To check continuity at a boundary, substitute the boundary value into both adjacent sub-functions and verify that the outputs match. In real-world modelling — which is central to IB Applications and Interpretation — piecewise functions capture systems with thresholds, such as tax brackets, tiered pricing, and speed zones. On a graph, use open dots for excluded endpoints and closed dots for included endpoints to clearly communicate which piece applies at each boundary.

Varsity Tutors • IB Mathematics: Applications and Interpretation • Piecewise Functions — SL 2.5 Piecewise functions and real-world modelling