Re: interpolating f(x,y) from evaluation

*To*: mathgroup at smc.vnet.net*Subject*: [mg8657] Re: interpolating f(x,y) from evaluation*From*: Paul Abbott <paul at physics.uwa.edu.au>*Date*: Fri, 12 Sep 1997 04:11:09 -0400*Organization*: University of Western Australia*Sender*: owner-wri-mathgroup at wolfram.com

K. Nikolaj Berntsen wrote: > I want to generate an interpolatingfunction-like object for a > complicated function of several variables; Interpolation etc. does not > seem to be able to; but I may have missed something in the > documentation, anyone got an idea? > > I tried: > > Interpolation[Table[{f[i,j].i.j},{i,3},{j,3}]] The argument to interpolation needs to be "flattened" and should be of the form Flatten[Table[{i,j,f[i,j]},{i,3},{j,3}],1] (Note that you had {f[i,j].i.j} instead of {i,j,f[i,j]}). For example, In[1]:= f[i_, j_] := i^2 + j^2 In[2]:= Interpolation[Flatten[Table[{i,j,f[i,j]},{i,5},{j,5}],1]]; In[3]:= Plot3D[%[x, y], {x, 1, 5}, {y, 1, 5}]; Alternatively you can use FunctionInterpolation: In[4]:= FunctionInterpolation[f[i, j], {i, 1, 5}, {j, 1, 5}]; In[5]:= Plot3D[%[x, y], {x, 1, 5}, {y, 1, 5}]; Cheers, Paul ____________________________________________________________________ Paul Abbott Phone: +61-8-9380-2734 Department of Physics Fax: +61-8-9380-1014 The University of Western Australia Nedlands WA 6907 mailto:paul at physics.uwa.edu.au AUSTRALIA http://www.pd.uwa.edu.au/Paul God IS a weakly left-handed dice player ____________________________________________________________________ ~ ~ ~ ~ ~ ~ ~ ~ ~