# Interpolation and Curve Fitting

Mathematics I · Scientific Programming · https://tryals.app/learn/mathematics-i/interpolation-and-curve-fitting

## Interpolation Basics

Given data points, we often want a function to fill gaps or make predictions. **Interpolation** finds a function passing **exactly through** every data point.

Given $n+1$ points, there is a unique **interpolating polynomial** of degree $n$. **Spline interpolation** joins points with low-degree cubic pieces, matching smoothly.

| Approach | Goal | Data Assumption |
| --- | --- | --- |
| **Interpolation** | Exact match | Data are **exact** |
| **Curve Fitting** | Minimize error | Data have **noise** |

A single high-degree polynomial can oscillate wildly (**Runge's phenomenon**). Splines avoid this by using piecewise low-deg curves.

## Curve Fitting & Pitfalls

**Curve fitting** (regression) finds a function of a chosen form coming close to points without hitting them. **Least-squares fitting** minimizes the sum of squared vertical distances (residuals) from points to the curve.

$$\text{exact data: interpolate} \;;\; \text{noisy data: fit}$$

**Common pitfall:** **interpolating noisy data**. Forcing a curve through every point when data have noise makes it chase random jitter (**overfitting**). Conversely, **underfitting** misses real features by using a too-simple curve. Match the method to the data's noise level.

## Practice questions

6 of this lesson's 11 practice questions, with answers. The full set is in the app.

### 1. Complete the definition of least-squares fitting.

**Answer:** Least-squares fitting chooses the curve that minimises **the sum of the squared residuals**.

**Why:** The total of the squared vertical distances is minimised, every point contributes, and large misses are penalised disproportionately. Minimising the largest residual instead is a different, legitimate criterion, but it is not least squares.

Page: https://tryals.app/practice/mathematics-i/interpolation-and-curve-fitting/complete-the-definition-of-least-squares-fitting

### 2. Fitting a polynomial through all n data points guarantees passing through every one, and Runge showed the result can oscillate wildly between them. What is the fix in practice?

A. Using equally spaced points, which prevents the phenomenon
B. Splines, low-degree pieces joined smoothly to keep it local
C. Removing the points that cause the oscillation
D. Increasing the polynomial's degree until the oscillation damps out

**Answer:** B. Splines, low-degree pieces joined smoothly to keep it local

**Why:** A single high-degree polynomial is global, so every coefficient answers to every point and the curve whips about near the ends. Splines make it local, cubic pieces meeting smoothly, which is why they are what CAD, fonts and animation actually use.

Page: https://tryals.app/practice/mathematics-i/interpolation-and-curve-fitting/fitting-a-polynomial-through-all-n-data-points-guarantees-passing

### 3. A high-degree polynomial forced through many equally spaced points approximates the underlying function better than a low-degree one.

**Answer:** False

**Why:** False. Raising the degree makes the interpolant oscillate violently near the ends of the interval, Runge's phenomenon, so it matches at the nodes and is badly wrong between them. Splines avoid it by staying low-degree and piecewise, and Chebyshev nodes avoid it by clustering points toward the ends.

Page: https://tryals.app/practice/mathematics-i/interpolation-and-curve-fitting/a-high-degree-polynomial-forced-through-many-equally-spaced-points

### 4. Twenty-one exact data points are to be interpolated. Select every genuine reason to prefer a cubic spline to a single degree-20 polynomial.

A. High-degree interpolating polynomials can oscillate wildly between the data points.
B. Least squares minimises the sum of squared residuals.
C. A spline joins low-degree pieces smoothly rather than using one high-degree polynomial.
D. A curve dragged through every noisy reading will follow the noise too.
E. Fitting always produces a curve through every data point.

**Answer:** A. High-degree interpolating polynomials can oscillate wildly between the data points.; B. Least squares minimises the sum of squared residuals.; C. A spline joins low-degree pieces smoothly rather than using one high-degree polynomial.

**Why:** The spline interpolates, so it hits every point while keeping each piece cubic and locally tame. It is not a least-squares fit and it uses exactly the same data, those two options describe a different method altogether.

Page: https://tryals.app/practice/mathematics-i/interpolation-and-curve-fitting/twenty-one-exact-data-points-are-to-be-interpolated-select-every

### 5. Sort each situation by whether the data should be interpolated or fitted.

**Answer:**

- Interpolate: An exact table of physical constants; values wanted between entries, Points computed exactly from a known formula, wanted cheaply in between
- Fit: Noisy sensor readings; the underlying trend is wanted, Measurements each carrying about 2% error, used for prediction, Twenty noisy points, with a degree-19 polynomial under consideration

**Why:** Exact data deserve a curve through every point; noisy data deserve a curve near them. Insisting on passing through noisy points forces the curve to reproduce the noise, which is overfitting, the lesson's named pitfall.

Page: https://tryals.app/practice/mathematics-i/interpolation-and-curve-fitting/sort-each-situation-by-whether-the-data-should-be-interpolated-or

### 6. A degree-19 polynomial through 20 noisy points passes through every one exactly, yet is a worse model than a straight line. Why does perfect fit indicate failure?

A. Because 20 points are too few for any polynomial model
B. Because the noise should have been removed before fitting
C. Because it has fitted the noise as well as the signal
D. Because high-degree polynomials are numerically unstable to evaluate

**Answer:** C. Because it has fitted the noise as well as the signal

**Why:** Fit quality on the training data is not model quality. A model with as many parameters as points always fits perfectly and has learned nothing generalisable.

Page: https://tryals.app/practice/mathematics-i/interpolation-and-curve-fitting/a-degree-19-polynomial-through-20-noisy-points-passes-through-every
