Bivariate Polynomial Regression - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.
Our website is currently undergoing maintenance, which may result in occasional errors while browsing. We apologize for any inconvenience this may cause and are working swiftly to restore full functionality. Thank you for your patience.

Online Help

All Products    Maple    MapleSim


Bivariate Polynomial Regression

This application:

• 

Allows arbitrary 3-D data to be specified (for example, a table of X, Y, Z points).

• 

Generates a bivariate polynomial with a customizable order.

• 

Fits the polynomial to the data with a least-squares fit.

• 

Plots the data against the best-fit polynomial surface.

Specify the Data Set

Below we include some sample point data in a DataTable component and associate it with the variable data.

 

Alternatively, this data could be imported from an external source using the Import command.

 

Define Model Equation

The general form of a bivariate polynomial of total degree n is given by:

f:=nj=0ni=0nai,jxiyj

fnj=0ni=0nai,jxiyj

(2.1)

For example, the general form for a bivariate quadratic is:

f2

a2,2x2y2+a2,1x2y+a1,2xy2+a2,0x2+a1,1xy+a0,2y2+a1,0x+a0,1y+a0,0

(2.2)

Next, we choose the order of the bivariate polynomial which we will fit to the points. Increasing this value will refine the fit.

n  3

n3

(2.3)

poly  unapplyfn,x,y

polyx,yx3y3a3,3+x3y2a3,2+x2y3a2,3+x3ya3,1+x2y2a2,2+xy3a1,3+x3a3,0+x2ya2,1+xy2a1,2+y3a0,3+x2a2,0+xya1,1+y2a0,2+xa1,0+ya0,1+a0,0

(2.4)

 

Calculate Parameters by Least Squares Minimization

 

Separate and normalize the data

withLinearAlgebra:

X  Normalizedata.., 1, Euclidean

Y  Normalizedata.., 2, Euclidean

Z  data.., 3

nRows  RowDimensiondata

nRows176

(3.1)

Define objective function:

sse  addpolyXi, YiZi2, i = 1 .. nRows :

Minimize the objective function:

results  Optimization:-Minimizesse, iterationlimit = 10000000

results5570.44474478066,a0,0=845.161626107227,a0,1=−86.1947006441847,a0,2=−1458.30435684866,a0,3=281.463539195567,a1,0=217.408601231041,a1,1=741.790713963987,a1,2=−2291.92998724700,a1,3=−40269.8139678015,a2,0=−2406.91365945783,a2,1=2106.61413635412,a2,2=−35753.8882512417,a2,3=−291162.032188614,a3,0=−378.725838677108,a3,1=24869.3026839377,a3,2=−349072.733326674,a3,3=1.15434999607485×106

(3.2)

 

Assign the values corresponding to the minimum value to the parameters:

assignresults2

 

Plot Original Data against Best Fit Surface

Original Data:

p1  plots:-pointplot3dX,Y,Z,color=black,symbol=solidsphere,symbolsize=10

Best Fit Surface:

p2:=plot3dpolyx,y,x=minX..maxX,y=minY..maxY,style=patchnogrid,transparency=0.5

plots:-displayp1,p2