Cubic Regression Calculator

Cubic Regression Calculator

Fit y = ax³ + bx² + cx + d to data that bends twice, with R², the turning points, the inflection point where the bend changes direction, and predictions.

y = ax³ + bx² + cx + d · inflection at x = −b ÷ 3a

Enter at least 4 pairs of X and Y values

What is Cubic Regression?

Cubic regression fits a third-degree polynomial, y = ax³ + bx² + cx + d, to data whose curve changes direction of bending. Where a parabola bends one way, a cubic can bend one way and then the other.

That S-like flexibility suits cost curves (cheaper per unit at first, then dearer), learning curves that start slow, speed up and plateau, and dose-response data over a moderate range.

The inflection point is where the bending flips. On a cost curve it marks the output with the lowest extra cost per unit; on a growth curve, the moment growth was fastest.

Cubic Regression Formula

Least squares as in the NIST/SEMATECH e-Handbook, section 4.4.3. See Sources.

1. Least squares

Minimise Σ(y − ax³ − bx² − cx − d)² over a, b, c, d

This leads to four normal equations, solved together. The calculator centres X first so large values like years don't cause rounding problems.

2. Turning points

Solve 3ax² + 2bx + c = 0

If 4b² − 12ac is negative, the curve has no peaks or troughs: it just keeps rising or falling.

3. Inflection point

x = −b ÷ 3a, where 6ax + 2b = 0

Worked Example: A Factory's Cost Curve

Given:
Output in thousands of units 0, 1, 2, 3, 4, 5, 6 and total daily cost in £00 100, 150, 180, 196, 220, 270, 360.
Step 1:
Fit the cubic:
y = 2.778x³ − 21.238x² + 70.841x + 99.429
Step 2:
Inflection point:
x = −b ÷ 3a = 2.55 thousand units
Step 3:
Fit quality:
R² = 0.9998 · turning points: none
Result:
Extra cost per unit is lowest near 2,549 units a day

Below that, extra output gets cheaper as the factory settles into rhythm; above it, overtime and congestion make each extra unit dearer. With no turning points, total cost rises throughout, as it should.

Marginal Cost Along the Fitted Curve

The slope of the fitted cost curve, 3ax² + 2bx + c: the cost of one more thousand units at each output level.

Marginal cost from the fitted cubic
Output (000)Fitted cost (£00)Marginal cost (£00)
099.470.8
1151.836.7
2178.419.2
3195.818.4
4220.834.3
5269.966.8
6359.9116

Common Cubic Regression Mistakes

  • Fitting a cubic to a handful of points. With 4 points the curve goes through every one and R² = 1, which proves nothing.
  • Extrapolating. The x³ term dominates far from the data and sends predictions shooting off.
  • Over-reading tiny coefficients. A cubic term that barely improves adjusted R² is probably noise; compare with the quadratic fit.
  • Using a cubic for a true S-curve. Growth that levels off at a ceiling is better modelled by a logistic curve, which can't overshoot.

Cubic Regression FAQs

How many data points do I need?

At least 4 different X values, but ideally 10 or more so the fit can be judged.

Why are there sometimes no turning points?

When the curve rises or falls the whole way, its slope never reaches zero. It still has an inflection point.

Is a cubic always better than a quadratic?

It always fits at least as closely, but that doesn’t make it better. Use adjusted R² and the shape of the residuals to decide.

What does the inflection point mean?

The point where the rate of change is at its fastest or slowest. On a cost curve, that’s the lowest marginal cost.

How do I do this in Excel?

Add a polynomial trendline of order 3, or use =LINEST(y, x^{1,2,3}).

Can I fit even higher powers?

Yes, with the polynomial regression calculator, but higher orders wiggle more and generalise worse.

Why is X centred before fitting?

Raising large numbers like 2024 to the third power loses precision. Centring keeps the arithmetic accurate; the equation shown is converted back to your original X.

What do the units of the coefficients mean?

Each coefficient carries Y units divided by X units to the matching power, so they only make sense together, not one at a time.

Sources

Related Tools