Fitting Curves Using Polynomial Models
Finite differences reveal a polynomial model’s degree when the inputs are equally spaced. For real data, nearly constant differences suggest a degree, regression supplies an equation, and R² compares fits to the observed points. Correctly coding the input makes prediction possible, but even a high R² does not guarantee an accurate forecast.

The Data That Curves
Population, prices, and website traffic can follow curved patterns rather than straight lines. Polynomial models can describe such patterns. The task is to choose a degree, fit an equation, and judge how far its predictions can be trusted
Suppose the following table comes from a polynomial. What degree is it really? The values alone do not make the degree obvious, and guessing from the apparent shape of a few points is unreliable
| x | y |
|---|---|
| -2 | 14 |
| -1 | 0 |
| 0 | 0 |
| 1 | 2 |
| 2 | 18 |
| 3 | 84 |
| 4 | 260 |
This lesson uses finite differences to identify the degree in this table, then develops regression models for city population and website traffic. The final step is to evaluate a model with the correct input and distinguish a good fit to recorded data from a reliable future prediction
Finding the Degree with Finite Differences
Three clues guide the method: the shape of a few points can imitate other degrees; equally spaced x-values are the required condition; and a row of identical differences identifies the degree
Start with the y-values and subtract adjacent entries to obtain the first differences. Each difference belongs to the gap between its two parent values, so the new row has one fewer entry. Apply the same subtraction to the first-difference row to obtain second differences, then continue to third differences and beyond
| First constant difference level | Polynomial type | Degree |
|---|---|---|
| First | Linear | 1 |
| Second | Quadratic | 2 |
| Third | Cubic | 3 |
| Fourth | Quartic | 4 |
| Fifth | Quintic | 5 |
Worked example: resolve the mystery table
The inputs −2, −1, 0, 1, 2, 3, 4 increase by 1, so finite differences apply. Starting with y-values 14, 0, 0, 2, 18, 84, 260, the first calculations are 0 − 14 = −14, 0 − 0 = 0, and 2 − 0 = 2. Continuing gives 18 − 2 = 16, 84 − 18 = 66, and 260 − 84 = 176
| Level | Entries | Conclusion |
|---|---|---|
| Original y-values | 14, 0, 0, 2, 18, 84, 260 | Inputs have a constant step of 1. |
| First differences | −14, 0, 2, 16, 66, 176 | Not constant: not linear. |
| Second differences | 14, 2, 14, 50, 110 | Not constant: not quadratic. |
| Third differences | −12, 12, 36, 60 | Not constant: not cubic. |
| Fourth differences | 24, 24, 24 | Constant: a quartic model, degree 4. |
For example, the second differences begin with 0 − (−14) = 14 and 2 − 0 = 2. The third differences begin with 2 − 14 = −12 and 14 − 2 = 12. Finally, 12 − (−12) = 24, 36 − 12 = 24, and 60 − 36 = 24. The fourth level is the first constant level, so the model is quartic
Practice 1: complete the differences
Complete the missing differences and choose the best model. The equally spaced inputs are x = 1, 2, 3, 4, 5, with y = 5, 11, 21, 35, 53. The first differences are 6, 10, ___, 18; the second differences are 4, ___, 4. The supplied choices are 14, −14, 4, 10, quadratic (degree 2), and cubic (degree 3)
The missing first difference is 35 − 21 = 14, not −14. The missing second difference is 14 − 10 = 4. Thus the completed first differences are 6, 10, 14, 18 and the second differences are 4, 4, 4. Constant second differences identify a quadratic model, degree 2
From Close Differences to a Regression Model
Riverton: nearly constant differences
Riverton’s population was recorded every five years. The constant five-year spacing allows finite differences, but these real observations do not produce an exactly constant third-difference row
| Year | Population | x: years since 1990 |
|---|---|---|
| 1990 | 2900 | 0 |
| 1995 | 3538 | 5 |
| 2000 | 3901 | 10 |
| 2005 | 4062 | 15 |
| 2010 | 4101 | 20 |
| 2015 | 4088 | 25 |
| Level | Entries |
|---|---|
| First differences | 638, 363, 161, 39, −13 |
| Second differences | −275, −202, −122, −52 |
| Third differences | 73, 80, 70 |
The first differences come from changes such as 3538 − 2900 = 638. Subtracting again gives second differences such as 363 − 638 = −275; the third differences are −202 − (−275) = 73, −122 − (−202) = 80, and −52 − (−122) = 70. These third differences are relatively close rather than identical, suggesting a cubic, degree-3 model for this real dataset
Use regression to obtain the equation
Let x be the number of years since 1990, not the calendar year. Enter the inputs 0, 5, 10, 15, 20, 25 with their corresponding populations and use cubic regression. For a model f(x) = ax³ + bx² + cx + d, the reported coefficients are a ≈ 0.100370, b ≈ −7.014603, c ≈ 160.158995, and d ≈ 2900.039683
The fitted model is f(x) ≈ 0.100370x³ − 7.014603x² + 160.158995x + 2900.039683, where x = years since 1990. As a check, f(0) ≈ 2900.04, close to the recorded 1990 population of 2900. Its R² ≈ 0.999999 indicates an excellent fit to these observations
Practice 2: interpret the input
A biologist counts a reserve’s deer population every 2 years and fits g(x) ≈ 0.05x³ − 3.2x² + 96x + 1450, where x is the number of years since 1998
Choosing a Model with R²
Website traffic: unevenly spaced inputs
The website dataset records monthly visitors in thousands. Define x as years since 2010
| Year | x: years since 2010 | Monthly visitors (thousands) |
|---|---|---|
| 2010 | 0 | 820 |
| 2011 | 1 | 310 |
| 2012 | 2 | 950 |
| 2015 | 5 | 6200 |
| 2018 | 8 | 10900 |
| 2019 | 9 | 11800 |
| 2020 | 10 | 15400 |
The year gaps are 1, 1, 3, 3, 1, and 1, so the equal-spacing condition fails. The finite-difference method taught here does not apply. The seven plotted points would be (0, 820), (1, 310), (2, 950), (5, 6200), (8, 10900), (9, 11800), and (10, 15400). They show an early dip followed by a steep rise, motivating comparison of quadratic, cubic, and quartic regression models rather than selection by appearance alone
Compare the fit to the observed points
Use the coefficient of determination, R² = 1 − SSE/SST, to compare the three regressions. For this dataset, SST ≈ 228,020,371. Among these candidates, the R² value closest to 1 identifies the best fit to the observed points
| Regression model | SSE (approximately) | R² (approximately) |
|---|---|---|
| Quadratic | 3,082,605 | 0.98648 |
| Cubic | 2,772,981 | 0.98784 |
| Quartic | 489,855 | 0.99785 |
The quartic has the smallest SSE and the R² closest to 1: 1 − 489,855/228,020,371 ≈ 0.99785. It fits these observed points best among the three models tested. Its equation is f(x) ≈ 8.26635x⁴ − 174.25750x³ + 1237.56637x² − 1780.60247x + 880.99015, where x = years since 2010 and f(x) is measured in thousands of monthly visitors
Practice 3: choose the method
Which method applies to each dataset: finite differences or regression with R²? Check whether the consecutive input gaps are constant
Rainfall recorded at x = 0, 3, 6, 9, 12 belongs with finite differences: every step is 3. Home prices from 2001, 2004, 2005, 2011 belong with regression + R²: the steps are 3, 1, and 6, so they are uneven. Sensor readings at x = 2, 4, 6, 8 belong with finite differences: every step is 2
Predict — Then Question It
Predict website traffic for 2021
Use the website’s fitted quartic to predict monthly visitors in 2021. Because x counts years since 2010, convert the year first: x = 2021 − 2010 = 11, not 2021
Substitute 11 into every term: f(11) ≈ 8.26635(11)⁴ − 174.25750(11)³ + 1237.56637(11)² − 1780.60247(11) + 880.99015 ≈ 20130.8
The output is in thousands, so the forecast is about 20,131 thousand monthly visitors, or about 20.1 million. Interpreting the output’s units is part of making the prediction
Question the forecast
The quartic’s R² ≈ 0.99785 describes its fit to the seven recorded observations. Years between the observations have no directly measured fit in this dataset. The prediction for 2021 is one year beyond the last observation in 2020, making it a near extrapolation that still needs a real-world check. A forecast much farther beyond the recorded years would be riskier
A high R² is not an error percentage for a future prediction, proof of a true equation, or a guarantee of accuracy. It describes observed-data fit; regression remains a tool whose forecasts require judgment
Practice 4: interpret R²
A quartic model fits a lake’s yearly fish counts from 2005 through 2015 with R² ≈ 0.998. Consider its prediction for 2035
Summary
1. Finite differences need equal x-steps. Subtract (right value) − (left value) throughout each row, then repeat on the resulting row
2. The first constant difference level names the degree: first means linear, second quadratic, third cubic, fourth quartic, and fifth quintic. Use the level number, not the numerical value of the constant difference
3. For real data, a relatively close difference row can suggest a degree. Regression then computes a fitted function. When coding time, keep the definition explicit: x is the number of years since the chosen start year
4. When spacing is uneven, compare regression models with R² = 1 − SSE/SST. Among the candidates tested on the same observations, the value closest to 1 indicates the best observed-data fit
5. High R² is not a guarantee. Convert the input correctly, interpret the output’s units, and sanity-check the prediction. Watch for overfitting and extrapolation, especially predictions far beyond the recorded data
Quiz
Quiz 1: identify the degree
The x-values increase by 1. Use the given first and second differences to compute the third differences before choosing a model
| Row | Entries |
|---|---|
| x | 0, 1, 2, 3, 4, 5 |
| y | 2, 3, 10, 29, 66, 127 |
| First differences | 1, 7, 19, 37, 61 |
| Second differences | 6, 12, 18, 24 |
Quiz 2: connect evidence to decisions
Connect each situation to the correct decision: survey data with third differences 41, 39, 40; x-values 2000, 2003, 2004, 2008; and candidate R² values 0.976, 0.991, 0.998. The decisions are to use a cubic model, rule out finite differences because spacing is uneven, or choose the model with R² ≈ 0.998
For the survey, third differences 41, 39, 40 are close, suggesting a cubic model for the real data. For the years 2000, 2003, 2004, 2008, the gaps are 3, 1, and 4, so finite differences do not apply. Among R² values 0.976, 0.991, and 0.998, choose the model with R² ≈ 0.998 because it is closest to 1
Quiz 3: predict with the correct input and caution
A quartic model h(x) ≈ 11.2x⁴ − 198x³ + 1350x² − 1900x + 870 fits data recorded from 2005 through 2014. Here x = years since 2005, and R² ≈ 0.995