Polynomial Regression Calculator

Fit data to a polynomial curve and predict new values

Enter your data points (one x,y pair per line) and the desired polynomial degree to compute the best-fit equation, R-squared, and predictions.

Polynomial Regression Calculator
Fit data to a polynomial curve and predict new values
Quick Load Examples

About the Polynomial Regression Calculator

Polynomial regression is a powerful extension of linear regression that models the relationship between an independent variable x and a dependent variable y as a polynomial of degree n. Unlike simple linear regression, which fits a straight line, polynomial regression can capture curves, bends, and more complex patterns in data — making it useful when real-world relationships are clearly non-linear. The mathematical model takes the form: y = β₀ + β₁x + β₂x² + … + βₙxⁿ, where the coefficients β₀ through βₙ are estimated from the data using the method of least squares. Despite fitting a curve rather than a line, polynomial regression is still classified as a linear model because it is linear in its coefficients. The least squares method minimizes the sum of squared residuals — the differences between observed y values and the values predicted by the polynomial. This is accomplished by solving the normal equations: (XᵀX)β = Xᵀy, where X is the Vandermonde matrix constructed from the x values. This calculator solves those equations using Gaussian elimination, a robust numerical method suitable for polynomials up to degree 10. R-squared (R²), the coefficient of determination, measures how well the fitted polynomial explains the total variability in y. An R² of 1.0 means the curve passes through all data points exactly; 0.0 means the model explains none of the variance. While R² always increases with polynomial degree, a very high R² with a high-degree polynomial may indicate overfitting — the model memorizes the training data rather than capturing the true underlying trend. Choosing the right degree is critical. Degree 1 gives a straight line (equivalent to simple linear regression). Degree 2 (quadratic) captures U-shaped or inverted U-shaped patterns. Degree 3 (cubic) can model S-shaped trends or more complex growth curves. For most practical data sets, degrees 2 or 3 are sufficient, and going beyond degree 5 or 6 often introduces numerical instability and overfitting. Applications of polynomial regression span many fields. Engineers use quadratic models for stress-strain relationships and projectile motion. Economists fit cubic curves to cost functions and production models. Biologists apply polynomial regression to growth curves and dose-response studies. Data scientists use it as a preprocessing step in machine learning pipelines. When using this calculator, be aware of extrapolation risk — polynomial curves can behave wildly outside the range of the observed data. Always verify predictions against domain knowledge, and consider simpler models first before increasing polynomial degree.

Examples

These examples illustrate polynomial regression for common data patterns.

Data & DegreeEquation / R²Use Case
Points: (0,1),(1,2.5),(2,5),(3,8.5),(4,13) Degree: 2y ≈ 0.5x² + x + 1, R²≈1.00Quadratic projectile-like growth
Points: (1,2),(2,4.1),(3,5.9),(4,8.2),(5,10) Degree: 1y ≈ 2x, R²≈0.9997Linear trend, near-perfect fit
Points: (-2,-10),(-1,0),(0,2),(1,4),(2,18) Degree: 3y ≈ 3x³−2x²+x+2, R²≈1.00Cubic stress-strain model
Points: (1,3),(2,5),(3,4),(4,6),(5,8),(6,7) Degree: 4High-degree fit, R²>0.99Volatile data, high-degree smoothing

How to Use This Calculator

  1. Enter your data points in the text area, one pair per line in the format 'x, y' (comma or space separated).
  2. Set the Polynomial Degree — enter 1 for linear, 2 for quadratic, 3 for cubic, and so on.
  3. Optionally enter an X value in the 'Predict Y' field to forecast the output at that point.
  4. Click 'Calculate' to see the regression equation, R-squared value, and predicted Y.
  5. Use the Quick Load buttons to explore pre-built examples, or click 'Reset' to clear all fields.

Frequently Asked Questions

What is polynomial regression?
Polynomial regression is a form of regression analysis that models the relationship between a dependent variable y and an independent variable x as an nth-degree polynomial. Unlike simple linear regression, it can fit curved relationships. The model is still linear in its coefficients and is solved using the least-squares method.
How do I choose the polynomial degree?
Start with a low degree (1 or 2) and increase it only if the fit is poor. A higher degree can overfit the data, producing a curve that passes through all points but predicts poorly for new values. The R-squared value improves with higher degrees, but check whether the improvement is meaningful or a sign of overfitting.
What does R-squared mean?
R-squared (coefficient of determination) measures how well the regression curve explains the variability in your data. A value of 1.0 means a perfect fit; 0.0 means the model explains none of the variance. Values above 0.9 generally indicate a strong fit, but always consider the context and the number of data points.
Why does the calculator require more points than the degree?
A polynomial of degree d has d+1 coefficients to estimate. You need at least d+1 data points to solve the normal equations. With exactly d+1 points, the curve passes through all of them exactly (R²=1), but that may represent overfitting rather than a true relationship in the data.
Can I use this for time-series forecasting?
Polynomial regression can be applied to time-series data by treating time as the x variable. However, polynomial models can extrapolate poorly beyond the range of observed data — especially high-degree polynomials. For robust time-series forecasting, consider exponential smoothing or ARIMA models in addition to polynomial regression.
What is the difference between polynomial regression and other curve-fitting methods?
Polynomial regression fits a specific algebraic form (a polynomial) to the data. Other curve-fitting methods include exponential regression (y = ae^bx), logarithmic regression (y = a + b ln x), and power regression (y = ax^b). Choose the method based on the underlying pattern in your data and the theory explaining the relationship.