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:

  1. Calculate the matrix and vectors
  2. Solve the linear equations for coefficients
  3. Calculate the coefficient of determination,
  4. Plot the fitted function with experimental data to verify curve fit.