Updated · By Pete Bromfield, former Head of Maths with IB examining experience

IA modelling, step by step · Piecewise

Piecewise model, step by step: when the rule changes part-way

AA SLAA HLAI SLAI HL

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.

Example data: water temperature and time
ix: Time (min)y: Water temperature (°C)
1018.4
2127.6
3237.3
4346.5
5456.2
6565.3
7675
8784.1
9893.8
10998.9
111099.2
121199
131299.1
141398.9
Scatter graph of water temperature against time for the example data
Step 1 of any modelling IA: plot the data and describe the shape before fitting anything.

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

Sums for the least-squares line
ixyx²xyy²
1018.400338.56
2127.6127.6761.76
3237.3474.61391.29
4346.59139.52162.25
5456.216224.83158.44
6565.325326.54264.09
7675364505625
8784.149588.77072.81
9893.864750.48798.44
Σ36504.22042582.133572.64

n = 9 points.

Graph of the data with the fitted piecewise (two lines) (piecewise model)
Split, fit each piece, join: the fitted curve over the example data.

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.

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

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.