Numerical Methods · Unit 4
Curve Fitting and Regression
Exam-focused notes for Curve Fitting and Regression (Numerical Methods, BIT203): what the TU syllabus asks and how it has actually been tested, with 5 solved past questions from this unit.
Curve Fitting and Regression in short
Measured data usually contain small errors, so forcing a curve through every point is not sensible. Curve fitting finds a simple curve that follows the general trend of the data as closely as possible.
What this unit covers
- Least squares method for function fitting
- Quadratic polynomial fitting
- Exponential curve fitting
- Regression versus interpolation
- Fitting algorithms and applications
Exponential curve fitting
2082 · 5 marks
Fit the exponential curve $y = ae^{bx}$ for (1,15), (2,22), (3,33), (4,48), (5,70) using least square method. [5]
2078 · 5 marks
The temperature of a metal strip was measured at various time intervals during heating and the values are given in the table below. If the relation between the time 't' and temperature 'T' is of the form: $T = be^{t/4} + a$. Estimate the temperature at t = 6 minute.
| Time ('t' min) | 1 | 2 | 3 | 4 |
|---|---|---|---|---|
| Temp ('T' °C) | 70 | 83 | 100 | 124 |
[5]
Quadratic polynomial fitting
2080 · 5 marks
Fit a second order polynomial to the data in the table below:
$$\begin{array}{|c|c|c|c|c|c|}\hline X & 1 & 2 & 3 & 4 & 5 \ \hline F(x) & 2 & 6 & 12 & 20 & 30 \ \hline \end{array}$$
[5]
0 · 5 marks
Fit the quadratic curve through the following data points and estimate the value of f(x) at x=2.
$$\begin{array}{|c|c|c|c|c|c|}\hline x & 1 & 3 & 4 & 5 & 6 \ \hline y & 2 & 7 & 8 & 7 & 5 \ \hline \end{array}$$
[5]
Least squares method for function fitting
2079 · 5 marks
What is least squares method of fitting a function? Fit the second order polynomial for the following data values.
| x | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
|---|---|---|---|---|---|---|---|
| y | 2 | 6 | 7 | 8 | 10 | 12 | 15 |
[5]
Show solved answerHide answer
Least Squares Method and Second Order Polynomial Fitting
Definition
The least squares method finds the best-fit curve for a set of data points by minimizing the sum of squares of residuals (differences between observed values $y_i$ and fitted values $f(x_i)$):
$$S = \sum_{i=1}^{n} [y_i - f(x_i)]^2 \to \text{minimum}$$
Given Data
$$x: 1, 2, 3, 4, 5, 6, 7$$ $$y: 2, 6, 7, 8, 10, 12, 15$$ $$n = 7$$
Model and Normal Equations
Fit $y = a_0 + a_1 x + a_2 x^2$. The normal equations are:
$$\sum y = na_0 + a_1\sum x + a_2\sum x^2$$ $$\sum xy = a_0\sum x + a_1\sum x^2 + a_2\sum x^3$$ $$\sum x^2y = a_0\sum x^2 + a_1\sum x^3 + a_2\sum x^4$$
Calculation Table
| $x$ | $y$ | $x^2$ | $x^3$ | $x^4$ | $xy$ | $x^2y$ |
|---|---|---|---|---|---|---|
| 1 | 2 | 1 | 1 | 1 | 2 | 2 |
| 2 | 6 | 4 | 8 | 16 | 12 | 24 |
| 3 | 7 | 9 | 27 | 81 | 21 | 63 |
| 4 | 8 | 16 | 64 | 256 | 32 | 128 |
| 5 | 10 | 25 | 125 | 625 | 50 | 250 |
| 6 | 12 | 36 | 216 | 1296 | 72 | 432 |
| 7 | 15 | 49 | 343 | 2401 | 105 | 735 |
| $\Sigma$ | 60 | 140 | 784 | 4676 | 294 | 1634 |
Also $\sum x = 28$.
Substituting
$$60 = 7a_0 + 28a_1 + 140a_2 \quad (1)$$ $$294 = 28a_0 + 140a_1 + 784a_2 \quad (2)$$ $$1634 = 140a_0 + 784a_1 + 4676a_2 \quad (3)$$
Note: The coefficient of $a_0$ in equation (1) must be $\sum x = 28$, while in equation (3) the $a_0$ coefficient is $\sum x^2 = 140$; mixing the two is an easy slip to make.
Solving
Eliminate $a_0$. Multiply (1) by 4 and subtract from (2):
$(2) - 4\times(1)$: $$294 - 240 = (28-28)a_0 + (140-112)a_1 + (784-560)a_2$$ $$54 = 28a_1 + 224a_2 \quad (4)$$
Multiply (1) by 20 and subtract from (3):
$(3) - 20\times(1)$: $$1634 - 1200 = (140-140)a_0 + (784-560)a_1 + (4676-2800)a_2$$ $$434 = 224a_1 + 1876a_2 \quad (5)$$
Eliminate $a_1$. Multiply (4) by 8: $$432 = 224a_1 + 1792a_2 \quad (4')$$
$(5) - (4')$: $$434 - 432 = (1876 - 1792)a_2$$ $$2 = 84a_2 \implies a_2 = 0.02381$$
From (4): $$54 = 28a_1 + 224(0.02381) = 28a_1 + 5.333$$ $$28a_1 = 48.667 \implies a_1 = 1.7381$$
From (1): $$60 = 7a_0 + 28(1.7381) + 140(0.02381)$$ $$60 = 7a_0 + 48.667 + 3.333$$ $$7a_0 = 8.0 \implies a_0 = 1.1429$$
Result
$$\boxed{y = 1.1429 + 1.7381x + 0.0238x^2}$$
Verification (at $x=4$): $1.1429 + 6.9524 + 0.381 = 8.476 \approx 8$ ✓ (at $x=7$): $1.1429 + 12.167 + 1.167 = 14.48 \approx 15$ ✓
Make Unit 4 stick
Practice BIT203 with flashcards & quizzes