Polynomials, Curve Fitting and Interpolation
Polynomial Data Modelling: Matching Samples or Fitting a Trend
Polynomial Data Modelling uses a polynomial to represent how an output changes with an input. You might model a sensor response, summarize experimental measurements or estimate a value between recorded samples. Before calculating coefficients, decide what agreement with the data should mean: passing through every sample and representing an overall trend solve different problems.
Specify the polynomial model
For observations (xi,yi), choose a maximum degree d and write
There are d+1 coefficient positions. A straight line has maximum degree one; a quadratic has maximum degree two. Increasing the allowed degree gives the model more flexibility, but flexibility alone does not establish accuracy between observations.
Keep coefficient order explicit when using numerical software. The mathematical expression above lists coefficients from constant to highest power, whereas some software expects the reverse order. Also track units: if x is measured in seconds and the output in metres, the coefficient multiplying x2 has units of metres per second squared.
Match samples or reduce discrepancies
An interpolating polynomial reproduces every supplied output at its corresponding input:
For n samples with distinct input values, exactly one polynomial of degree at most n−1 satisfies these conditions. Its actual degree can be smaller. Repeated inputs with different outputs cannot be matched by a single-valued polynomial.
A least-squares polynomial fit chooses coefficients that minimize the sum of squared differences between observed and modelled outputs. For a fixed degree, the unweighted objective is
The residuals are ei=yi−pd(xi). Squaring prevents positive and negative discrepancies from cancelling. If outputs are in volts, S is in volts squared.
Feature | Interpolating polynomial | Least-squares polynomial fit |
|---|---|---|
Main requirement | Match every sample | Minimize total squared discrepancy |
Degree choice | At most n−1 suffices for distinct inputs | Chosen to represent the intended trend |
Sample discrepancies | All zero in exact arithmetic | Usually nonzero for a restricted degree |
Typical motivation | Preserve trusted tabulated values | Summarize measurements containing noise |
These categories can overlap. If the chosen polynomial family can reproduce every sample, its least-squares minimum is zero and the resulting polynomial also interpolates.
Example: For samples (0,1), (1,3) and (2,2), the quadratic p(x)=1+3.5x−1.5x2 matches all three outputs. The least-squares line q(x)=1.5+0.5x instead gives predictions 1.5, 2 and 2.5, allowing discrepancies while following the overall trend.
Choose and check the model
For a straight-line least-squares model p(x)=a+bx, the coefficients can be calculated using the sample means xˉ and yˉ:
The denominator is nonzero when the inputs are not all identical. For higher degrees, numerical software can determine the coefficients, but you still need to specify the degree and objective.
Check the model against measurements withheld from coefficient calculation when these are available. Compare candidates on the same validation observations. Lower error on the original samples can reflect increased flexibility rather than improved prediction.
Choose a degree using the intended physical behaviour, the quality of the observations and independent checks. Zero sample error is not a guarantee of predictive accuracy.
What to remember
- Specify the polynomial degree and coefficient order.
- Interpolation enforces sample agreement; least squares minimizes squared discrepancies.
- Distinct inputs guarantee a unique interpolant of degree at most n−1.
- Judge predictions using evidence beyond the original sample error.
Example: Two Polynomial Models for a Load Sensor
A laboratory records the following calibration readings from a load sensor. The readings may contain measurement noise, and no independent validation measurements are yet available.
Load (kN) | Signal (V) |
|---|---|
0 | 1.1 |
1 | 2.0 |
2 | 4.1 |
Use x for the numerical load value in kilonewtons. Each polynomial below returns the numerical signal value in volts. Retain unrounded coefficients throughout.
a) Find the unweighted least-squares line q(x)=a+bx and its sum of squared residuals.
The input mean is xˉ=1. The sum of the observed signal values is ________, so yˉ=7.2/3=2.4.
Calculate the slope using deviations from the means:
The intercept follows from the mean point:
Thus the fitted line is q(x)=0.9+1.5x, corresponding to an intercept of 0.9 V and a slope of 1.5 V/kN.
A residual is an observed value minus its prediction at the same input. The line predicts 0.9, 2.4 and 3.9 V. Its residuals, in load order, are ________, ________ and ________. Therefore,
The final sum of squared residuals is 0.24 V2. Positive and negative residuals contribute positively after squaring.
b) Find the polynomial of degree at most two that interpolates all three readings, and calculate its sum of squared residuals.
Write p(x)=c0+c1x+c2x2 and impose exact agreement at the three distinct inputs:
Subtracting the constant term leaves right-hand sides of ________ and ________ in the two remaining equations:
Subtract twice the first equation from the second:
Then c1=0.9−0.6=0.3. The interpolating polynomial is p(x)=1.1+0.3x+0.6x2, with numerical inputs in kilonewtons and numerical outputs in volts.
Check every sample:
Every residual is zero, giving Sp=0 V2.
c) Predict the signal at 1.5 kN using each model. Does the smaller sample error establish which prediction is more accurate?
Substitute the same numerical load into each model:
The line predicts 3.15 V, and the quadratic predicts 2.90 V. Both predictions concern a load within the sampled range.
The quadratic's zero sample error confirms exact agreement with the recorded readings. However, those readings may contain noise, and the actual signal at 1.5 kN has not been supplied. The smaller sample error does not establish which prediction is more accurate. Independent validation readings or justified knowledge of the sensor response would help choose between the models.
A technician requires interpolation: a polynomial must pass through every supplied calibration pair exactly. The five dimensionless control settings are x=0,1,2,3,4, with one measured response in millivolts at each setting.
Complete the first blank with an integer and the second with either possible or impossible.
There is a unique polynomial of degree at most that matches these five pairs. If a sixth pair assigns a different response to the already recorded setting x=2, exact interpolation through all six pairs is .
A calibration table gives the following signal values. Construct the polynomial of degree at most two that matches all three entries, then use it to estimate the signal at a load of 1.5 kN. Give your answer in volts, to two decimal places.
Load (kN) | Signal (V) |
|---|---|
0 | 2 |
1 | 4 |
3 | 14 |
Use x for the numerical load value in kilonewtons and let p(x) give the numerical signal value in volts.