MathGroup Archive 1997

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: interpolating f(x,y) from evaluation

  • To: mathgroup at smc.vnet.net
  • Subject: [mg8652] Re: [mg8599] interpolating f(x,y) from evaluation
  • From: Allan Hayes <hay at haystack.demon.co.uk>
  • Date: Fri, 12 Sep 1997 04:11:05 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

"K. Nikolaj Berntsen" <knb at _nospam_bkm.dtu.dk>
[mg8599] interpolating f(x,y) from evaluation

writes

> I want to generate an interpolatingfunction-like object for a
> complicated function of several variables ....
> I tried:
>
> Interpolation[Table[{f[i,j].i.j},{i,3},{j,3}]]
>
> but it did not work.

Nikolaj:

I may not be understanding your quastion but

1. the dots in f[i,j].i.j seem odd.

2. assuming that you want to interpolate data giving values f[i,j]
at i,j with i and j ranging over 1 to 3 then you need to supply the
data in the form
        {{1,1,f[1,1]},{1,2,f[1,2]}, ..}
(the order of main list is unimportant, {{1,2,f[1,2]},{1,1,f[1,1]},
        {{1,1,f[1,1]},{1,2,f[1,2]}, ..}
(the order of main list is unimportant, {{1,2,f[1,2]},{1,1,f[1,1]},
..} will do  just as well)


However with Table  get

In[1]:= Table[{i,j,f[i,j]},{i,3},{j,3}]

Out[1]=
{{{1,1,f[1,1]},{1,2,f[1,2]},{1,3,f[1,3]}},{{2,1,f[2,1]},{2,2,f[2,2]},
{2,3,f[2,3]}},{{3,1,f[3,1]},{3,2,f[3,2]},{3,3,f[3,3]}}}

which is not of form expected. We need to remove some of the brackets.

In[2]:= data = Flatten[%,1]  (* the 1 stops the flattening at level 1*)

Out[2]=
{{1,1,f[1,1]},{1,2,f[1,2]},{1,3,f[1,3]},{2,1,f[2,1]},{2,2,f[2,2]},{2,3,f[2,3]},{3,1,f[3,1]},{3,2,f[3,2]},{3,3,f[3,3]}}

Now define f.

In[3]:= f[i_,j_]:= i-j

The values of f are now numeric.

In[4]:= data

Out[4]=
{{1,1,0},{1,2,-1},{1,3,-2},{2,1,1},{2,2,0},{2,3,-1},{3,1,2},{3,2,1},
{3,3,0}}

Do the interpolation

In[5]:= intf = Interpolation[data]
Interpolation::"inhr":
    "Requested order is too high; order has been reduced to {2,2}."

Out[5]=
InterpolatingFunction[{{1,3},{1,3}},"<>"]

The message simply says that with only 3 data points each way, it
cannot do an order {3,3} interpolation (the default), and has
instead done an order {2,2} one (you can set this order via the
option InterpolationOrder).

The intf works as expected

You can find information online via the help browser: menu Help/Help


Allan Hayes
hay at haystack.demon.co.uk
http://www.haystack.demon.co.uk/training.html
voice:+44 (0)116 2714198
fax: +44 (0)116 2718642
Leicester,  UK


  • Prev by Date: Re: Re: programing: reduce list to cycle
  • Next by Date: "mesh" question
  • Previous by thread: Re: interpolating f(x,y) from evaluation
  • Next by thread: Re: interpolating f(x,y) from evaluation