1. PF Contest - Win "Conquering the Physics GRE" book! Click Here to Enter
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Interpolating A Surface

  1. Aug 22, 2010 #1
    So I have this surface that I am trying to make approximations on. Now I have values for [itex]f(x_1,y_1)[/itex] and [itex]f(x_2,y_2)[/itex]. I want to find the value of [itex]f(x,y)[/itex] where x and y lie between (x1, x2) and (y1, y2). I am willing to assume that f changes linearly in both x and y for this small interval. Would the appropriate interpolation function then be

    [tex]f(x,y)=f(x_1,y_1) + \frac{f(x_2,y_2) - f(x_1,y_1)}{x_2 - x_1} *(x - x_1) + \frac{f(x_2,y_2) - f(x_1,y_1)}{y_2 - y_1} *(y - y_1)[/tex]


    I feel like it would be ... but I also feel like it could be

    f(x_1,y_1) +
    [\frac{f(x_2,y_2) - f(x_1,y_1)}{x_2 - x_1} *(x - x_1)]^2
    [\frac{f(x_2,y_2) - f(x_1,y_1)}{y_2 - y_1} *(y - y_1)]^2

    What do you think? I am really confusing myself here :smile: First or second one?
  2. jcsd
  3. Aug 22, 2010 #2


    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    Your second possibility isn't first degree in its variables, which is what I think you mean. Let's say f(x1,y1) = z1 and f(x2,y2) = z2

    Then a general plane through the first point would be:

    z = a(x-x1) + b(y - y1) + z1.

    Making the plane go through the second plane requires:

    z2 = a(x2-x1) + b(y2 - y1) + z1

    This does not completely determine a and b. The problem is that there are infinitely many planes, first degree in each variable, passing through those two points, so there isn't any reasonable way to pick a best one. If you think about the straight line joining your two points in 3D, any plane containing that line interpolates your two points. You need another condition.
  4. Aug 22, 2010 #3
    Hi LCKurtz :smile: I think I am more confused now haha. I am thinking along the lines of something like this: I have some value f(x1,y1). Now couldn;t I say that for some local region "around" the point (x1,y1) I can approximate f(x,y) = f(x1,y1) + Δf where Δf is the "finite analog" to [itex]df = (\partial{f} /\partial{x})*dx + (\partial{f}/\partial{y})*dy[/itex].

    Am I still missing your point? Or does that work? Note that this is a "real problem" that I am working on here. I have some tabulated data and I am making some assumptions about the nature of the unknown funciton.

  5. Aug 22, 2010 #4


    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    Yes, you could with more information. That is the same thing as my suggestion z = a(x-x1) + b(y - y1) + z1 where your two partials are my a and b. The problem is that you don't have enough information to estimate the two partials fx and fy, which are a and b.
  6. Aug 22, 2010 #5
    I am sorry, I still don't follow. I thought that I did estimate the two partials :confused:

    [tex](\partial{f} /\partial{x}) \approx \frac{f(x_2,y_2) - f(x_1,y_1)}{x_2 - x_1} \text{ and }(\partial{f} /\partial{y}) \approx\frac{f(x_2,y_2) - f(x_1,y_1)}{y_2 - y_1}
  7. Aug 22, 2010 #6


    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    But you wouldn't estimate the fx by changing the y variable nor fy by changing the x variable. You would hold the other variable constant.

    Anyway, I'm guessing you haven't really posted what you want or need. Bivariate approximation is a big subject. Do you have a rectangular grid in the xy plane where you know the values? Or scattered values?

    I would suggest you Google interpolation of surfaces and look around. You might find just what you need.
  8. Aug 22, 2010 #7
    Actually, I have been Googling around and got so confused that I came here :redface:

    Let me post an example. I have a bunch of data tabulated as follows,


    You can see that for some value of "P" in the header (for example P = 0.06 MPa) we have a bunch of Temperatures and corresponding values of properties. For example for
    P = 0.06 MPa we can scroll down to T = 10 and see that the corresponding value of v is
    v = 0.37861.

    Similarly we can see that for P = 0.10 MPa and T = 30 we have v = 0.24216.

    My question is what if I want to approximate a value of v for P = 0.08 MPa and T = 15 ?

    I cannot seem to figure out what kind of bivariate interpolation this falls under, nor do I know what determines which kind of interpolation I should use. It seems like I have a regular rectangular grid here... I think. But not all of the tables like the ones above have the same temperature range. But working with the 2 above would be a good start.
  9. Aug 22, 2010 #8


    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    This is getting a bit out of my area of expertise. One method I have read a bit about is the quadratic Shepard's method. This interpolates 2d data with a smooth quadratic function. There are implementations in Fortran and I suppose other languages. For example, look at:

    http://people.sc.fsu.edu/~jburkardt/f_src/qshep2d/qshep2d.html [Broken]

    I'm afraid beyond that, I can't help you much.
    Last edited by a moderator: May 4, 2017
  10. Aug 22, 2010 #9
    Ok. thanks for your help! :smile: I have never had to interpolate about 2 axes before. I have done plenty of regular linear interpolation and thought it was a simple jump to do 2D. I guess I thought wrong, eh? :smile:
    Last edited by a moderator: May 4, 2017
  11. Aug 23, 2010 #10
    For these kind of thermodynamic problems, there can be different formulas for different input variable ranges e.g. PV = mRT is one simple formula. However, heat transfer has different formula for different ranges of the inputs.

    Best possible thing I can think of at the moment is getting sufficient information to construct a plane. Two points A and B have infinite number of planes. If you get one or more points, you make a plane and use the points as estimation. This should work for smooth graphs without discontinuities.
    Last edited: Aug 23, 2010
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook