Cubic Regression Calculator
Find cubic polynomials of best fit step by step
The calculator will find the cubic polynomial of best fit for the given set of paired data using the least squares method, with steps shown.
Related calculators: Linear Regression Calculator, Quadratic Regression Calculator
Your Input
Find the cubic polynomial of best fit for $$$\left\{\left(-2, -7\right), \left(-1, -1\right), \left(0, 0\right), \left(1, 2\right), \left(2, 5\right)\right\}$$$.
Solution
The number of observations is $$$n = 5$$$.
Generate the following matrix $$$M = \left[\begin{array}{cccc}\left(-2\right)^{3} & \left(-2\right)^{2} & -2 & 1\\\left(-1\right)^{3} & \left(-1\right)^{2} & -1 & 1\\0^{3} & 0^{2} & 0 & 1\\1^{3} & 1^{2} & 1 & 1\\2^{3} & 2^{2} & 2 & 1\end{array}\right].$$$
Generate the following vector $$$Y = \left[\begin{array}{c}-7\\-1\\0\\2\\5\end{array}\right]$$$.
The vector of coefficients is $$$X = \left(M^T M\right)^{-1}M^T Y = \left[\begin{array}{c}\frac{1}{2}\\- \frac{5}{14}\\1\\\frac{18}{35}\end{array}\right]$$$.
Thus, the cubic polynomial of best fit is $$$y = \frac{x^{3}}{2} - \frac{5 x^{2}}{14} + x + \frac{18}{35}$$$.
Answer
The cubic polynomial of best fit is $$$y = \frac{x^{3}}{2} - \frac{5 x^{2}}{14} + x + \frac{18}{35}\approx 0.5 x^{3} - 0.357142857142857 x^{2} + x + 0.514285714285714.$$$A