Free browser-based ML tool

Quadratic Regression Calculator

Fit a quadratic parabola y = ax² + bx + c to CSV data in your browser. Get exact coefficients a, b, c, vertex (h, k), R², holdout RMSE, residuals, and JS/Python code.

Free to useNo upload or sign-inRuns entirely in your browser
Live calculation
Powered by @kanaries/ml

Data stays in this tab. Limits: 2,000 rows, 30 columns; customer clustering: 500 customers and 12 features.

Choose columns, then calculate. Changing an input hides the previous result until you run again.

Preview input (15 rows)
xy
05
110
219
332
449
570
695
7124
8157
9194
10235
11280
12329
13382
14439

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:

  1. Standardize the predictor: Compute the mean μ and population standard deviation σ of x, then transform to z = (x − μ) / σ.
  2. Solve least squares in standardized space: Expand features [z, z²] and fit ordinary least squares via Linear.LinearRegression in @kanaries/ml to obtain well-conditioned coefficients c₀ + c₁z + c₂z².
  3. Recover exact standard coefficients: Expand algebraically back to original units so a = c₂ / σ², b = c₁ / σ − 2c₂μ / σ², and c = c₀ − c₁μ / σ + c₂μ² / σ².
  4. Locate the vertex: Whenever a ≠ 0, compute the exact extremum h = −b / (2a) and k = ah² + bh + c. Positive a means the parabola opens upward (minimum at the vertex); negative a means 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:

ModelEquationShape & turning pointsWhen to prefer it
Linear (degree 1)y = mx + bConstant slope, zero bendsResiduals are flat and quadratic holdout RMSE does not improve meaningfully
Quadratic (degree 2)y = ax² + bx + cSingle symmetric bend with vertex (h, k)Clear arch or U-shape, diminishing returns, projectile/acceleration laws
Cubic (degree 3)y = ax³ + bx² + cx + dUp to two bends and one inflection pointS-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. If a is very close to zero compared with the scale of y, 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 b and intercept c: Together with a, b shifts the horizontal location of the vertex h = −b / (2a), while c is the fitted value at x = 0. When x = 0 lies far outside your measured range (such as years or temperatures in Kelvin), avoid over-interpreting c on 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.

Frequently asked questions

Questions about quadratic regression calculator

How does quadratic regression find a, b, and c?

Quadratic regression solves ordinary least squares for the degree-2 model y = ax² + bx + c by minimizing the sum of squared vertical residuals Σ(yᵢ − ŷᵢ)². Internally, this calculator centers and scales X before fitting in @kanaries/ml for numerical stability, then algebraically converts the fitted curve back into exact standard coefficients a, b, and c.

How is the vertex (h, k) calculated from the quadratic equation?

For any parabola y = ax² + bx + c with a ≠ 0, the turning point (minimum if a > 0, maximum if a < 0) occurs at h = −b / (2a) and k = a·h² + b·h + c. The calculator displays (h, k) automatically in the summary cards.

How do I know if quadratic regression is better than linear regression?

Compare both the residual plot and holdout RMSE. If a linear fit leaves a clear U-shaped or arch-shaped residual pattern and the degree-2 model lowers holdout RMSE meaningfully while flattening residuals around zero, a quadratic term captures genuine curvature.

Can I predict Y for a new X value?

Yes. After running the fit, enter any numeric X in the Predict Y at X box to compute ŷ immediately. Keep in mind that quadratic curves grow or bend sharply outside the observed X interval, so extrapolation far beyond your sample range should be treated cautiously.

When should I switch to higher-degree polynomial regression?

Stick to quadratic regression when your curve has a single bend or turning point (such as projectile motion, diminishing returns, or U-shaped cost curves). If residuals still show an S-shape or multiple inflection points, open the Polynomial Regression Calculator to compare degrees 1 through 6 on holdout error.

Powered by @kanaries/ml — the scikit-learn-style ML library for JavaScriptnpmGitHub