Using FPOLY to Fit a Polynomial to XY Data in METSIM

The mathematical function N FPOLY XY finds the coefficients for an N'th order polynomial which provides the lowest error squares fit for the X and Y values provided in a two column matrix.

The result is a vector with N + 1 items, with the coefficients for the polynomial, for the terms with power 0 to N.

To understand the result, consider the simplest polynomial: y = mx + c

It can be re-written as y = c.x^0 + m.x^1, and the co-efficients are c and m.

Extending this to a higher order poynomial y = c1.x^0 + c2.x^1 + c3.x^3 and solving for X and Y values using FPOLY we would find the values for c1, c2, c3 

In conventional mathematical notation (text books) polynomials are typically written with the non-zero power terms in increasing sequence from 1 to N but leaving out the power terms for which the co-efficient is zero, and then the zero-th power term (the constant) is written at the end - for example:  y = a.x + b.x^3 + c.x^4 + d

APLers would look at this and think y = d.x^0 + a.x^1 + 0.x^2 + b.x^3 + c.x^4