What Is Polynomial Curve Fitting?
Polynomial curve fitting finds the polynomial that best follows your data, using least squares. Degree 1 is a line, degree 2 a parabola, degree 3 a cubic and so on.
Enter your x and y values and choose a degree. You get the equation, R², adjusted R², RMSE, a prediction for any x and a table that compares every degree. The chart shows the data with the fitted curve and the adjusted R² of each degree.
Below are the formulas, a worked example and answers on avoiding overfitting.
How to Use the Polynomial Curve Fitting Calculator
- Enter x and y values.
- Choose the degree.
- Read the equation and R².
- Check the degree comparison table.
Polynomial Curve Fitting Formula
Polynomial
Adjusted R²
Polynomial Curve Fitting Variables Explained
| Symbol | Meaning | Notes |
|---|---|---|
| d | Degree of the polynomial | |
| a₀…a_d | Coefficients | |
| R² | Share of variation explained | |
| Adjusted R² | R² corrected for degree |
Polynomial Curve Fitting Worked Example
Data that grow roughly like 1.5x² are fitted well by a quadratic: R² is very close to 1. A cubic adds almost nothing, and its adjusted R² is no better, so the quadratic is the right choice.
With the example values loaded in the calculator above, the steps are:
- Fit y = a₀ + a₁x + … + a2x² by least squares to the 9 points.
- Coefficients (a₀ first): 1.52303, -0.534978, 1.62771.
- R² = 1 − SSE ÷ SST = 1 − 0.921801 ÷ 10,172 = 0.999909; adjusted R² = 0.999879.
- Compare degrees in the table: choose the lowest degree that fits well.
Result: Degree 2 polynomial = y = 1.6277x² − 0.53498x + 1.523; R² = 0.999909; Prediction at x = 9 = 128.552.
How to Read a Polynomial Fit
R² tells you how much of the variation in y the curve explains. A value near 1 means a close fit. Adjusted R² penalises extra terms, so it can fall when a higher degree adds almost nothing.
Prefer the lowest degree that fits well. A quadratic that gives R² of 0.99 is a better model than a degree-8 curve with R² of 0.9999, because the high-degree curve usually bends to follow noise. Look at the plot before you trust a prediction outside your data.
Where Polynomial Curve Fitting Is Used
Trend lines
Fit a quadratic or cubic through measurements that curve, such as stopping distance against speed.
Choosing a degree
Compare R² and adjusted R² for several degrees to see where extra terms stop paying for themselves.
Prediction inside the data range
Estimate y at a new x between your observed values. Interpolation is far safer than extrapolation.
Coursework
Check the coefficients of a regression you worked by hand, with the full equation written out.
Common Polynomial Curve Fitting Mistakes to Avoid
- You need more data points than coefficients. A degree-3 fit needs at least 4 points, and many more to be trustworthy.
- Do not extrapolate far beyond your data. Polynomials can swing sharply outside the fitted range.
- Judge fit with adjusted R², not R², when you compare degrees. R² never falls when you add a term.
- Look at the plot. A high R² can hide a curve that wiggles between points.
Polynomial Curve Fitting Terms and Definitions
- Degree
- The highest power of x in the polynomial.
Polynomial Curve Fitting FAQs
How do I fit a polynomial to data?
Enter your x and y values and choose a degree. The calculator solves the least-squares normal equations for the coefficients and shows the equation, R² and the fitted curve over your points.
What degree should I use?
Start with the lowest degree that follows the pattern: 1 for a straight line, 2 for one bend, 3 for an S shape. Move up only if adjusted R² improves clearly and the curve still looks sensible.
Why is a high degree risky?
A degree n − 1 polynomial passes exactly through n points, so R² is 1 but the curve is fitting noise. It will usually predict new values badly. This is called overfitting.
What is polynomial regression?
It is regression with powers of x as predictors, such as y = a + bx + cx². It is still linear in the coefficients, so ordinary least squares solves it exactly.