Quadratic Regression Calculator y = ax² + bx + c
Paste your data below (one point per line as x y or x,y). You get the best-fit parabola, R², a live scatter plot with the fitted curve, and the coefficients — with the steps and the NumPy code.
This free quadratic regression calculator fits the best parabola y = ax² + bx + c through your data, draws the curve on a live scatter plot, and reports the coefficients and R² — then shows the working and the NumPy code. Paste your points above, press Fit curve, and you see exactly how well a single-bend curve describes the relationship, not just the numbers.
What quadratic regression actually does
Quadratic regression finds the parabola that comes closest to a set of data points. “Closest” has the same precise meaning it has in linear regression: the curve that minimises the sum of the squared vertical distances between each point and the curve — the least squares criterion. Those vertical distances are the residuals, and this calculator draws them as faint lines from each point to the fitted curve so you can literally see what is being minimised. The difference from a straight line is the extra x² term, which lets the model bend once: up-then-down, or down-then-up.
The coefficient a controls the curvature and the direction of the bend — a positive a opens the parabola upward (a valley), a negative a opens it downward (a hill). The coefficient b shifts and tilts the curve, and c is the value of y when x is zero, the point where the curve crosses the vertical axis. Together the three numbers define the parabola, and once you have them you can compute the fitted y for any x.
How to use the quadratic regression calculator
- Enter your data, one point per line, as
x yorx,y. You need at least three points with at least three distinct x values. - Press Fit curve. The best-fit equation, the coefficients a, b and c, and R² appear instantly, alongside a scatter plot with the parabola drawn through the points.
- Change the Decimal places selector if you need more or fewer digits, then press Copy result to grab the equation for a report or notebook.
- Open Show the working to see the sums and the normal-equation solution that produced the coefficients.
Try the example presets to see a clean upward parabola, a wider U-curve, and a downward hill — a fast way to build intuition for what the sign of a means.
The normal equations
To fit y = ax² + bx + c by least squares you solve a system of three linear equations, called the normal equations, in the three unknowns. Written with the running sums over your n points, the system is:
n·c + Σx·b + Σx²·a = Σy
Σx·c + Σx²·b + Σx³·a = Σxy
Σx²·c + Σx³·b + Σx⁴·a = Σx²y
The calculator builds the seven sums — Σx, Σx², Σx³, Σx⁴, Σy, Σxy, and Σx²y — then solves the 3×3 system with Cramer’s rule. The determinant of the coefficient matrix must be non-zero, which is exactly why you need at least three distinct x values: if all your points share fewer than three x positions, the system is singular and no unique parabola exists.
Worked example
Take the five points (-2, 4), (-1, 1), (0, 0), (1, 1), (2, 4) — the built-in Parabola preset. Summing over the points gives Σx = 0, Σx² = 10, Σx³ = 0, Σx⁴ = 34, Σy = 10, Σxy = 0, and Σx²y = 34. Solving the normal equations returns a = 1, b = 0, c = 0, so the fitted curve is simply y = x². Because every point lies exactly on that parabola, the residuals are all zero and R² is 1. Press the Parabola chip above to reproduce this instantly.
What R² tells you
A parabola will fit almost any small dataset, so you need a number that says how well. The coefficient of determination R² answers that. It is defined as 1 − SSres / SStot, where SSres is the sum of squared residuals from the curve and SStot is the total squared spread of y around its mean. R² ranges from 0 to 1: a value of 0.99 means the curve explains 99% of the variation in y, while a value near 0 means the parabola barely helps. Reading R² together with the plot is the fastest way to judge whether a quadratic model is appropriate for your data.
Quadratic versus linear: when to use which
Use linear regression when the relationship is a straight trend — y rises or falls at a roughly constant rate. Reach for quadratic regression when the data has a single clear bend: a quantity that rises then falls (like projectile height over time, or yield versus temperature), or one that falls then rises (like cost per unit versus production volume). The tell is a scatter plot that curves once. If the data bends more than once — two or more turning points — a quadratic is too rigid and you want a higher-degree polynomial or a different model entirely. A quick check: fit a line first, and if the residuals show a systematic U-shape rather than random scatter, the quadratic term is capturing real structure.
Quadratic regression in Python with NumPy
In practice you will fit regressions in code. NumPy does a quadratic fit in one line with polyfit, passing degree 2:
import numpy as np
x = np.array([-2, -1, 0, 1, 2])
y = np.array([4, 1, 0, 1, 4])
a, b, c = np.polyfit(x, y, 2) # highest power first
print(a, b, c)
# R-squared:
fit = a*x**2 + b*x + c
ss_res = np.sum((y - fit)**2)
ss_tot = np.sum((y - y.mean())**2)
print(1 - ss_res/ss_tot)
Note that np.polyfit returns the coefficients highest-power first, so the first value is a, then b, then c — the same order this calculator reports. Change the 2 to 1 for a line or 3 for a cubic, and you have the whole polynomial-regression family.
Two traps sink most quadratic fits. First, overfitting: a parabola can hug a handful of noisy points and post a high R² that vanishes on new data — more points and a look at the residuals guard against this. Second, extrapolation: a parabola shoots off to infinity beyond your data range, so a fitted curve that looks sensible between your points can give wildly wrong predictions just outside them. Trust the fit only inside the range of x values you actually measured.
Where quadratic regression shows up in machine learning
Quadratic regression is the simplest example of polynomial feature expansion, a core idea in machine learning: you take a linear model and feed it x² as an extra input feature, and suddenly a linear method can capture curvature. The same trick scales up — adding higher-order and interaction terms lets linear models fit rich non-linear surfaces, and it is the intuition behind kernel methods and basis-function regression. Understanding how the single x² term changes the fit, and how R² and the residuals respond, makes those more advanced techniques far easier to reason about.
Frequently asked questions
How many data points do I need?
At least three, with at least three distinct x values, to pin down the three coefficients. More points give a more reliable fit and a more trustworthy R²; three points alone will pass exactly through a parabola and always show R² = 1, which tells you nothing about generalisation.
Why do I get a "need distinct x values" error?
Fitting three coefficients requires the 3×3 normal-equation matrix to be invertible, and that fails when your points do not span at least three different x positions. Add points at new x values and the error clears.
Is the result the same as Excel or NumPy?
Yes. The coefficients and R² match numpy.polyfit(x, y, 2) and Excel’s LINEST with a squared term, because they all solve the same least-squares normal equations.
Should I use quadratic or a higher-degree polynomial?
Use quadratic when the data bends once. If the scatter shows two or more turning points, a cubic or higher polynomial fits better — but beware overfitting as the degree climbs.
Is the calculator free?
Completely free, no sign-up, and it runs entirely in your browser — including the chart, which never sends your data anywhere.
Related calculators
Compare fits with the general regression calculator, start simpler with the linear regression calculator, or go further with the polynomial regression calculator for curves with more than one bend.