Message Boards Message Boards

4 Replies
0 Total Likes
View groups...
Share this post:

ListInterpolation help?

Posted 9 years ago

I have a list of input pairs {xa,ya} and a list of output pairs {x,y}. For example:

p = {
  {{1, 1}, {1, 1}},
  {{1, 2}, {1, 4}},
  {{2, 1}, {4, 1}},
  {{2, 2}, {4, 4}},
  {{1, 3}, {1, 9}},
  {{2, 3}, {4, 9}},
  {{3, 1}, {9, 1}},
  {{3, 2}, {9, 4}},
  {{3, 3}, {9, 9}}

which, for a given {xa,ya} gives {xa^2,ya^2}.

f = Interpolation[p]

works fine, f[2.5,2.5]={6.25,6.25}, but if I add RandomReal[.1, {9, 2, 2}] to p:

pp=p+RandomReal[ 0.1 ,  {9, 2, 2} ]

it becomes an unstructured grid, and Interpolation won't work.

I think ListInterpolation[ ] using pp will give me what I want, but I have no idea how to construct an interpolation function f from ListInterpolation such that

f[xa,ya] will give me roughly {xa^2,ya^2}.

Does anyone know how to do this?

POSTED BY: Paul Reiser
4 Replies

Try interpolating separately for each output component.

In[4]:= if1 = Interpolation[Transpose[{pp[[All, 1]], pp[[All, 2, 1]]}], InterpolationOrder -> 1];
        if2 = Interpolation[Transpose[{pp[[All, 1]], pp[[All, 2, 2]]}],  InterpolationOrder -> 1];
        if[x_, y_] := {if1[x, y], if2[x, y]}
        if[2.5, 2.5]

Out[7]= {6.19335, 6.35006}
POSTED BY: Ilian Gachevski
Posted 9 years ago

Hmm - that's not doing it. If I use p (no random added), the above gives {6.5,6.5}, not the {6.25,6.25) that I need, because it's using InterpolationOrder->1, but if I remove the InterpolationOrder->1, it gives me the unstructured grid problem again, and forces the interpolation order to 1.

POSTED BY: Paul Reiser

Higher order is not currently implemented for unstructured grids: while one can create a quadratic mesh from the given point data, to compute an interpolating function the midpoint function values would be needed. There is more discussion and an example at

POSTED BY: Ilian Gachevski
Posted 9 years ago

Hi Ilian - The real problem I have is somewhat less complicated. I have an unstructured {xa,ya} and I want to calculate the corresponding {x,y} which is structured; it has equal increments in x and y. That means I can use Interpolation[ ] to interpolate from {x,y} to {xa,ya}, but not from {xa,ya} to {x,y}, which is what I want.

What I guess I will have to do is use the F[{x,y}]={xa,ya} interpolation, and then use FindMinimum[ ] to find the {x,y} that minimizes [ F[{x,y}] - {xa,ya} ]^2

Does that sound like the best way to do it?

POSTED BY: Paul Reiser
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract