Understanding the quadratic and exponential regression calculator — concept and principle
When points curve instead of following a straight line, two common models are a parabola, y = ax² + bx + c, and an exponential curve, y = A·e^(bx). This calculator fits both by least squares so you can compare them.
How it is calculated
- Quadratic fit: solve the 3 × 3 normal equations for c, b, a: [n, Σx, Σx²; Σx, Σx², Σx³; Σx², Σx³, Σx⁴] × [c; b; a] = [Σy; Σxy; Σx²y]. The calculator uses Gauss–Jordan elimination.
- Exponential fit: take ln y, run ordinary linear regression of ln y on x to get slope b and intercept ln A, then A = e^(ln A). All y values must be positive.
- Growth per step = (e^b − 1) × 100%, the percentage change in y for each one-unit increase in x.
The principle
Both models are "linear in the parameters". A parabola is a straight-line model with an extra predictor x², so the least-squares conditions still form a linear system. An exponential becomes a straight line after taking logarithms, because ln y = ln A + bx. Note that the log method minimises squared errors in ln y, i.e. relative errors, so it gives the small values more weight than a direct non-linear fit would.
Worked example
- X = 1, 2, 3, 4, 5, 6 and Y = 2.1, 3.9, 8.2, 15.8, 32.5, 63 (n = 6).
- Sums: Σx = 21, Σx² = 91, Σx³ = 441, Σx⁴ = 2275, Σy = 125.5, Σxy = 638.2, Σx²y = 3424.8.
- Solving the normal equations gives y = 3.448214286x² − 12.76892857x + 13.31.
- ln y values have mean 2.43191; Σ(x − x̄)(ln y − mean) = 12.01133 and Σ(x − x̄)² = 17.5, so b = 0.6863615229.
- ln A = 2.43191 − 0.68636 × 3.5 = 0.02964, so A = 1.030083779: y = 1.030083779 · e^(0.6863615229x).
- Growth per step = (e^0.68636 − 1) × 100 = 98.65%.
How to read the result
Y roughly doubles each step (98.65% growth), so the doubling time is ln 2 ÷ b ≈ 1.01 steps. The quadratic also fits the range closely, but its negative middle term makes it dip near x = 2 and then curve upward, which is not how a growth process behaves. R² is 0.9887 for the quadratic (on y) and 0.9996 for the exponential (on ln y); on different scales, they are only a rough guide. Choose the model that matches the mechanism and gives sensible predictions, not only the one with the smaller error.
Common mistakes
- Entering zero or negative y values for the exponential fit (ln is undefined).
- Extrapolating a parabola, which eventually turns in the wrong direction.
- Comparing the two fits by R² computed on different scales (y versus ln y).
Frequently asked questions
Why is the exponential fit different from Excel's "Exponential trendline"?
Excel also fits ln y linearly, so the results should match; differences usually come from input errors.
How do I convert the exponential to the form y = A·Bˣ?
B = e^b. Here B = e^0.68636 ≈ 1.9865, so y ≈ 1.03 × 1.9865ˣ.
How many points does a quadratic fit need?
Three points define a parabola exactly; this calculator requires at least four so there is some information left to judge the fit.
Sources: NIST/SEMATECH e-Handbook of Statistical Methods. · Draper, N. R. & Smith, H. (1998). Applied Regression Analysis (3rd ed.). Wiley.