Polynomial Regression Calculator

Quick answer

The polynomial regression calculator fits a least-squares polynomial of degree 1 to 6 – linear, quadratic, cubic, quartic, quintic or sextic – to your x and y data. It returns the equation, coefficients with standard errors, R², adjusted R², an F-test, residuals, a chart and predictions.

Same number of values as x

Optional – leave empty to skip the prediction

Regression equation
y = −0.01123x³ + 0.3028x² − 1.31x + 14.06
Scatter plot with the fitted curve
Coefficient a₃ (x³)
-0.011233
Coefficient a₂ (x²)
0.302838
Coefficient a₁ (x)
-1.309656
Coefficient a₀ (constant term)
14.063636
Coefficient of determination (R²)
0.95998
Adjusted R²
0.92997
Residual standard error
1.25189
Overall F-test
F(3, 4) = 31.9843, p = 0.003
Predicted y at the chosen x
23.53948
95% prediction interval for a new y
19.5 to 27.5789
95% confidence interval for the mean y
21.4813 to 25.5977
Interpolation or extrapolation?
x = 13 lies inside the data range (0 to 21) – an interpolation.
Coefficients with standard errors and t-tests
Term Coefficient Std. error t p-value ──────────────────────────────────────────────────────────── Intercept (a₀) 14.06 1.184 11.882 0.0003 x (a₁) −1.31 0.526 −2.49 0.0675 x² (a₂) 0.3028 0.06088 4.974 0.0076 x³ (a₃) −0.01123 0.001902 −5.904 0.0041
Fitted values and residuals
# x y ŷ (fitted) Residual y − ŷ Standardised ────────────────────────────────────────────────────────── 1 0 14.2 14.063636 0.136364 0.109 2 3 12.8 12.556926 0.243074 0.194 3 6 13.5 14.681602 −1.181602 −0.944 4 9 18.9 18.617965 0.282035 0.225 5 12 23.6 22.54632 1.05368 0.842 6 15 25.1 24.64697 0.45303 0.362 7 18 21.4 23.100216 −1.700216 −1.358 8 21 16.8 16.086364 0.713636 0.57
Sum of squared residuals (SSE)
6.2689
Number of points
8

Polynomial regression is the general family behind linear, quadratic and cubic regression: you choose the degree k, and the calculator finds the k + 1 coefficients that minimise the sum of squared residuals. The model stays linear in its coefficients, which is why it can be solved exactly with the normal equations, even though the fitted curve bends.

The real question is which degree to choose. A degree that is too low leaves a systematic pattern in the residuals (underfitting); a degree that is too high starts chasing random noise (overfitting) and produces wild curves between and beyond the points. Switch between degrees and watch three things: adjusted R², which only rises if a new term earns its place; the p-value of the highest-power coefficient; and the shape of the curve on the chart.

Remember that k + 1 points are needed for degree k, and that exactly k + 1 points always give a perfect but meaningless fit. A useful rule of thumb is to have at least five to ten points for every coefficient you estimate.

How to use the Polynomial Regression Calculator

  1. Degree of the polynomial
  2. x values
  3. y values — Same number of values as x
  4. Predict y at x = — Optional – leave empty to skip the prediction
  5. Precision (significant figures)

Everything is calculated in your browser, so results appear instantly and nothing you type is sent to a server.

How it works

The tool builds the design matrix 1, z, z², …, zᵏ from the centred and scaled x values z, solves the normal equations by Gauss–Jordan elimination with pivoting, converts the solution to coefficients of powers of x (with their covariance) and computes residuals, R², adjusted R², the overall F-test and t-tests for each coefficient.

Worked example

Air temperature (°C) every three hours over a day: x = 0, 3, …, 21 h and y = 14.2, 12.8, 13.5, 18.9, 23.6, 25.1, 21.4, 16.8. A straight line explains only R² = 0.385 and a parabola 0.611, but the cubic y = −0.01123x³ + 0.3028x² − 1.31x + 14.06 reaches R² = 0.960 (adjusted 0.930, F(3, 4) = 32.0, p = 0.003). A quartic adds little (adjusted R² 0.944, p-value of x⁴ = 0.26), so degree 3 is a sensible choice. At 13:00 the cubic predicts 23.5 °C.

Degree comparison for the example

Degree R² Adjusted R²
1 0.3853 0.2829
2 0.6112 0.4557
3 0.9600 0.9300
4 0.9758 0.9436
5 0.9985 0.9948

Why not just take the highest R²?

In the comparison above degree 5 has the best adjusted R², yet it uses six coefficients for eight points and leaves only two degrees of freedom. Such a curve tracks every wiggle of one particular day and will predict another day poorly. Prefer the simplest degree that captures the main shape and has a physical interpretation.

Formula

y = a₀ + a₁x + a₂x² + … + aₖxᵏ · β = (XᵀX)⁻¹Xᵀy · adjusted R² = 1 − (1 − R²)(n − 1) ÷ (n − k − 1)

Worked example

Inputs — Degree of the polynomial: 3 – cubic; x values: 0, 3, 6, 9, 12, 15, 18, 21; y values: 14.2, 12.8, 13.5, 18.9, 23.6, 25.1, 21.4, 16.8; Predict y at x =: 13; Precision (significant figures): 4.
Results — Regression equation = y = −0.01123x³ + 0.3028x² − 1.31x + 14.06; Coefficient a₃ (x³) = -0.011233; Coefficient a₂ (x²) = 0.302838; Coefficient a₁ (x) = -1.309656; Coefficient a₀ (constant term) = 14.063636; Coefficient of determination (R²) = 0.95998.

Key terms

Degree
The highest power of x in the polynomial.
Underfitting
A model too simple to capture the trend, leaving patterned residuals.
Overfitting
A model so flexible that it follows noise.
F-test
Test of whether all non-constant coefficients are zero.

Frequently asked questions

How do I choose the degree of a polynomial regression?

Increase the degree one step at a time and stop when adjusted R² stops improving or the top coefficient is no longer significant. Use the lowest degree that leaves random-looking residuals.

How many points do I need?

At least degree + 1. With exactly that many, the curve passes through every point and R² = 1.

Why is it called linear regression if the curve is bent?

Because y is a linear combination of the unknown coefficients; x², x³ and so on are just extra columns of data.

What is the difference between R² and adjusted R²?

R² never decreases when you add terms; adjusted R² subtracts a penalty for each term and can fall when a term adds nothing.

What does the F-test show?

Whether the polynomial as a whole explains significantly more variation than a flat line at ȳ.

Why does a high-degree fit swing wildly?

High-degree polynomials oscillate between and beyond the data (Runge's phenomenon). Use fewer terms or more evenly spaced points.

Can I fit degree 7 or higher?

This tool stops at 6, because higher degrees are almost always overfitting and numerically unstable.

Sources

  1. Penn State STAT 462 – Applied Regression Analysis
  2. NIST/SEMATECH e-Handbook of Statistical Methods
  3. Wolfram MathWorld – Probability and statistics

Cite this calculator

Speedy Calculator. (2026). Polynomial Regression Calculator. Speedy Calculator. https://speedycalculator.com/calculators/statistics/polynomial-regression/