What cubic regression does
Cubic regression finds the third-degree polynomial that best fits a set of data points. The model is
y = ax³ + bx² + cx + d
The four coefficients a, b, c, and d are chosen so that the sum of the squared vertical distances between each observed point and the curve — the residual sum of squares — is as small as possible. This is the same least-squares principle used in straight-line regression, extended to a cubic. Because a cubic can bend twice (it has up to two turning points and one inflection point), it fits data that rises then falls then rises again, or curves that flatten and steepen, which a line (degree 1) or a parabola (degree 2) cannot capture.
How the coefficients are computed
For n data points, least squares reduces to a system of four linear equations in the four unknowns a, b, c, d — the "normal equations." In matrix form the design matrix X has rows [xᵢ³, xᵢ², xᵢ, 1], and the coefficients solve XᵀX·β = Xᵀy. The calculator above builds the 4×4 matrix XᵀX (which contains the sums of x, x², x³, up to x⁶) and the vector Xᵀy, then solves the system by Gaussian elimination with partial pivoting. No iteration or guessing is involved: for a given data set the answer is exact and unique whenever the x values are distinct and there are at least four of them.
Reading R²
R² (the coefficient of determination) reports the fraction of the variance in y that the fitted cubic explains, computed as 1 − SS_res/SS_tot, where SS_res is the residual sum of squares and SS_tot is the total sum of squares about the mean of y. R² = 1 means the curve passes exactly through every point; R² near 0 means the cubic is no better than simply predicting the average y. With exactly four distinct points a cubic always achieves R² = 1 because it interpolates them, so a high R² is only meaningful when you have comfortably more points than coefficients.
Where cubic regression is used
- Growth and dose-response curves: biological and chemical responses often accelerate, level off, then accelerate again — an S-shape a cubic can approximate over a limited range.
- Engineering calibration: sensor and instrument calibration curves are frequently modeled with low-degree polynomials, and a cubic captures mild curvature without over-fitting.
- Economics and forecasting: cost, yield, and trend data with a single hump or dip are common candidates for a cubic term.