Quadratic Regression Calculator

Fit a quadratic and a straight line to the same x and y observations. Compare their residuals and training error on a common scale. Inspect the exact centered equation, see what supports the curvature term, and check whether the fitted turning point falls within the observed x range.

Polynomial least squares

Quadratic regression explorer

Fit a curve to observed pairs and compare its errors with a straight-line fit.

Observed x and y pairs

Enter 3–200 pairs in two columns, without a header. Separate x and y with a comma, a tab or whitespace.

Straight-line and quadratic fits

5 observations · 5 distinct x values

ModelRMSER²Residual SSE
Straight line2.17255610.016666666723.6
Quadratic0.3023715780.9809523810.457142857

Fitted y = ax² + bx + c

a
1.28571429
b
0.2
c
0.428571429

Standardized condition number 1.

A higher value means the centered predictor and its squared term are closer to alignment after standardization.

Show exact centered equation

t = x − (0)

ŷ = (9/7)t² + (1/5)t + (3/7)

Fitted minimum at x -0.0777777778, y 0.420793651. Within the observed x range.

These fit metrics use the entered observations. A lower training error can result from adding a term.

Fitted curves and observations

Plot coordinates are offsets from the sample means, x̄ 0 and ȳ 3.

Observed values and least-squares fits5 observations and a fitted line and quadratic curve. Values are in the observation ledger.x -2, y 5x -1, y 2x 0, y 0x 1, y 2x 2, y 6Fitted minimum at x -0.0777777778y offset · 3.48-2.242.24
  • Observed
  • Straight line
  • Quadratic
  • Turning point
Compare residuals
Residuals on a shared response scalePositive residuals appear above zero. The plot uses the same axis scale when you select individual fits.+3.360−3.36Line residual at x -2: 2.4Quadratic residual at x -2: -0.171428571Line residual at x -1: -0.8Quadratic residual at x -1: 0.485714286Line residual at x 0: -3Quadratic residual at x 0: -0.428571429Line residual at x 1: -1.2Quadratic residual at x 1: 0.0857142857Line residual at x 2: 2.6Quadratic residual at x 2: 0.0285714286

Each residual is the observed y minus its fitted value.

Observation and residual ledger

RowEntered xEntered yLine fittedLine residualQuadratic fittedQuadratic residual
1-252.62.45.17142857-0.171428571
2-122.8-0.81.514285710.485714286
3003-30.428571429-0.428571429
4123.2-1.21.914285710.0857142857
5263.42.65.971428570.0285714286

How to use this calculator

  1. Paste 3 to 200 observed pairs in two columns. Separate x and y by a comma, tab or whitespace. Keep each row's x and y together.
  2. Compare Straight-line and quadratic fits. Repeated x values each contribute an observation. At least three distinct x values are needed to estimate curvature.
  3. Review the fitted coefficients and exact centered equation. Check the standardized condition number and whether the fitted turning point lies within the observed x range.
  4. Inspect the plotted fits and select a residual series. The residual scale stays fixed as you switch between the models.
  5. Review the Observation and residual ledger. Download quadratic regression CSV for exact coefficients, fitted values and residuals.

The Formula

The mathematical logic powering this calculation is:

The quadratic model ŷ = ax² + bx + c and straight-line model ŷ = mx + k each minimize the sum of squared residuals on the same data. Center t = x − x̄. Orthogonalize the squared term by setting u = t² − mean(t²), then w = u − t × Σ(tu)/Σt². The coefficient on the extra term is a = Σ[w(y − ȳ)]/Σw². The straight-line slope is m = Σ[t(y − ȳ)]/Σt². The centered fit is ŷ = ȳ + mt + aw, and the equivalent expanded coefficients are in the results.

The standardized condition number measures how strongly the centered predictor and its squared term align after each is scaled to unit length. With correlation magnitude |r| between t and u, it equals (1 + |r|)/√(1 − r²). A large number indicates near dependence between those two columns. The exact rank comes from the entered distinct x values. Fitting the quadratic needs at least three distinct x values.

When a ≠ 0, the fitted turning point is x = −b/(2a), a minimum for positive a and a maximum for negative a. The observed range includes its endpoints for this comparison. A zero fitted a yields no isolated turning point. The graph marks a turning point when it lies in range.

Residual = observed y − fitted y. SSE = Σ residual², RMSE = √(SSE/n), and R² = 1 − SSE/Σ(y − ȳ)² when y varies. The CSV also gives residual standard deviation with denominator n minus the number of fitted parameters when degrees of freedom are positive. These values describe fit to the entered observations.

Enter 3–200 pairs, using signed decimal or scientific numbers up to ±1 trillion and 12 effective decimal places. Explicit exponents must lie from −12 to 12. Means, coefficients, residuals, SSE, R² and turning-point coordinates use exact rational arithmetic. Displayed square roots, condition number and graph coordinates are numerical approximations.

Worked Example

If you input:

  • Observed x, y pairs: (−2,5), (−1,2), (0,0), (1,2), (2,6)

Result:

The line has RMSE about 2.17256 and R² about 0.01667. The quadratic is ŷ = (9/7)x² + (1/5)x + 3/7, with RMSE about 0.30237 and R² about 0.98095. Its fitted minimum occurs at x = −7/90 and y = 2651/6300, within the observed x range.

Frequently Asked Questions

What is quadratic regression?

It estimates the coefficients a, b and c that minimize squared differences between the observed y values and ax² + bx + c. Input is a set of observed pairs. When coefficients are already known, a quadratic equation calculator can solve for its roots.

Why does the quadratic training error usually decrease?

The quadratic contains the straight line as the special case where a equals zero. Adding the term can lower the error on the same observations. Evaluating whether that improvement generalizes calls for new data or a separate validation design.

Can I use repeated x values?

Yes. Each repeated observation remains in the fit. Two distinct x values support a line. Three or more distinct values are needed to estimate the quadratic curve.

What does the standardized condition number mean?

It describes the alignment of the centered predictor and its squared term after standardizing the two columns. One means those two columns are orthogonal. Larger values mean the design has less separation between them. Exact arithmetic keeps the reported fit for the supplied observations.

Is the turning point an observed maximum or minimum?

It is the fitted curve's minimum or maximum. Its location is compared with the observed x range. If the fitted turning point is outside the range, it describes an extrapolated feature. If the quadratic term is zero, there is no isolated turning point.

Why is R² unavailable for constant y?

Every observed y equals its mean, so the total sum of squares is zero. Both fits reproduce the constant response and have zero RMSE. The R² ratio is undefined.

What does the NIST Pontius example contain?

It loads the 40 observed load-cell calibration pairs in the NIST Statistical Reference Datasets collection. The published reference includes the quadratic coefficients, R² and residual sum of squares.

Similar Calculators