Smoothing, linearization, sinusoidal models, and recurrence relations
Math AI HL Topic 2 ExtensionAt HL, the study of functions extends beyond algebraic manipulation to fitting mathematical models to real-world data. Technology (GDC, GeoGebra, Desmos) is essential for this topic.
Given a scatter plot or dataset, we select an appropriate function type and use regression to find the best-fit parameters:
| Pattern in Data | Suggested Model | Form |
|---|---|---|
| Straight line trend | Linear | $y = mx + c$ |
| Rapid growth/decay | Exponential | $y = ab^x$ or $y = ae^{kx}$ |
| Power relationship | Power | $y = ax^n$ |
| Oscillating / periodic | Sinusoidal | $y = A\sin(Bx+C)+D$ |
| S-shaped growth curve | Logistic | $y = \frac{L}{1+e^{-k(x-x_0)}}$ |
Real data is often noisy — it has random fluctuations that obscure the underlying trend. A moving average smooths the data by replacing each value with the average of neighboring values.
3-point moving average (centred at point $i$):
$$\bar{y}_i = \frac{y_{i-1} + y_i + y_{i+1}}{3}$$5-point moving average (centred at point $i$):
$$\bar{y}_i = \frac{y_{i-2} + y_{i-1} + y_i + y_{i+1} + y_{i+2}}{5}$$Note: You lose data points at the ends — a 3-point MA of $n$ values gives $n-2$ smoothed values.
In time series data (e.g., monthly sales, quarterly temperatures), the overall direction is the trend. Periodic fluctuations (summer highs, winter lows) are seasonal variation.
Monthly sales (units): Jan=120, Feb=95, Mar=140, Apr=110, May=155, Jun=130. Calculate the 3-point moving average.
An exponential model $y = ab^x$ is not linear, making it hard to fit by eye. We can linearize it by taking logarithms, transforming it into a linear relationship.
Take $\ln$ of both sides:
$$\ln y = \ln a + x \ln b$$Let $Y = \ln y$, $c = \ln a$, $m = \ln b$. Then: $Y = c + mx$ (linear!)
For $y = ax^n$: take $\log$ of both sides: $\log y = \log a + n \log x$. Plot $\log y$ vs $\log x$ — gradient = $n$, intercept = $\log a$.
A bacterial culture data: $t$ (hours) = 0, 1, 2, 3, 4 and count $N$ = 100, 165, 272, 449, 740. Test whether this fits $N = ab^t$ and find $a$ and $b$.
Many natural phenomena are periodic: temperature, tides, daylight hours, sound waves. The general sinusoidal model is:
| Parameter | Meaning | How to Find |
|---|---|---|
| $A$ | Amplitude (half the range) | $A = \frac{y_{\max} - y_{\min}}{2}$ |
| $B$ | Controls period | $B = \frac{2\pi}{\text{period}}$ |
| $C$ | Horizontal (phase) shift | From first maximum or zero |
| $D$ | Vertical shift (midline) | $D = \frac{y_{\max} + y_{\min}}{2}$ |
Average monthly temperatures (°C) in a city: Jan=−3, Apr=8, Jul=22, Oct=10. Fit a sinusoidal model.
A piecewise-defined function uses different formulas for different parts of the domain.
Sign function: $$\text{sgn}(x) = \begin{cases} -1 & x < 0 \\ 0 & x = 0 \\ 1 & x > 0 \end{cases}$$
Floor function (greatest integer function): $\lfloor x \rfloor$ = greatest integer $\leq x$
$\lfloor 3.7 \rfloor = 3$, $\lfloor -1.2 \rfloor = -2$
Ceiling function: $\lceil x \rceil$ = smallest integer $\geq x$
A recurrence relation defines a sequence where each term is expressed in terms of previous terms.
First-order linear: $u_{n+1} = au_n + b$ (arithmetic if $a=1$; geometric if $b=0$)
General solution:
Iteration (cobweb/staircase diagrams): Graphically trace $u_{n+1} = f(u_n)$ using $y = f(x)$ and $y = x$.
1. Quarterly profits (£000s): Q1=45, Q2=62, Q3=78, Q4=54, Q1=49, Q2=67, Q3=83. Calculate the 4-point centred moving average for Q2 and Q3 of year 1.
4-point MA: Average 4 consecutive values, then centre by averaging adjacent 4-point averages.
4-pt MAs: $(45+62+78+54)/4 = 59.75$; $(62+78+54+49)/4 = 60.75$; $(78+54+49+67)/4 = 62.00$
Centred at Q2: $(59.75+60.75)/2 = 60.25$
Centred at Q3: $(60.75+62.00)/2 = 61.375$
2. Data suggests $y = ax^n$. When plotted on a log-log graph, the line has gradient 2.5 and $y$-intercept 1.2. Find $a$ and $n$.
From $\log y = \log a + n \log x$: gradient $= n = 2.5$, $y$-intercept $= \log a = 1.2$.
Therefore $a = 10^{1.2} \approx 15.85$ and $n = 2.5$.
Model: $y \approx 15.85 x^{2.5}$
3. A sinusoidal model has $y_{\max} = 14$ and $y_{\min} = 2$, with period 8. Write the model in the form $y = A\sin(Bx) + D$ (assuming max at $x=2$).
$A = (14-2)/2 = 6$, $D = (14+2)/2 = 8$, $B = 2\pi/8 = \pi/4$.
Max at $x=2$: $\sin(\frac{\pi}{4}\cdot 2 + C) = 1 \Rightarrow \frac{\pi}{2} + C = \frac{\pi}{2} \Rightarrow C = 0$.
$\mathbf{y = 6\sin\!\left(\frac{\pi}{4}x\right) + 8}$ (shift already satisfied if we use cosine: $y = 6\cos\!\left(\frac{\pi}{4}(x-2)\right)+8$)