## SFIT

The SFIT function determines a polynomial fit to a surface and returns a fitted array. The function fitted is:

This routine is written in the IDL language. Its source code can be found in the file ``` sfit.pro``` in the ``` lib``` subdirectory of the IDL distribution.

### Calling Sequence

Result = SFIT( Data, Degree )

### Arguments

#### Data

The two-dimensional array of data to fit. The sizes of the dimensions may be unequal.

#### Degree

The maximum degree of fit (in one dimension).

### Keywords

#### KX

Set this keyword to a named variable that will contain the array of coefficients for a polynomial function of x and y to fit data. This parameter is returned as a Degree +1 by Degree +1 array.

### Example

Create a grid from zero to six radians in the X and Y directions:

X = (FINDGEN(61)/10) # REPLICATE(1,61)

Y = TRANSPOSE(X)

Evaluate a function at each point:

F = -SIN(2*X) + COS(Y/2)

Compute a sixth-degree polynomial fit to the function data:

result = SFIT(F, 6)

Display the original function on the left and the fitted function on the right, using

identical axis scaling:

WINDOW, XSIZE = 800, YSIZE = 400

!P.MULTI = [0, 2, 1] ; Set up side-by-side plots.

!P.BACKGROUND = 255 ; Set background color to white.

!P.COLOR = 0 ; Set plot color to black.

SURFACE, F, X, Y, ZRANGE = [-3, 3], ZSTYLE = 1

SURFACE, result, X, Y