Re: Calculate polynomial coefficients


nileiqi
07-15-2007, 09:41 PM
Hi expert,

I am new to NR.

I need help to find an algorithm to calculate the coefficient of a polynomial function for a non-linear least squares problem.

my engineering problem can be expressed following

z = scale * x + f(x, y)

z is output, scale is constant, x and y is input, and f(x, y) is an error term.

f(x, y) is a three-order polynomial function, it can be expressed as

f(x,y)=
c00 + c01x + c02(x^2) + c03(x^3) +
c10y + c11yx + c12y(x^2) + c13y(x^3) +
c20(y^2) + c21(y^2)x + c22(y^2)(x^2) + c23(y^2)(x^3) +
c30(y^3) + c31(y^3)x + c32(y^3)(x^2) + c33(y^3)(x^3)

I can get z data by manually set x,y data, What I want is to determine the following coefficients

| C00 C01 C02 C03 |
| C10 C11 C12 C13 |
| C20 C21 C22 C23 |
| C30 C31 C32 C33 |

to best fit the model.

I am not sure whether somewhere in NR can find such algorithm and C code ? Any idea and suggestion are appreciated. Thanks in advance.

Daniel