Polynomial Regression Calculator

Polynomial regression fits a curve — not just a straight line — through a set of x,y data points. Enter comma-separated x-values, matching y-values, and the degree of polynomial you want (2 for a parabola, 3 for a cubic, and so on) to get the best-fit equation and how well it fits.

—
—
—
—

How Least-Squares Polynomial Fitting Works

The calculator builds the "normal equations" from your data — a small system of linear equations derived from the sums of powers of x — and solves them by Gaussian elimination to get the coefficients that minimize the total squared error between the curve and your points.

Worked Example

For points (−2,3), (−1,0), (0,1), (1,6), (2,15) fit with degree 2, the calculator recovers y = 2x² + 3x + 1 exactly, with R² = 1 — because these points were generated from that exact quadratic, with no noise to fit around.

Choosing the Right Degree

Higher degree always fits the given points at least as well, but can "overfit" — matching the noise in your sample rather than the true underlying pattern, and performing poorly on new data. Start with the lowest degree that captures the visible curve in your data, and treat a sudden jump to R² = 1 at high degree with suspicion rather than celebration.

Frequently Asked Questions

What is polynomial regression?

It's a way of fitting a curve — a polynomial of degree 2, 3, or higher — through data points so the sum of squared vertical distances from each point to the curve is as small as possible, the same least-squares idea behind linear regression.

How is this different from linear regression?

Linear regression only fits a straight line (degree 1). Polynomial regression allows curves — degree 2 for a parabola, degree 3 for an S-shaped cubic — which can capture bends that a straight line can't.

What does an R² close to 1 mean?

R² measures how much of the variation in y the fitted curve explains, from 0 (no fit) to 1 (perfect fit passing through every point). An R² of 0.95 means the curve explains 95% of the variation in your data.

How many data points do I need for a given degree?

At least degree + 1 points are required to fit a unique polynomial of that degree — a degree-2 (quadratic) fit needs at least 3 points, degree-3 needs at least 4, and so on. More points than that let least squares smooth out noise.

Why might the equation look odd for noisy real-world data?

With few points or a high degree relative to the data, the fit can swing wildly between points to chase noise rather than capturing a genuine trend — a lower degree, or more data, usually gives a more trustworthy curve.