# Polynomial Regression Calculator

URL: https://speedycalculator.com/calculators/statistics/polynomial-regression/
Last updated: 2026-10-30

> 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.

## Inputs

- Degree of the polynomial
- x values
- y values — Same number of values as x
- Predict y at x = — Optional – leave empty to skip the prediction
- Precision (significant figures)

## Results

- Regression equation
- Scatter plot with the fitted curve
- Coefficient a₆ (x⁶)
- Coefficient a₅ (x⁵)
- Coefficient a₄ (x⁴)
- Coefficient a₃ (x³)
- Coefficient a₂ (x²)
- Coefficient a₁ (x)
- Coefficient a₀ (constant term)
- Coefficient of determination (R²)
- Adjusted R²
- Residual standard error
- Overall F-test
- Predicted y at the chosen x
- 95% prediction interval for a new y
- 95% confidence interval for the mean y
- Interpolation or extrapolation?
- Coefficients with standard errors and t-tests
- Fitted values and residuals
- Sum of squared residuals (SSE)
- Number of points

## Formula

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

## Explanation

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

- **Degree of the polynomial**
- **x values**
- **y values** — Same number of values as x
- **Predict y at x =** — Optional – leave empty to skip the prediction
- **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

DegreeR²Adjusted R²10.38530.282920.61120.455730.96000.930040.97580.943650.99850.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.

## 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.

## FAQ

**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

- [Penn State STAT 462 – Applied Regression Analysis](https://online.stat.psu.edu/stat462/)
- [NIST/SEMATECH e-Handbook of Statistical Methods](https://www.itl.nist.gov/div898/handbook/)
- [Wolfram MathWorld – Probability and statistics](https://mathworld.wolfram.com/topics/ProbabilityandStatistics.html)
