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)(x_i,y_i), choose a maximum degree dd and write


pd(x)=a0+a1x+a2x2+⋯+adxd.p_d(x)=a_0+a_1x+a_2x^2+\cdots+a_dx^d.


There are d+1d+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 xx is measured in seconds and the output in metres, the coefficient multiplying x2x^2 has units of metres per second squared.

Match samples or reduce discrepancies

An interpolating polynomial reproduces every supplied output at its corresponding input:


pd(xi)=yifor every sample i.p_d(x_i)=y_i\qquad\text{for every sample }i.


For nn samples with distinct input values, exactly one polynomial of degree at most n−1n-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


min⁡a0,…,adS,S=∑i=1n[yi−pd(xi)]2.\min_{a_0,\ldots,a_d} S, \qquad S=\sum_{i=1}^{n}\left[y_i-p_d(x_i)\right]^2.


The residuals are ei=yi−pd(xi)e_i=y_i-p_d(x_i). Squaring prevents positive and negative discrepancies from cancelling. If outputs are in volts, SS 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−1n-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)(0,1), (1,3)(1,3) and (2,2)(2,2), the quadratic p(x)=1+3.5x−1.5x2p(x)=1+3.5x-1.5x^2 matches all three outputs. The least-squares line q(x)=1.5+0.5xq(x)=1.5+0.5x instead gives predictions 1.51.5, 22 and 2.52.5, allowing discrepancies while following the overall trend.


Three sample points are shown with an interpolating polynomial and a fitted straight line.



Choose and check the model

For a straight-line least-squares model p(x)=a+bxp(x)=a+bx, the coefficients can be calculated using the sample means xˉ\bar{x} and yˉ\bar{y}:


b=∑i(xi−xˉ)(yi−yˉ)∑i(xi−xˉ)2,a=yˉ−bxˉ.b=\frac{\sum_i(x_i-\bar{x})(y_i-\bar{y})}{\sum_i(x_i-\bar{x})^2}, \qquad a=\bar{y}-b\bar{x}.


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−1n-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 xx 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+bxq(x)=a+bx and its sum of squared residuals.


The input mean is xˉ=1\bar{x}=1. The sum of the observed signal values is ________, so yˉ=7.2/3=2.4\bar{y}=7.2/3=2.4.


Calculate the slope using deviations from the means:


b=(0−1)(1.1−2.4)+(1−1)(2.0−2.4)+(2−1)(4.1−2.4)(0−1)2+(1−1)2+(2−1)2=1.3+0+1.71+0+1=1.5.\begin{aligned} b&=\frac{(0-1)(1.1-2.4)+(1-1)(2.0-2.4)+(2-1)(4.1-2.4)}{(0-1)^2+(1-1)^2+(2-1)^2}\\ &=\frac{1.3+0+1.7}{1+0+1}=1.5. \end{aligned}


The intercept follows from the mean point:


a=yˉ−bxˉ=2.4−(1.5)(1)=0.9.a=\bar{y}-b\bar{x}=2.4-(1.5)(1)=0.9.


Thus the fitted line is q(x)=0.9+1.5xq(x)=0.9+1.5x, corresponding to an intercept of 0.9 V0.9\ \text{V} and a slope of 1.5 V/kN1.5\ \text{V/kN}.


A residual is an observed value minus its prediction at the same input. The line predicts 0.90.9, 2.42.4 and 3.9 V3.9\ \text{V}. Its residuals, in load order, are ________, ________ and ________. Therefore,


Sq=(0.2)2+(−0.4)2+(0.2)2=0.24 V2.S_q=(0.2)^2+(-0.4)^2+(0.2)^2=0.24\ \text{V}^2.


The final sum of squared residuals is 0.24 V20.24\ \text{V}^2. 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+c2x2p(x)=c_0+c_1x+c_2x^2 and impose exact agreement at the three distinct inputs:


c0=1.1,c0+c1+c2=2.0,c0+2c1+4c2=4.1.\begin{aligned} c_0&=1.1,\\ c_0+c_1+c_2&=2.0,\\ c_0+2c_1+4c_2&=4.1. \end{aligned}


Subtracting the constant term leaves right-hand sides of ________ and ________ in the two remaining equations:


c1+c2=0.9,2c1+4c2=3.0.c_1+c_2=0.9, \qquad 2c_1+4c_2=3.0.


Subtract twice the first equation from the second:


2c2=3.0−1.8=1.2,c2=0.6.2c_2=3.0-1.8=1.2, \qquad c_2=0.6.


Then c1=0.9−0.6=0.3c_1=0.9-0.6=0.3. The interpolating polynomial is p(x)=1.1+0.3x+0.6x2p(x)=1.1+0.3x+0.6x^2, with numerical inputs in kilonewtons and numerical outputs in volts.


Check every sample:


p(0)=1.1,p(1)=1.1+0.3+0.6=2.0,p(2)=1.1+0.6+2.4=4.1.\begin{aligned} p(0)&=1.1,\\ p(1)&=1.1+0.3+0.6=2.0,\\ p(2)&=1.1+0.6+2.4=4.1. \end{aligned}


Every residual is zero, giving Sp=0 V2S_p=0\ \text{V}^2.


c) Predict the signal at 1.5 kN1.5\ \text{kN} using each model. Does the smaller sample error establish which prediction is more accurate?


Substitute the same numerical load into each model:


q(1.5)=0.9+1.5(1.5)=3.15,q(1.5)=0.9+1.5(1.5)=3.15,


p(1.5)=1.1+0.3(1.5)+0.6(1.5)2=1.1+0.45+1.35=2.90.p(1.5)=1.1+0.3(1.5)+0.6(1.5)^2 =1.1+0.45+1.35=2.90.


The line predicts 3.15 V3.15\ \text{V}, and the quadratic predicts 2.90 V2.90\ \text{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 kN1.5\ \text{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 laboratory collects six noisy sensor readings at distinct concentrations. Independent calibration evidence suggests an approximately linear response over this range. The analyst wants a straight-line summary that uses every reading and penalizes large discrepancies more strongly than small ones. Which procedure best meets this goal?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

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,4x=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=2x=2, exact interpolation through all six pairs is .

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

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 kN1.5\ \text{kN}. Give your answer in volts, to two decimal places.


Load (kN)

Signal (V)

0

2

1

4

3

14


Use xx for the numerical load value in kilonewtons and let p(x)p(x) give the numerical signal value in volts.

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

Extra Practice