Group Abstract Group Abstract

Message Boards Message Boards

0
|
6.8K Views
|
3 Replies
|
1 Total Like
View groups...
Share
Share this post:

Interpolation of function of two variables over very large range

Posted 6 years ago
3 Replies
Posted 6 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

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 6 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