Message Boards Message Boards

0
|
4919 Views
|
3 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Interpolation of function of two variables over very large range

Posted 5 years ago

Hi everyone,

I have been struggling with the following problem: I have a function of two variables, let me call it f[x,y] and each variables takes values on a very large range (0-10^8 say). I need to build an interpolating function of the original function for computational purposes. In order not to get a huge number of interpolating points, I would like to split the very large interval into smaller intervals and build several Tables of the original function over the different intervals, like this:

t1=Table[{x, y, f[x,y]}, {x,0,10,0.1},{y,0,10,0.1}];
t2=Table[{x, y, f[x,y]}, {x,10,100,1},{y,10,100,1}];
.....
t=Table[{x, y, f[x,y]}, {x,10^7,10^8,10^6},{y,10^7,10^8,10^6}];

I would then try to join these tables and use Interpolation to build an interpolating function:

fint=Interpolation[DeleteDuplicates[Flatten[Join[t1, t2,..], 1]]]

I use DeleteDuplicates to make sure that I do not repeat points.

However, when I do so, I get the following:

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

For my purposes, I need an interpolation order of 3. There seems to be a problem with the merging of the elements in the list, but I cannot solve it with Union[], nor with Sort[].

Would anyone here know how to solve this? Thank you so much! Best. Fabrizio

3 Replies

First I would like to remark that with the ti's you gave above you don't cover the whole (square) region where your function may be defined. The ti's form something like a "diagonal" region.

Second I would really like to know what an "unstructured grid " is.

But perhaps you can get what you want by a modified approach. Let n be the exponent (of 10) of your highest number. Then define for example

n = 3;
elim = Range[0, n]
f[x_, y_] := x^2/5 + Sqrt[y]

and

values[i_, j_] := Module[{a, b, x, y},
a = 10^i;
b = 10^j;
Flatten[
Table[{{x = a (1 + 9 u), y = b (1 + 9 v)}, f[x, y]}, {u, 0, 1, .2}, {v, 0, 1, .2}], 1]
]

For more datapoints you should change the .2 to .1 in the iterators.

Then

intpol = Table[
   Interpolation[values[i, j]],
   {i, 1, Length[elim]}, {j, 1, Length[elim]}];

and

func[x_, y_] := 
intpol[[IntegerPart[Log[10, x]], IntegerPart[Log[10, y]]]][x, y]

will call the appropriate interpolation-function

POSTED BY: Hans Dolhaine
Posted 5 years ago

Since you want the same number of points per decade, perhaps something like this might do:

Notice the extra layer of {} around x and y in the Table, as shown in the documentation for multivariate Interpolation. Notice I also Flatten away the extra layer of {} around each row of points in a multivariate Table.

f[x_,y_]:=x*y;
t=Flatten[Table[{{x, y}, f[10^x,10^y]}, {x,-1.,8.,0.1},{y,-1.,8.,0.1}],1];
fint=Interpolation[t]

The result is an interpolating function over your very large range with the same number of points per decade, as long as I use 10^x and 10^y in the arguments to f.

See if you might be able to adapt something like this to your needs.

POSTED BY: Bill Nelson
Posted 5 years ago

Thank you! This indeed work for these simplest cases, as there is a single table of values with the same spacing. However, I would be still interested in knowing if there is a way to actually interpolate by joining different tables of the same function with different spacings in different intervals, or whether this is really not possible in Mathematica. Thank you again, Best Fabrizio

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

Group Abstract Group Abstract