Free access until 31 December 2026 · Physics and Maths questions and notes, updated continuously · Build a test

ExaminerPrep › IB Maths AI › Notes

IB Maths AI · Topic 2 · 2.1 · SL and HL

Linear models and piecewise models

This note covers linear functions and models, including gradient, intercepts, equations of lines, parallel and perpendicular lines, and, at HL, piecewise models where different rules apply on different intervals. Linear models describe anything that changes at a steady rate, such as fares, depreciation and tariffs.

Key ideas

A linear function has a graph that is a straight line. It can be written as \(f(x)=mx+c\), where \(m\) is the gradient and \(c\) is the \(y\)-intercept. In context, \(m\) is the rate of change, the change in the output for each one-unit increase in the input, and \(c\) is the starting value when the input is 0. Always give both with units.

Gradient. Through the points \((x_1,y_1)\) and \((x_2,y_2)\), the gradient is

\[ m=\frac{y_2-y_1}{x_2-x_1} \]

A positive gradient means the line rises and a negative gradient means it falls.

Forms of the equation. Three forms are commonly used.

  • Gradient-intercept form: \(y=mx+c\).
  • Point-gradient form: \(y-y_1=m(x-x_1)\), useful when you know a point and the gradient.
  • General form: \(ax+by+d=0\) with \(a, b, d\) constants.

To find an equation from two points, calculate \(m\) and then substitute one point to find \(c\) (or use the point-gradient form).

Parallel and perpendicular lines. Parallel lines have equal gradients, \(m_1=m_2\). Perpendicular lines have gradients whose product is \(-1\), so \(m_2=-\dfrac{1}{m_1}\).

Intercepts. The \(y\)-intercept is found by setting \(x=0\). The \(x\)-intercept, which is the zero of the function, is found by setting \(y=0\). In a model, the \(x\)-intercept often marks when a quantity runs out.

Intersections. Two lines meet where their equations give the same value. Solve \(m_1x+c_1=m_2x+c_2\) by algebra, or draw both graphs on the GDC and use its intersection feature. This is how two options are compared, for example two phone plans.

Piecewise models (HL). A piecewise function uses different rules on different intervals of the input, for example

\[ f(x)=\begin{cases}8+0.15x & 0\le x\le100\\ 0.22x+1 & x\gt100\end{cases} \]

To evaluate it, first decide which interval the input lies in and then use that rule. To solve an equation, solve it on each piece separately and keep only solutions that lie within that piece's interval. A model is continuous where the pieces meet without a jump, which you test by checking that both rules give the same value at the boundary.

Domain and limits of a model. A model is only valid for sensible inputs. A depreciation model with a negative value is nonsense, and a fare model cannot use a negative distance. State the domain, and say whether answers outside it are meaningful.

Definitions and formulae

Term or formulaMeaning / when to use
\(f(x)=mx+c\)Linear model, with gradient \(m\) (rate of change) and intercept \(c\) (starting value).
\(m=\dfrac{y_2-y_1}{x_2-x_1}\)Gradient of the line through two points.
\(y-y_1=m(x-x_1)\)Equation of a line from a point and a gradient.
\(m_1=m_2\)Condition for parallel lines.
\(m_1m_2=-1\)Condition for perpendicular lines.
Zero (\(x\)-intercept)The input for which \(f(x)=0\).
Piecewise functionA function made of different rules on different intervals.

Worked examples

Example 1 A taxi charges a fixed fee of £3.50 plus £1.80 per kilometre. (a) Write a model for the cost \(C\) of a journey of \(d\) km. (b) Find the cost of a 14.6 km journey. (c) How far can a passenger travel for £50?

(a) The fixed fee is the intercept and the rate is the gradient: \(C=3.50+1.80d\).

(b) \(C=3.50+1.80\times14.6=3.50+26.28=29.78\).

(c) Solve \(3.50+1.80d=50\): \(1.80d=46.5\), so \(d=25.833\ldots\)

