Polynomial Regression Calculator

Polynomial Regression Calculator

Fit polynomial curves to your data and calculate the best-fit equation with R² goodness of fit.

Last updated: March 2026

Regression Tool

R² (Goodness of Fit)
0.996739
Equation
y = 1.1200 -0.5329x + 1.7071x^2
Coefficients
a0 (x)1.120000
a1 (x^1)-0.532857
a2 (x^2)1.707143
Data points (n)5

What is Polynomial Regression?

Polynomial regression is a form of regression analysis that models the relationship between an independent variable x and a dependent variable y as an nth degree polynomial. Unlike simple linear regression which fits a straight line, polynomial regression can capture curved, non-linear relationships in data.

The general form of a polynomial regression equation is: y = a₀ + a₁x + a₂x² + a₃x³ + ... + aₙxⁿ, where n is the degree of the polynomial and the coefficients (a₀, a₁, a₂, etc.) are determined through least squares fitting. A degree of 1 produces linear regression, degree 2 produces a parabola, and higher degrees produce increasingly complex curves.

This technique is widely used in fields like economics, physics, engineering, and data science when the relationship between variables is known or suspected to be non-linear. The R² statistic measures how well the polynomial fits the data, with values closer to 1 indicating better fit.

How to Use Polynomial Regression

The Fitting Process

Follow these steps to fit a polynomial to your data:

Step 1: Enter your X values (independent variable) separated by commas or spaces
Step 2: Enter corresponding Y values (dependent variable) in the same order
Step 3: Choose polynomial degree (1=linear, 2=quadratic, 3=cubic, etc.)
Step 4: The calculator uses least squares method to find best-fit coefficients
Step 5: Review R² value to assess fit quality (closer to 1 is better)
Step 6: Use the equation to predict Y values for new X inputs

Choosing the Right Degree

Degree 1: Linear relationship (straight line)
Degree 2: Quadratic (parabola, one curve)
Degree 3: Cubic (S-curve, two turns)
Degree 4+: Higher-order polynomials (more complex curves)
⚠️ Avoid overfitting: Higher degrees fit data better but may not generalize well to new data.

Example: Quadratic Regression

Fitting a parabola to projectile motion data:

Given:
Time (seconds): 1, 2, 3, 4, 5
Height (meters): 2.1, 7.7, 13.6, 27.2, 40.9
Degree: 2 (quadratic)
Solution:
Best-fit equation:
y = −1.0000 + 0.8000x + 1.7000x²
R² Value
0.999
Excellent fit!
Data Points
5
Minimum met
Interpretation:
The R² of 0.999 indicates an almost perfect quadratic fit. The positive coefficient for x² (1.7000) shows the curve opens upward, typical of projectile motion under acceleration.

Frequently Asked Questions

What does R² tell me?

R² (coefficient of determination) measures how well the polynomial fits your data. Values range from 0 to 1, where 1 means perfect fit. R² > 0.9 is generally considered excellent, 0.7-0.9 good, and below 0.5 indicates poor fit.

How many data points do I need?

You need at least n+1 data points for a polynomial of degree n. For example, degree 2 (quadratic) requires at least 3 points. More points generally produce more reliable results and better ability to detect the true relationship.

What is overfitting?

Overfitting occurs when you use too high a polynomial degree, making the curve pass through all points but creating wild oscillations. The model fits the noise in your data rather than the underlying pattern, hurting predictions for new data.

When should I use polynomial vs linear regression?

Use polynomial regression when you see clear curvature in a scatter plot of your data. If the relationship looks roughly straight, stick with linear (degree 1). Try degree 2 or 3 first before higher polynomials.

Can I extrapolate beyond my data?

Extrapolation with polynomials is risky, especially with higher degrees. Polynomials can diverge rapidly outside the range of your data. Only extrapolate if you have strong theoretical reasons to believe the polynomial relationship continues.

What's the difference between polynomial and multiple regression?

Polynomial regression uses powers of a single variable (x, x², x³). Multiple regression uses multiple different variables (x₁, x₂, x₃). Polynomial regression is for modeling non-linear single-variable relationships.

How do I choose the optimal degree?

Compare R² values for different degrees, but beware of overfitting. Also consider: (1) domain knowledge, (2) simplicity (prefer lower degrees), (3) cross-validation if you have enough data, and (4) visual inspection of the fitted curve.

What is the least squares method?

Least squares finds coefficients that minimize the sum of squared differences between observed Y values and predicted values. This calculator uses Gaussian elimination to solve the normal equations for the least squares solution.

Related Tools