MathGroup Archive 2005

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

Search the Archive

Re: ListInterpolation

  • To: mathgroup at smc.vnet.net
  • Subject: [mg58415] Re: ListInterpolation
  • From: Peter Pein <petsie at dordos.net>
  • Date: Sat, 2 Jul 2005 04:06:11 -0400 (EDT)
  • References: <d9r4tv$55q$1@smc.vnet.net> <200506290157.VAA15270@smc.vnet.net> <da0b8t$fiu$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

St=E9phane Fay schrieb:
> Thank you for your answer, but when I try
>
> res = ListInterpolation[
> Transpose[{{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10 , 11 , 12}}],
> {{1, 1.3, 2, 5}, {0, 1.5, 2}}];
>
> I get
>
> res[1, 0.5] = 1.
>
> whereas for me the correct answer would be res[1, 0.5] = 5/3
>
> since {1, 1.3, 2, 5} is the x coordinate of the data table {{1, 2, 3,
> 4}, {5, 6, 7, 8}, {9, 10 , 11 , 12}} and {0, 1.5, 2} the y
> coordinates. Where does I make a mistake?
>
>
> On 6/29/05, Peter Pein <petsie at dordos.net> wrote:
>
>>St=E9phane Fay schrieb:
>>
>>>Dear everyone,
>>>
>>>I have a problem with the ListInterpolation instruction. I would like
>>>to specify some explicit lists of positions for grid lines like this:
>>>
>>>res == ListInterpolation[{{1, 2, 3, 4}, {5, 6, 7, 8}}, {{1, 1.3, 2=
=2E 5,
>>>5}, {0.5, 1.3}}]
>>>
>>>But it does not work: when I try to calculate res[2, 1.1], I get
>>>ListInterpolation[{{1, 2, 3, 4}, {5, 6, 7, 8}}, {{1, 1.3, 2.5, 5},
>>>{0.5, 1.3}}][2, 1.1]
>>>
>>>I thank you in advance for your help.
>>>
>>>Yours sincerely
>>>
>>>    Stephane Fay
>>>    Paris Observatory
>>>    France
>>>
>>
>>Your input is not in proper format (and use "=" for assignments, not =
"=="):
>>
>>In[1]:= res = ListInterpolation[
>> Transpose[{{1, 2, 3, 4}, {5, 6, 7, 8}}],
>> {{1, 1.3, 2.5, 5}, {0.5, 1.3}}];
>>From In[1]:=
>>ListInterpolation::inhr:
>>Requested order is too high; order has been reduced to {3, 1}. More...
>>
>>In[2]:= res[2, 1.1]
>>Out[2]=
>> 6.031081081081081
>>--
>>Peter Pein
>>Berlin
>>
>>
>
>
Dear St=E9phane,
we've got four x-grids and three y-grids. A polynomial interpolation
involves at most x^3 and y^2:

data = Flatten /@ Transpose[(Flatten[#1, 1] & ) /@
     {Outer[List, {1, 1.3, 2, 5}(*x - values*),
                  {0, 1.5, 2}(*y - values*)],
      Transpose[{{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}}]
                (*z - values*)}]
Out[1]=
{{1, 0, 1}, {1, 1.5, 5}, {1, 2, 9},
 {1.3, 0, 2}, {1.3, 1.5, 6}, {1.3, 2, 10},
 {2, 0, 3}, {2, 1.5, 7}, {2, 2, 11},
 {5, 0, 4}, {5, 1.5, 8}, {5, 2, 12}}

In[2]:=
fun[x_, y_] = Evaluate[Rationalize[
  Fit[data, {1, x, y, x^2, y^2, x^3}, {x, y}]]]
Out[2]=
-(3033/518) + (31351*x)/3108 - (3765*x^2)/1036 + (625*x^3)/1554 -
 (4*y)/3 + (8*y^2)/3

In[3]:=
fun[1, 1/2]
Out[3]=
1

If you want to use an non-polynomial model, Fit[] or
Statistics`NonLinearFit[] would be the choice.

--
Peter Pein
Berlin


  • Prev by Date: Re: Can't assign value to symbols
  • Next by Date: Re: Explicit solution to Root[]
  • Previous by thread: Re: ListInterpolation
  • Next by thread: Simple List manipulation question