# Thread: Simple Polynomial fit problem

1. ## Simple Polynomial fit problem

Dear users,

I have the following grid and I know value of a function f at each discrete point.

(0,2) (1,2) (2,2)
-----------------*-------------------
| | |
| | |
| | |
| | |
| | |
| | |
-----------------*--------------------
(0,0) (1,0) (2,0)

That is, I know the value of f(0,0),f(1,0),f(2,0),f(0,2),f(1,2) and f(2,2). I want to fit a 2nd degree or 3rd degree polynomial to this grid so that it passes through all the function values,f at each grid point.

I used the following 2nd degree polynomial to fit the function f:

a0 + a1*x + a2*y + a3*x*y +a4*x^2 + a5*y^2

If I plug in the values of x and y, I get the following system to solve:

A*X =B

where, A is a square matrix:
A=
1 0 0 0 0 0
1 1 0 0 1 0
1 2 0 0 4 0
1 0 2 0 0 4
1 1 2 2 1 4
1 2 2 4 4 4
B is a column matrix which contain function values and X is a column matrix which contains coefficients a0 to a5 to be determined.

I cannot solve this equation as determinant of A is zero!

Am I addressing this problem correctly? Is there a way to get a 2nd degree polynomial fit to this grid?

Thanks!

2. I think the grid didn't come out as I expected. I don't know how to draw it here but I think from the grid points [(0,0),(1,0),(2,0),(0,1),(1,1),(2,1)] one can visualize the grid.

Sorry about that...and I would really appreciate if somebody can shed some light on the problem.

Thanks!