Answer: (a) \(C=3.50+1.80d\); (b) £29.78; (c) \(25.8\) km (3 s.f.).

Example 2 A piece of equipment is worth £8400 after 2 years and £6000 after 5 years. Assuming its value falls linearly, find a model for its value \(V\) after \(t\) years, interpret the gradient and intercept, and find when the value reaches zero.

Gradient: \(m=\dfrac{6000-8400}{5-2}=\dfrac{-2400}{3}=-800\).

Use \(V=-800t+c\) with the point \((2,8400)\): \(8400=-1600+c\), so \(c=10\,000\).

The model is \(V=10\,000-800t\).

Interpretation: the gradient means the equipment loses £800 of value each year, and the intercept means it was worth £10 000 when new.

Zero value: \(10\,000-800t=0\), so \(t=12.5\).

Answer: \(V=10\,000-800t\); the value reaches zero after 12.5 years.

Example 3 (HL, because it uses a piecewise model) Plan A for electricity charges £8 plus £0.15 per kWh for the first 100 kWh, and £0.22 per kWh for every kWh above 100, so the cost in pounds is \(A(x)=8+0.15x\) for \(0\le x\le100\) and \(A(x)=0.22x+1\) for \(x\gt100\). Plan B costs \(B(x)=0.19x+5\). Find the cost on Plan A for 340 kWh, and the usage values for which the two plans cost the same.

For 340 kWh, \(x\gt100\), so \(A(340)=0.22\times340+1=75.80\).

Check continuity: at \(x=100\), \(8+0.15\times100=23\) and \(0.22\times100+1=23\), so there is no jump.

On \(0\le x\le100\): set \(8+0.15x=0.19x+5\). Then \(3=0.04x\), so \(x=75\), which lies in the interval.

On \(x\gt100\): set \(0.22x+1=0.19x+5\). Then \(0.03x=4\), so \(x=133.33\ldots\), which lies in the interval.

You can confirm both points by plotting \(A\) and \(B\) on the GDC and using the intersection feature.

Answer: £75.80 for 340 kWh on Plan A; the plans cost the same at 75 kWh and at 133 kWh (3 s.f.). Plan A is cheaper between these two values, and Plan B is cheaper outside them.

Common errors

  • Common error: subtracting the \(x\)-values and \(y\)-values in different orders when finding the gradient, which gives the wrong sign.
  • Common error: reporting a gradient or intercept without units or meaning, such as "\(-800\)" instead of "the value falls by £800 per year".
  • Common error: using the original gradient for a perpendicular line instead of the negative reciprocal.
  • Common error: applying a piecewise rule outside its interval, or accepting a solution that lies outside the interval for that piece.
  • Common error: charging the higher rate on every unit in a tariff problem. Only the units above the boundary are charged at the higher rate, which is why the second rule is \(0.22x+1\) and not \(0.22x+8\).

Exam tip: when a question gives a context, state what the gradient and intercept mean in words, with units, and say whether your answer lies inside the valid domain.

Check yourself

  1. Find the equation of the line through \((1,5)\) and \((4,17)\).
    Answer\(m=\dfrac{17-5}{4-1}=4\). Using \((1,5)\): \(5=4+c\), so \(c=1\). The line is \(y=4x+1\).
  2. Find the gradient of a line perpendicular to \(y=-\dfrac{2}{5}x+3\).
    AnswerThe negative reciprocal of \(-\dfrac25\) is \(\dfrac52\).
  3. A gym charges a £30 joining fee and £22 per month. How many months can a member pay for with £400?
    Answer\(30+22m\le400\), so \(22m\le370\) and \(m\le16.8\ldots\) A member can pay for 16 full months.
  4. (HL) For the piecewise function in Example 3, find \(A(60)\).
    Answer60 lies in \(0\le x\le100\), so \(A(60)=8+0.15\times60=17\), that is £17.