2
$\begingroup$

I am attempting to do a second or third order interpolation on a grid of 2D data with 1D output; i.e. a scalar function on the complex plane. However, when attempting to do:

Interpolation[...,InterpolationOrder-> 2]

Mathematica gives the error: "Interpolation on unstructured grids is currently only supported for InterpolationOrder->1 or InterpolationOrder->All. Order will be reduced to 1."

There are multiple posts referencing this issue, one of which details that the documentation for the "Interpolation" function specifies a multi-dimensional data input of the form

Interpolate[{{{x1,y1},f1},{{x2,y2},f2},...}]

(see Simon Wood's answer at Interpolation: Unstructured grid error). But my data is structured exactly in this fashion. My code is as follows:

    InterpolateK = {};
    Do[AppendTo[
       InterpolateK, {{xlist[[iz]], ylist[[iz]]}, Klist[[iz]]}], {iz, 
       Length[xlist]}];
    intK = Interpolation[InterpolateK, InterpolationOrder -> 2];

so the list "InterpolateK" has the form:

{{{-4,4},-2.16645},{{-3,4},-2.21115},{{-2,4},-2.25149}, 
{{-1,4},-2.28097},{{0,4},-2.29233},...{{1,-4},-2.28205}, 
{{2,-4},-2.25337},{{3,-4},-2.21349},{{4,-4},-2.16896}}

Another recommendation was to use "ListInterpolation", which unfortunately won't work because though regular, the grid of (x,y) values has some specific values omitted for convergence issues (x=y=0, x^2+y^2 = 1).

The reason for desiring a higher-order interpolation is to be able to take numerical derivatives up to second order of the interpolated function. With a linear interpolation, getting a second order derivative is impossible.

My questions are the following:

  1. What makes the list InterpolateK "unstructured"? It is in the format the documentation asks for and is as naturally ordered as it could be, save the omission of some points.
  2. How could the data be restructured to obtain a higher-order interpolation, or how could ListInterpolation be used on this data?

The hard part is that the function values come from a computationally intensive process and cannot be generated with a Table[...] as is used in some other examples. The raw data comes in the form of a set of (x,y) values with associated function values but no guarantee that they form a perfect grid.

EDIT:Below is a complete version of InterpolateK, as requested in comments:

{{{-4,4},-2.16645},{{-3,4},-2.21115},{{-2,4},-2.25149},{{-1,4},-2.28097},{{0,4},-2.29233},{{1,4},-2.28205},{{2,4},-2.25337},{{3,4},-2.21349},{{4,4},-2.16896},{{-4,3},-2.2108},{{-3,3},-2.26983},{{-2,3},-2.32803},{{-1,3},-2.37495},{{0,3},-2.39431},{{1,3},-2.37661},{{2,3},-2.33074},{{3,3},-2.27293},{{4,3},-2.21393},{{-4,2},-2.25066},{{-3,2},-2.32745},{{-2,2},-2.41318},{{-1,2},-2.49558},{{0,2},-2.53541},{{1,2},-2.49846},{{2,2},-2.41723},{{3,2},-2.33155},{{4,2},-2.25446},{{-4,1},-2.27953},{{-3,1},-2.3735},{{-2,1},-2.49439},{{-1,1},-2.65089},{{1,1},-2.65649},{{2,1},-2.50034},{{3,1},-2.37863},{{4,1},-2.28391},{{-4,0},-2.29026},{{-3,0},-2.39189},{{-2,0},-2.5325},{{2,0},-2.53969},{{3,0},-2.39751},{{4,0},-2.29488},{{-4,-1},-2.27953},{{-3,-1},-2.3735},{{-2,-1},-2.49439},{{-1,-1},-2.65089},{{1,-1},-2.65649},{{2,-1},-2.50034},{{3,-1},-2.37863},{{4,-1},-2.28391},{{-4,-2},-2.25066},{{-3,-2},-2.32745},{{-2,-2},-2.41318},{{-1,-2},-2.49558},{{0,-2},-2.53541},{{1,-2},-2.49846},{{2,-2},-2.41723},{{3,-2},-2.33155},{{4,-2},-2.25446},{{-4,-3},-2.2108},{{-3,-3},-2.26983},{{-2,-3},-2.32803},{{-1,-3},-2.37495},{{0,-3},-2.39431},{{1,-3},-2.37661},{{2,-3},-2.33074},{{3,-3},-2.27293},{{4,-3},-2.21393},{{-4,-4},-2.16645},{{-3,-4},-2.21115},{{-2,-4},-2.25149},{{-1,-4},-2.28097},{{0,-4},-2.29233},{{1,-4},-2.28205},{{2,-4},-2.25337},{{3,-4},-2.21349},{{4,-4},-2.16896}}
$\endgroup$
  • $\begingroup$ Unstructured does not refer to the input format, but to the structure of the underlying mesh on which the available function values have been calculated. Can you share a full set of values for InterpolateK? You can add them to the question or share them on e.g. pastebin or some such. Also, take a look at the possible workaround presented in the documentation page for the error you are getting: reference.wolfram.com/language/ref/message/Interpolation/… $\endgroup$ – MarcoB Jul 3 '18 at 19:04
  • $\begingroup$ Added the full list to the question. Sounds like the omission of values is the irregularity referenced by the error message? I guess a possible workaround would be to compute an average and re-include the omitted points. $\endgroup$ – George Hulsey Jul 3 '18 at 20:19
  • $\begingroup$ Yes, that would work. I gave an example below. $\endgroup$ – MarcoB Jul 3 '18 at 20:40
0
$\begingroup$

You have missing points in your $(x,y)$ grid. With your complete definition of InterpolateK:

InterpolateK[[All, 1]] // ListPlot

Mathematica graphics

As you can see, and as you mentioned, the points {{-1, 0}, {0, 0}, {0, 1}, {0, -1}, {1, 0}} are missing in the grid, which makes it "unstructured". If you can add them back, either using limits or estimations, then you will get a second-order interpolation.

For instance, I arbitrarily set the value of the function at the missing values to $-2$:

full = 
 Join[
  InterpolateK, 
  {{{-1, 0}, -2}, {{0, 0}, -2}, {{0, 1}, -2}, {{0, -1}, -2}, {{1, 0}, -2}}
 ];

Interpolation[full, InterpolationOrder -> 2]

Mathematica graphics

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.