5
$\begingroup$

If I try to make a table SimpleTable and to interpolate a function of two variables, I encounter a problem.

For example:

SimpleTable = Table[{j, i, 2 i - 3 j}, {j, 0, 5}, {i, -5, 5}];

and interpolation:

f := Interpolation[SimpleTable]

and if I try:

f[1, 2]

I get the error messages:

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

Interpolation::inder: The order-2 derivative of {0,-2,-4} is not a tensor of rank 2 with dimensions 3. >>*)

To me the table SimpleTable seems to have a "rectangular domain". What is wrong here? How to tackle this problem, to get an interpolated function from the table? Does the domain have to be changed?

Although the unstructured grids have already been mentioned here, I was hoping that somebody could make clear how to interpolate a function from 3-D data, without the unstructured grid warning.

$\endgroup$
  • 1
    $\begingroup$ f = ListInterpolation[SimpleTable] ? $\endgroup$ – Sektor Mar 10 '14 at 12:44
  • $\begingroup$ @Sektor. I tried with f = ListInterpolation[SimpleTable] , and after: f[1,2] didn't get the function value, but the error message: ListInterpolation::inhr: "Requested order is too high; order has been reduced to {3,3,2}." $\endgroup$ – david1983 Mar 10 '14 at 12:59
  • $\begingroup$ @david1983 Well, you are trying to pass 2 arguments to a function that accepts 3... That's not gonna work :) Try f[1,2,3] and see what happens SimpleTable//MatrixForm $\endgroup$ – Sektor Mar 10 '14 at 13:03
  • $\begingroup$ I have voted to close and the reasons are bit vague, but I just wanted to say I think the question is fine (don't regret asking it :) ). $\endgroup$ – Jacob Akkerboom Mar 10 '14 at 13:59
9
$\begingroup$

If you check the documentation for Interpolation the correct syntax for multidimensional data is

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

So you will need to modify your code to put the {x, y} coordinates in a list, and Flatten the table:

SimpleTable = Table[{{j, i}, 2 i - 3 j}, {j, 0, 5}, {i, -5, 5}] ~Flatten~ 1;
f = Interpolation[SimpleTable];
f[1, 2]
(* 1 *)

Alternatively you can omit the x,y coordinates entirely and use ListInterpolation:

data = Table[2 i - 3 j, {j, 0, 5}, {i, -5, 5}];    
fun = ListInterpolation[data, {{0, 5}, {-5, 5}}];    
fun[1, 2]

(* ==> 1 *)
$\endgroup$
  • $\begingroup$ +1, I learned something. I will be tougher on myself and try to answer new users questions with only elementary functions/constructions, in order to gain the right to complain about this infix notation, though :P. $\endgroup$ – Jacob Akkerboom Mar 10 '14 at 13:42

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.