Group Abstract Group Abstract

Message Boards Message Boards

Interpolation for multi-dimensional functions

Posted 11 years ago

Dear fellow forum members,

Who can help me with the following problem?

I have a list that looks as follows: { {f1,x1,y1}, {f2,x2,y2}, ...}. I wish to express f as a function of x and y by use of Mathematica's ListInterpolation. The documentation for ListInterpolation tells me that I must use the following syntax: ListInterpolation[list,{{x1,x2,...},{y1,y2,....}}]. In other words: it looks as if my data points must be defined on all the intersection points of a grid of perpendicular lines in the (x,y)-plane. In the data set I am working with, this is not the case (i.e. the (x,y) in my data set don't form a rectangular grid.)
I cannot imagine that Mathematica is so restrictive. There must be a good workaround for this.

Does anybody have a good idea?

Thanks in advance,

René Samson

POSTED BY: Rene Samson
10 Replies
Posted 10 years ago

Hi Frank,

I am pretty convinced now that the problem I had was not one of (near) duplicates but one of ordering. After I saw that a Union[] operation of the basic data solved the problem, I subsequently repeated the calculation, using Sort[] instead of Union[] on my basic data and this - likewise - resulted in success. So, my original basic data set apparently was so disordered that it made Interpolation[] impossible. Sorting resolved this problem. At least, that's how I interpreted my experiences. Thanks again for your help.

René

POSTED BY: Rene Samson

Hello Rene,

I'm very happy you had success! However, I'm very puzzled as to why my suggestion worked at all, if it did not identify (near) duplicate samples. Oh well, onward! :-)

POSTED BY: Frank Iannarilli
Posted 10 years ago

Hi Sander, Thanks for pointing me in the right direction for help and documentation. Thanks, René

POSTED BY: Rene Samson

At the bottom of (nearly) each page you have a 'see also' section, which also shows Interpolation in this case. Also at the very the top, on the right, you have a button Tutorials which shows: tutorial/ApproximateFunctionsAndInterpolation Which explains at length how interpolation can be done in Mathematica.

POSTED BY: Sander Huisman
Posted 10 years ago

Hi Frank,

I've just tested your proposal on my dataset and your suggestion to apply Union[] did the trick. It actually didn't compress my data set, so apparently the problem was not a result of duplicates but of disorder. I had actually tried to fiddle around with this on my own, without realizing that Union[] also orders multi-dimensional sets. Now the Interpolation[] function works without any hickups. WONDERFUL!! I am really thankful to you for pointing this out to me. You saved my day!! Thanks again. (Suggestion to the professional Wolfram crowd: Wouldn't it be nice to give this as an example in the help documentation for Interpolation? I am probably not going to be the first or the last person to run into this difficulty with multi-dimensional functions). René Samson

POSTED BY: Rene Samson
POSTED BY: Frank Iannarilli
Posted 11 years ago
POSTED BY: Rene Samson
Posted 11 years ago
POSTED BY: David Keith
Posted 11 years ago

Hi David,

This solves my problem indeed. You saved my day. Thanks a heap.

Two remarks, if I may: 1. I saw that both the list format {x1,x2, . . . y} as well as {{x1,x2, . . }, y} work in this case. (The Mathematica documentation recommends the latter format). 2. I would find it user-friendly if the Mathematica documentation for ListInterpolation would give am explicit referral to Interpolation for the case of non-grid lists. That would save other users a lot of heart ache.

Thanks so much for your advice, René

POSTED BY: Rene Samson
Posted 11 years ago

Hi Rene,

You want Interpolation rather than ListInterpolation. And notice that the argument is a list of {x1,x2, . . . y}.

d = RandomReal[{0, 10}, {1000, 3}];

f = Interpolation[d];

Interpolation::udeg: Interpolation on unstructured grids is currently only supported for InterpolationOrder->1 or InterpolationOrder->All. Order will be reduced to 1. >>

Plot3D[f[x, y], {x, 0, 10}, {y, 0, 10}]

InterpolatingFunction::dmval: Input value {0.000715,0.000715} lies outside the range of data in the interpolating function. Extrapolation will be used. >>

enter image description here

POSTED BY: David Keith
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard