Consider the following data
or rearranging...
and
In general, if the polynomial is higher order, the sums simply increase in terms as per the order of the polynomial. For example, second order polynomial produces three sums corresponding to three coefficients which look in matrix form like...
Clearly, the elements of the matrices look like
where k and j run from 0 to M, where M is the order of the polynomial.
where A is the coefficient matrix. Solving
Now, let us apply this to the data provided above for a first and second order fit..
This is read as
Plotting the results...
Which is what we saw previously.
Now, let us fit again to a second order polynomial...Now
Which is a much better fit.
As long as the function is a polynomial, this procedure works extremely well. Most software packages, including this MCAD have regression built in. In MCAD, the regression is accomplished using the built in function, regress. Using the data as above, it is executed as follows:
Obviously, the x and y are the data values used. The 2 is the order.
As you can see, there seem to be too many numbers! The first three numbers are those utilized by MCAD and can be disregarded unless more advanced work is carried out. Note that the last three numbers are identical to the fit obtained earlier.
This whole process can clearly be outlined in a very efficient fashion. Your humble professor has done this and the result is presented in as the MCAD document, GenLin.mcd. This document is reproduced below. Included in this is the calculation of the standard deviation of the coefficients and of the fit. Also included is a graphical fit for visual comparison.
To use this document, the user need only to replace the highlighted values with the data and order of fit desired.
In order to carry out this regression, the user is required to supply the number of data points, N, the order of the polynomial to be fit, Order, and the data points, x and y.
ref.. Peter C. Jurs "Computer Software Applications in Chemistry
Replace highlighted areas only with your data.
regression command
regression coefficients
Error analysis...
standard deviation of fit
standard deviations
of the coefficients
Final Equation...
Plotting data with curve fit...
In some instances, functions may appear to be non-linear, but can be manipulated into the proper form. As an example, consider the following function:
where A and B are constants to be determind.
Some representative data of T related to p is given and plotted as follows:
A cursory examination show that the relationship is clearly non-linear as plotted. However, we have a function that is purported to represent the data. We would like to fit the data to the function, however, we only have linear tools.