MathGroup Archive 2007

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

Search the Archive

Re: Interpolation in 2 D, bug?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg83853] Re: Interpolation in 2 D, bug?
  • From: Hugh <h.g.d.goyder at cranfield.ac.uk>
  • Date: Sun, 2 Dec 2007 04:14:36 -0500 (EST)
  • References: <fire9m$roc$1@smc.vnet.net>

On Dec 1, 10:50 am, Hugh <h.g.d.goy... at cranfield.ac.uk> wrote:
> I either need something explaining to me or there is a bug in
> Interpolation.
> I take the data below and make an interpolation function. When I put
> the x, y values back into the function I don't get the values of the
> original data but some transpose of them. Am I doing something wrong
> or is this a bug?
>
> Hugh Goyder
>
> In[1]:= $Version
>
> Out[1]= "6.0 for Microsoft Windows (32-bit) (June 19, 2007)"
>
> In[2]:= data = {
>    {{-1, 0}, 0}, {{-1, -1}, -1}, {{-1, -2}, -2}, {{-1, -3}, -3},
>    {{0, 0}, -2}, {{0, -1}, -3}, {{0, -2}, -4}, {{0, -3}, -5},
>    {{1, 0}, -4}, {{1, -1}, -6}, {{1, -2}, -8}, {{1, -3}, -9}};
>
> In[3]:= f = Interpolation[data, InterpolationOrder -> {2, 3}];
>
> In[4]:= f[-1, 0]
>
> Out[4]= -3
>
> In[5]:= f[-1, -1]
>
> Out[5]= -2
>
> In[6]:= f[-1, -2]
>
> Out[6]= -1
>
> In[7]:= f[-1, -3]
>
> Out[7]= 0
>
> In[8]:= f[0, 0]
>
> Out[8]= -5
>
> In[9]:= f[0, -1]
>
> Out[9]= -4
>
> In[10]:= f[0, -2]
>
> Out[10]= -3
>
> In[11]:= f[0, -3]
>
> Out[11]= -2
>
> In[12]:= f[1, 0]
>
> Out[12]= -9
>
> In[13]:= f[1, -1]
>
> Out[13]= -8
>
> In[14]:= f[1, -2]
>
> Out[14]= -6
>
> In[15]:= f[1, -3]
>
> Out[15]= -4

I think I have worked out my problem. My data are not in strictly
increasing order.
 Below I first order the data and then everything else is fine.
So this is not a bug -but a check by Interpolation would be a "nice to
have".

Hugh Goyder

data={
   {{-1,0},0},{{-1,-1},-1},{{-1,-2},-2},{{-1,-3},-3},
   {{0,0},-2},{{0,-1},-3},{{0,-2},-4},{{0,-3},-5},
   {{1,0},-4},{{1,-1},-6},{{1,-2},-8},{{1,-3},-9}};

data2=data[[Ordering[data,All,Which[#1[[1,1]]<#2[[1,1]],True,#1[[1,1]]==#2[[1,1]]&&#1[[1,2]]<#2[[1,2]],True,True,False]&]]]
{{{-1,-3},-3},{{-1,-2},-2},{{-1,-1},-1},{{-1,0},0},{{0,-3},-5},
{{0,-2},-4},{{0,-1},-3},{{0,0},-2},{{1,-3},-9},{{1,-2},-8},{{1,-1},-6},
{{1,0},-4}}

f=Interpolation[data2,InterpolationOrder ->{2,3}];

f[-1,0]
0

f[-1,-1]
-1

f[-1,-2]
-2

f[-1,-3]
-3

f[0,0]
-2

f[0,-1]
-3

f[0,-2]
-4

f[0,-3]
-5

f[1,0]
-4

f[1,-1]
-6

f[1,-2]
-8

f[1,-3]
-9


  • Prev by Date: Re: Exporting Sound
  • Next by Date: RE: Exporting Sound
  • Previous by thread: Interpolation in 2 D, bug?
  • Next by thread: FindInstance what inspite ?