Fit an exact parabola y = ax² + bx + c directly in your browser
Quadratic regression models a curved relationship between an input variable x and a continuous target y using a second-degree polynomial equation y = ax² + bx + c. It is the natural next step whenever a scatter plot curves upward or downward with a single bend—common in physics trajectories, dose–response experiments, pricing elasticity, manufacturing tolerances, and diminishing-returns curves.
Paste two-column or multi-column CSV data above, pick your X and Y columns, and click Calculate results. Everything runs client-side with @kanaries/ml without uploading your spreadsheet: you immediately receive the exact standard equation (a, b, and c), parabola vertex (h, k), full-data R² and RMSE, an 80/20 Holdout RMSE sanity check, fitted curve and residual plots, an instant single-point predictor, and reproducible JavaScript and Python code.
How quadratic least-squares fitting works under the hood
Naive quadratic calculators form raw normal equations directly in x and x². When x values are large (for example calendar years like 2015–2026 or timestamps), squaring x creates poorly conditioned matrices that lose floating-point precision. To prevent numerical drift, this tool follows the exact standardized pipeline recommended in scientific computing:
- Standardize the predictor: Compute the mean
μand population standard deviationσofx, then transform toz = (x − μ) / σ. - Solve least squares in standardized space: Expand features
[z, z²]and fit ordinary least squares viaLinear.LinearRegressionin@kanaries/mlto obtain well-conditioned coefficientsc₀ + c₁z + c₂z². - Recover exact standard coefficients: Expand algebraically back to original units so
a = c₂ / σ²,b = c₁ / σ − 2c₂μ / σ², andc = c₀ − c₁μ / σ + c₂μ² / σ². - Locate the vertex: Whenever
a ≠ 0, compute the exact extremumh = −b / (2a)andk = ah² + bh + c. Positiveameans the parabola opens upward (minimum at the vertex); negativeameans it opens downward (maximum at the vertex).
Worked example with the default dataset
The default sample contains 15 rows following y = 2x² + 3x + 5 for x = 0, 1, …, 14. Running the calculator recovers a = 2, b = 3, and c = 5 with R² = 1, RMSE = 0, Holdout RMSE = 0, and vertex (−0.75, 3.875). Evaluating at x = 3.5 predicts 2(3.5)² + 3(3.5) + 5 = 40. Try perturbing one or two rows to see how noise appears in the residual chart and widens the gap between training RMSE and holdout RMSE.
Reading R², holdout RMSE, and residual plots
Adding a squared term x² can never decrease training R²—even when the true relationship is purely linear plus random noise. That is why this calculator pairs every fit with two diagnostic checks that static calculators omit:
- Residual plot (observed − predicted): A healthy quadratic fit scatters residuals randomly around zero across the full range of
x. A leftover S-curve suggests a cubic model or nonlinear transform; a single huge residual spike suggests checking your data in the Outlier Calculator. - Fixed 80/20 Holdout RMSE: Every fifth row (rows 1, 6, 11, …) is held out while a separate quadratic model fits scaling and coefficients on the remaining 80% of rows. Compare this holdout RMSE against degree 1 (linear) and degree 3 (cubic) in the Polynomial Regression Calculator to verify that curvature improves out-of-sample accuracy rather than memorizing noise.
Cautions on extrapolation and time series
Parabolas accelerate quadratically outside the observed domain of x. Even a tight fit with R² = 0.99 inside x ∈ [0, 14] can diverge unrealistically at x = 30 if the underlying physical or business process saturates or follows an exponential growth curve. For chronological forecasting, always validate on a forward time split rather than interleaved holdout rows.
Comparing linear, quadratic, and cubic regression models
Students and analysts often wonder whether a dataset truly warrants a quadratic curve instead of a straight line or a higher-order cubic fit. A practical workflow is to test all three degrees on the exact same holdout split and inspect both error reduction and residual structure:
| Model | Equation | Shape & turning points | When to prefer it |
|---|---|---|---|
| Linear (degree 1) | y = mx + b | Constant slope, zero bends | Residuals are flat and quadratic holdout RMSE does not improve meaningfully |
| Quadratic (degree 2) | y = ax² + bx + c | Single symmetric bend with vertex (h, k) | Clear arch or U-shape, diminishing returns, projectile/acceleration laws |
| Cubic (degree 3) | y = ax³ + bx² + cx + d | Up to two bends and one inflection point | S-shaped curves where quadratic residuals still oscillate systematically |
Interpreting the quadratic equation parameters in practice
Each coefficient in y = ax² + bx + c carries a concrete geometric meaning that helps you sanity-check your fit before publishing charts or embedding predictions in an application:
- Curvature coefficient
a: Controls both the direction and steepness of the bend. Ifais very close to zero compared with the scale ofy, the quadratic term may be fitting noise and a simpler linear model in the Linear & Ridge Regression Calculator will generalize better. - Linear slope at origin
band interceptc: Together witha,bshifts the horizontal location of the vertexh = −b / (2a), whilecis the fitted value atx = 0. Whenx = 0lies far outside your measured range (such as years or temperatures in Kelvin), avoid over-interpretingcon its own—focus on fitted predictions inside the observed domain. - Exporting full precision for production code: Displayed summary stats round to six significant figures for readability. Whenever you embed the curve in a browser app, Edge function, or research notebook, copy the generated JavaScript or Python code or download the analysis JSON so you preserve full floating-point precision and standardization parameters.
Reproduce the fit in JavaScript or Python
Expand the code panel below the results table to copy a self-contained script embedding your dataset—in TypeScript/JavaScript using @kanaries/ml or in Python using scikit-learn (StandardScaler + PolynomialFeatures(2) + LinearRegression). Read How to Choose a Polynomial Degree Without Overfitting or explore the PolynomialRegression API reference to wire quadratic modeling directly into browser dashboards or Node.js services.