by James Thomas Lee, Jr. 12/25/97 Copyrighted 1995 by James Thomas Lee, Jr. Copyright Number: XXx xxx-xxx
Again, like with the linear least squares technique from above, polynomial least squares begins with the definition of a deviation-squared function.
1. Therefore, let f = SUM (y(i) - a1x(i)**2 - a2x(i) - a3)**2, where a1, a2, and a3 are coefficients,
y(i) => the observed value for y, x(i) => the observed value for x.
2. Find Partial(f) / Partial(a1) , Partial(f) / Partial(a2) , Partial(f) / Partial(a3), and set to zero to minimize the variance.
3. This will yield the following equations:
Partial(f) a. ----------- = 2 SUM (y(i) - a1x(i)**2 - a2x(i) - a3 ) (-x(i)**2) = 0 Partial(a1) Partial(f) b. ----------- = 2 SUM (y(i) - a1x(i)**2 - a2x(i) - a3 ) (-x(i)) = 0 Partial(a2) Partial(f) c. ----------- = SUM (y(i) - a1x(i)**2 - a2x(i) - a3 ) (-1) = 0 Partial(a3)
4. The above equations from Step 3 can be set up in the following matrix format:
| | | | | | | SUM(x(i)**2y(i)) | | SUM(x(i)**4) SUM(x(i)**3 SUM(x(i)**2 | | a1 | | | | | | | | SUM(x(i)y(i)) | = | SUM(x(i)**3) SUM(x(i)**2 SUM(x(i)) | | a2 | | | | | | | | SUM(y(i)) | | SUM(x(i)**2) SUM(x(i) n | | a3 | | | | | | |
5. Determinant of Matrix A.
Let a1 = nSUM(x(i)**2) - (SUM(x(i))**2 a2 = nSUM(x(i)**3) - SUM(x(i))SUM(x(i)**2) a3 = SUM(x(i))SUM(x(i)**3) - (SUM(x(i)**2)**2 a4 = nSUM(x(i)**4) - (SUM(x(i)**2))**2 a5 = SUM(x(i))SUM(x(i)**4) - SUM(x(i)**2)SUM(x(i)**3) a6 = SUM(x(i)**2)SUM(x(i)**3) - (SUM(x(i)**3))**2 det(A) = SUM(x(i)**4)(a1) - SUM(x(i)**3)(a2) + SUM(x(i)**2)(a3)6. Using co-factors, | | | a1 -a2 a3 | | ----- ----- ----- | | det(A) det(A) det(A) | | | | | | -a2 a4 -a5 | Inverse of A (A**-1) = | ----- ----- ----- | | det(A) det(A) det(A) | | | | | | a3 -a5 a6 | | ----- ----- ----- | | det(A) det(A) det(A) | | |
7. Using A**-1, the coefficients, a1, a2, and a3, can be found and are as follows:
(SUM(x(i)**2y(i))(a1) - (SUM(x(i)y(i))(a2) + (SUM(y(i))(a3) a1 = ------------------------------------------------------------------------ det(A) (SUM(x(i)**2y(i))(-a2) + (SUM(x(i)y(i))(a4) + (SUM(y(i))(-a5) a2 = ------------------------------------------------------------------------ det(A) (SUM(x(i)**2y(i))(a3) + (SUM(x(i)y(i))(-a5) + (SUM(y(i))(a6) a3 = ------------------------------------------------------------------------ det(A)
Appendix D. The Implementation of a Special Language Interpreter
Send email to: tlee6040@aol.com