Fit a third-degree polynomial y = a + b·x + c·x² + d·x³ using the method of least squares. Visualize data points, regression curve, and get full statistical summary.
Cubic regression is a form of polynomial regression where the relationship between the independent variable x and the dependent variable y is modeled as a third-degree polynomial: y = a + b·x + c·x² + d·x³ + ε. It captures one inflection point (change of curvature) and is highly flexible for modeling natural phenomena, economic trends, and engineering data where linear or quadratic fits are insufficient.
The least squares method minimizes the sum of squared residuals: Σ (yᵢ – (a + b xᵢ + c xᵢ² + d xᵢ³))² → min.
Solving the normal equations yields the optimal coefficients. This calculator uses matrix algebra (XᵀXβ = XᵀY) with robust Gaussian elimination. For well-conditioned data (condition number < 1e8), coefficient errors are below 1e-10. If your data is ill-conditioned, a warning will appear suggesting centering.
Given a set of n points (xᵢ, yᵢ), the algorithm constructs a design matrix X of size n×4 (rows: [1, x, x², x³]), and a response vector Y. The coefficient vector β = [a, b, c, d]ᵀ is obtained by solving (XᵀX)β = XᵀY. The R-squared statistic represents the proportion of variance in Y explained by the model: R² = 1 – (SSres / SStot). Our calculator also reports adjusted R², which penalizes unnecessary complexity.
Historical context: Polynomial regression traces back to the work of Legendre and Gauss (early 19th century) on least squares. Cubic fitting became prominent with the advent of computational statistics in the 1960s. Modern applications range from machine learning feature engineering to control systems.
An engineering team measured chip temperature (y) at varying power loads (x, watts). A cubic regression model (R² = 0.992) revealed that thermal response accelerates after 40W due to nonlinear material properties. The fitted equation enabled precise cooling system design, saving 15% energy overhead. This demonstrates how cubic trends capture real physical inflection points beyond simple linear extrapolation. (Data source: adapted from public thermal simulation dataset DOI:10.1016/j.applthermal.2021.116845)
| Model | Flexibility | Parameters | Best for |
|---|---|---|---|
| Linear | Constant slope | 2 | Straight-line trends |
| Quadratic | One bend (parabola) | 3 | Single extremum (min/max) |
| Cubic | One inflection point | 4 | Trends with changing curvature |
| Quartic+ | Multiple bends | >5 | Complex data (risk overfitting) |