We extend least squares criterion to fit polynomials with higher orders.
For example, a second order polynomial:
In this case, the sum of squares of residuals would be:
Taking the derivative with respect to the coefficients:
Setting these equal to and rearranging gives:
We can rewrite this into form:
which we can then solve with a method like Gauss-Seidel or Gaussian Elimination.
Note that this extends to polynomials of any order as long as the is less than the number of data points .
So, the steps are:
- Calculate the matrix and vectors
- Solve the linear equations for coefficients
- Calculate the coefficient of determination,
- Plot the fitted function with experimental data to verify curve fit.