IA modelling, step by step · Piecewise
Piecewise model, step by step: when the rule changes part-way
Some data follow one rule and then another: water heats steadily and then boils, a tariff changes at a threshold, a runner speeds up for the finish. Split the domain where the context says the rule changes, fit each piece, and join them.
Example data, invented for this guide. The context is realistic, but the numbers were made up to show the method. Use your own measured or sourced data in your IA.
When to use it
The shape of the data
- A sudden change of gradient (a kink) or a change of shape part-way through.
- One model fits the first part well but clearly fails on the rest.
The context
- A physical change of state (heating then boiling, melting).
- Rules with thresholds: tax bands, tariffs, speed limits.
- A process with phases: acceleration then steady speed.
Course fit: AI HL (piecewise models); domain notation is used everywhere. Justifying the split from the context is what makes it strong at any level.
The example data
A pan of water is heated on a hob at a constant setting; a thermometer is read every minute until it has been boiling for a few minutes.
| i | x: Time (min) | y: Water temperature (°C) |
|---|---|---|
| 1 | 0 | 18.4 |
| 2 | 1 | 27.6 |
| 3 | 2 | 37.3 |
| 4 | 3 | 46.5 |
| 5 | 4 | 56.2 |
| 6 | 5 | 65.3 |
| 7 | 6 | 75 |
| 8 | 7 | 84.1 |
| 9 | 8 | 93.8 |
| 10 | 9 | 98.9 |
| 11 | 10 | 99.2 |
| 12 | 11 | 99 |
| 13 | 12 | 99.1 |
| 14 | 13 | 98.9 |
The method: split, fit each piece, join
The water heats at a steady rate until it boils, then stays at boiling point. Split after x = 8 (the last reading before the temperature stops rising), fit a line to the first piece and a constant to the second, then find where they meet.
Step 1 · Split the domain
Split the data where the behaviour changes (from the graph and the context): piece 1 for x ≤ 8 (9 points), piece 2 for x > 8 (5 points).
Step 2 · Tabulate the sums for piece 1
| i | x | y | x² | xy | y² |
|---|---|---|---|---|---|
| 1 | 0 | 18.4 | 0 | 0 | 338.56 |
| 2 | 1 | 27.6 | 1 | 27.6 | 761.76 |
| 3 | 2 | 37.3 | 4 | 74.6 | 1391.29 |
| 4 | 3 | 46.5 | 9 | 139.5 | 2162.25 |
| 5 | 4 | 56.2 | 16 | 224.8 | 3158.44 |
| 6 | 5 | 65.3 | 25 | 326.5 | 4264.09 |
| 7 | 6 | 75 | 36 | 450 | 5625 |
| 8 | 7 | 84.1 | 49 | 588.7 | 7072.81 |
| 9 | 8 | 93.8 | 64 | 750.4 | 8798.44 |
| Σ | 36 | 504.2 | 204 | 2582.1 | 33572.64 |
n = 9 points.
In the full worked example
- The rest of the method: steps 3 to 8 and the residual plot
- What the model tells you, in context
- GDC key sequences: TI-84 Plus CE, TI-Nspire CX and Casio fx-CG50
- Desmos regression syntax
- How to write it up in your IA
- Common mistakes
- Is this good enough for Criterion E? The checklist
Evaluate this model
Questions to answer in your own words, about your own data. They are prompts, not sentences to copy.
- Is there a reason in the context for each split, and is the split point supported by the data?
- Should the pieces meet? Does the model jump where reality does not?
Then work through the general questions on evaluating a model (extrapolation, the parameters, residuals, comparing models, outliers, assumptions and improvements) and the notes on accuracy and rounding. In the free Grapher, fit the model with ~ and open “What this model means” for the same prompts with your own numbers.
IA ideas that use a piecewise model
Explorations from our idea list whose mathematics includes this model. Each research question is a starting point to make your own.
- Does my phone battery really drain in a straight line?: Is my phone's battery percentage over a day of normal use better described by a linear, piecewise-linear or exponential model, and can the best model predict when the phone will die?
- Contract or SIM-only? The real cost of a new phone: For a particular phone, is a 24-month contract cheaper than buying the phone outright (or with a loan) plus a SIM-only plan, once resale value and interest are included?
- How much does a cold month cost my family?: How strongly is my home's monthly gas (or electricity) use related to the average outside temperature, and at what temperature does heating effectively switch off?
- How much vaccination is enough to stop measles?: Across countries, how is measles incidence related to vaccination coverage, and is there evidence of a threshold near the herd-immunity level predicted by R₀?
- Modelling bacterial growth in the biology lab: Does the growth of a harmless bacterial culture (measured by optical density or colony counts) follow a logistic model, and what doubling time does the exponential phase give?
- How fast did COVID-19 spread at the start? Comparing doubling times: What were the doubling times of confirmed COVID-19 cases in the first 30 days after the 100th case in [several countries], and how did they change after lockdown measures?
How this earns marks
A piecewise model can earn marks under every criterion: the fit and its explanation under Criterion E, your judgement of it (residuals, the domain, what the parameters mean) under Criterion D, and the reasons you chose it under Criterion C. What examiners look for, criterion by criterion and the mistakes that cost marks are on the modelling guide.
Get feedback on your write-up Self-check your draft Model my data
Frequently asked questions
Where should I split the data for a piecewise model?
Where the context says the rule changes (boiling, a tariff threshold), confirmed by the graph. Then check how much the parameters change if you move the split by one point.
Next steps
- Criterion E: use of mathematicsWhat “maths at the level of the course” means for a model, at SL and HL.
- Criterion D: reflectionJudging a model: residuals, comparisons, limitations and implications.
- Self-check your draftTick through the criteria for your own exploration.
- Get feedback on your write-upCriterion-by-criterion feedback on your draft, with evidence from your own text.
Related models: Straight line y = mx + c · Cubic and polynomials (and overfitting) · Choosing and comparing models. Or model your own data, and see what the IA package adds.
Free: the IA checklist, criterion by criterion
Every check for Criteria A–E in a 4-page PDF, the mistakes that cost the most marks and a self-assessment grid. We'll email it to you, and for three weeks your weekly email carries one IA tip, timed to your deadline if you give it. Free — no account, no payment.
While you wait for the email: read the full modelling workflow →