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.
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.
Sub-functions
Domain Restrictions
Boundary Points
Continuity (Optional)
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.
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.
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.
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.
| Real-World Context | What Changes | Boundary Trigger |
|---|---|---|
| Tax brackets | Tax rate applied to income | Income thresholds |
| Shipping costs | Rate per kg or flat fee | Weight limits |
| Speed limits on a road | Maximum legal speed | Location along the road |
| Mobile data plans | Cost per GB | Data usage threshold |
| Depth vs. water pressure | Pressure equation | Phase 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.
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 | Limitations |
|---|---|
| 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-function | Errors often occur at boundary points if students forget to check which inequality (< vs. ≤) applies |
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.
| SL 2.5 Concept | Advanced Extension | Where You'll See It |
|---|---|---|
| Evaluating a piecewise function at a point | Limits and left/right-hand limits at boundary points | HL Calculus, university calculus |
| Checking continuity by matching outputs | Formal ε-δ definition of continuity | University analysis |
| Piecewise linear models | Spline interpolation (smooth curves through data) | Computer graphics, data science |
| Absolute value function | ReLU activation function in neural networks | Machine learning, AI |
| Real-world modelling with thresholds | Step functions and Heaviside function in engineering | Signal 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
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.