Thread: A Cubic regression to a number of points (2 independent variables!)

1. A Cubic regression to a number of points (2 independent variables!)

Hi All,

I posted this question to the pre-university problem a few days ago, but it seems nobody can answer, so I will try my luck here.

I want to approximate a surface with a cubic regression in the following form. (Where X is the temperature, Y time and and z the energy requirement: Thus f(x,y)=z.)

a⋅x^3+b⋅x^3+c⋅x^2⋅y^2+d⋅x^2⋅y+e⋅x⋅y^2+f⋅x^2+g⋅ y^2+ h⋅x⋅y+i⋅x+j⋅y+k

However I am not sure if I wrote correctly the cubic equation???
If somebody could tell me wherever it is correct or not. And if not, what is wrong :-)

a,b,c,d,...etc. are the coefficients.

By the way, what is the general form of such two variables dependent quadratic or cubic equations?

Thanks a lot in advance.

Cheers,
Martin

2. it is a^x3+b^y3...sorry for the typing error (not a^x3+b^x3).

cheers,
Martin

3. Write it as:

$u(x,y)=a +bx+cy+dx^2+ey^2+fxy+gx^2y+hyx^2+ix^3+jy^3$

The following Mathematica code first generates a list {{x_1,y_1,z_1},. . .{x_n,y_n,z_n}} for the function $\sin(xy)$ then fits the data points to u(x,y) then superimposes the plots to obtain a quick visual indication of how well the fit was determined.

Code:
f[x_,y_]=Sin[x y];
mytable = Flatten[Table[{x, y, f[x, y]},
{x, -1, 1, 0.1}, {y, -1, 1, 0.1}],
1];
myequation = a + b*x + c*y + d*x^2 +
e*y^2 + f*x*y + g*x^2*y + h*y^2*x +
i*y^3 + j*x^3;
myconstants = FindFit[mytable,
myequation, {a, b, c, d, e, f, g, h,
i, j}, {x, y}]
pic2 = Plot3D[myequation /. myconstants,
{x, -1, 1}, {y, -1, 1},
PlotStyle -> Blue]
Show[{pic1, pic2}]

4. Thanks a lot for your help, although I don't have mathemtica to use the code. But you helped me a lot writing correctly down the polynom!

Cheers,

Martin