DEGREE 1–5 CURVE FIT
Polynomial Regression Calculator
Fit a polynomial of degree 1 to 5 to paired observations using a QR least-squares solve on centered and scaled X. Compare degrees, inspect conditioning warnings, residuals and the fitted curve. Higher degree is not automatically better.
YOUR DATA
Enter paired observations
Paste or upload numeric X and Y columns. Use a period as the decimal mark. Up to 5 MB and 5,000 observations are accepted.
The file is read locally in your browser.
YOUR RESULTS
Polynomial fit
Observed values and fitted curve
Points are observations; the curve shows the least-squares fit.
Residuals by observation
Residual = observed Y − predicted Y.
| Row | X | Observed Y | Predicted Y | Residual |
|---|
How to use this calculator
- Paste paired X and Y values, or load the worked example.
- Choose a degree from 1 to 5. The calculator uses a QR solve, not the normal equations.
- Review the fitted equation, curve, R², RMSE and row residuals.
- Compare a lower-degree fit before accepting a higher-degree curve; exact interpolation (n = degree + 1) is flagged automatically.
Formula and calculation method
The model is ŷ = β₀ + β₁x + β₂x² + … + βdxd. To keep the solve numerically stable, the calculator first centres and scales X to z = (x − μ) / s, where μ is the mean X and s is the root-mean-square distance of X from μ. It then builds the Vandermonde design matrix [1, z, z², …, zd] and solves the least-squares problem with a Householder QR transformation. Coefficients are transformed back to the original X basis when the back-transformation is numerically stable; otherwise the centred/scaled form is shown.
R² = 1 − SSE/SST and RMSE = √(SSE/n). The reported reciprocal condition ratio is an estimate of the scaled design matrix’s conditioning; a very small value suggests the chosen degree may be numerically unstable for the input.
Assumptions and limitations
- You need at least d + 1 complete observations and at least d + 1 distinct X values for a degree-d fit.
- R² measures fit on these input observations. It does not test significance, causation, or performance on new data.
- A high-degree polynomial can follow noise and oscillate between observations. Inspect residuals and prefer the simplest adequate shape.
- When the number of observations equals the number of coefficients, the fit is exact interpolation and is flagged.
- Extrapolation outside the observed X range can behave unpredictably, especially for higher degrees.
- The current input limit is 5,000 observations and 5 MB per file.
Related calculators
Linear regression · Quadratic regression · Exponential regression · Compare regression models