Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

How to fit a 2 variables polynomial (3D graph) to a set of data: Need to extrapolate

  1. Jun 25, 2008 #1
    Please tell me if some of you know of a way, or program that I can download or use to fit a given polynomial to a set of data.

    I have done an experiment in which I varied two currents thru wires (Ix, Iy) and measured the Temperature at a given point (T). The polynomial is known from a model (I still don't know it for sure), but lets say that it is:

    T = a+ b(Ix) + c(Iy) + d(Ix)^4 + e(Iy)^4

    I need to obtain the value of this polynomial, because the current where measured (Ix from 0 to 8, Iy from 0 to 8), and I need values in the range of Ix=8, Iy=10 (Extrapolate).

    Most of the programs I used for data manipulation fit polynomial for 2D curves (only one variable), not surfaces.
  2. jcsd
  3. Jun 25, 2008 #2
    Re: How to fit a 2 variables polynomial (3D graph) to a set of data: Need to extrapol

    I found a program that does it. DataFit, from http://www.curvefitting.com/

    Now I only need to work on the model.

    Where and what can I read to solve the problem of obtaining the temperature at a distance from a wire with a current passing thru it?
  4. Jun 25, 2008 #3
    Re: How to fit a 2 variables polynomial (3D graph) to a set of data: Need to extrapol

    Well, you could try to use linear algebra... let's say you need to fit the points


    Suppose your function is in the form

    z = Ax + By + C

    So, we have three variables, but 5 equations. If you consider the matrix

    M =

    and the matrix

    b =

    you'll find that the equation

    [tex]Ax = b[/tex]


    [tex] x =


    models the situation in terms of simultaneous equations which we are trying to solve. Now obviously, we can't find A,B,C such that all of these equations are satisfied. So, we will try to find the best values for A,B,C. This works if we solve

    [tex]M^T M x = M^T b[/tex]

    Note that the left hand side yields a square matrix which is invertible while the right hand side yields a column vector. If we solve this, we get: A = -0.102656, B = -0.454035, C = 6.01481. Thus, this plane best models the given points: Ax + By + C = z, where I just stated the values for A, B, C. Now, a question you may have is, why did I multiply both sides by M transpose? This has to do with the projection of rowspaces onto other subspaces. Read a linear algebra book to find out why :P The cool part about this is you can extend the models to n dimensions and in addition, your models don't necessarily have to be lines, or planes. It could even be something like

    [tex]z = Ax^23 - Be^x + C \sin x - D[/tex]
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook