Re: InterpolatingFunction::dmwarn: Warning
- To: mathgroup at smc.vnet.net
- Subject: [mg5509] Re: InterpolatingFunction::dmwarn: Warning
- From: Robert Knapp <rknapp at sover.net>
- Date: Sat, 14 Dec 1996 19:26:08 -0500
- Organization: Wolfram Research
- Sender: owner-wri-mathgroup at wolfram.com
Jonathan Rich wrote: > > Can anyone explain why the following code generates the > above warning? > > secsperyear = 365.25*24*60*60; > Nt=56; > deltat = secsperyear/Nt; > seasonaltime = n deltat; > testtable=Table[{x,x^2},{x,0,secsperyear,secsperyear/100}]; > interpFunc=Interpolation[testtable]; > > seasonaltime1=3.15576*10^7; > > interpFunc[seasonaltime1]; (* no domain warning message *) > n=Nt; > interpFunc[seasonaltime]; (* this DOES produce domain-warning message?! > yet SameQ[seasonaltime,seasonaltime1] is True?! *) > > I am totally mystified! Is this a bug in InterpolatingFunction? > No its not a bug, but it is an interesting example of machine arithmetic uncertainty. First, if you've got two machine numbers, SameQ allows them to differ by one bit before calling them different. (Equal allows 7 bits) For example, on my machine, I get In[1]:= secsperyear = 365.25*24*60*60; Nt=56; deltat = secsperyear/Nt; seasonaltime = n deltat; testtable=Table[{x,x^2},{x,0,secsperyear,secsperyear/100}]; interpFunc=Interpolation[testtable]; seasonaltime1=3.15576*10^7; In[2]:= val1 = interpFunc[seasonaltime1]; In[3]:= n=Nt; val2 = interpFunc[seasonaltime]; In[4]:= SameQ[seasonaltime1, seasonaltime] Out[4]= True In[5]:= seasonaltime1 - seasonaltime Out[5]= -3.72529029846191406`*^-9 So they certainly are not identical! Notice also that on my machine I did not get the warning message. The reason you got the warning message was that the predicate used in InterpolatingFunction is simpler than SameQ (and faster) it just checks if your argument is greater than the endpoint--if it is you are using extrapolation, which is what the messages says. It is only a warning message--this close to the boundary there is likely to be no problem. The function does magnify the difference, though it is still only one bit: In[6]:= SameQ[val1,val2] Out[6]= True In[7]:= val1-val2 Out[7]= -0.25 I hope this helps. Ron Knapp WRI