Re: mathematica gets a simple limit wrong?

*To*: mathgroup at smc.vnet.net*Subject*: [mg24654] Re: [mg24633] mathematica gets a simple limit wrong?*From*: Andrzej Kozlowski <andrzej at tuins.ac.jp>*Date*: Mon, 31 Jul 2000 09:23:23 -0400 (EDT)*Sender*: owner-wri-mathgroup at wolfram.com

on 7/28/00 11:24 PM, danckel at my-deja.com at danckel at my-deja.com wrote: > Could anyone explain the following output of mathematica 4.0: > > In[]:= 1+Limit[a-Sqrt[a^2-a],a->Infinity] > Out[]:= 3/2 > > In[]:=Limit[1+a-Sqrt[a^2-a],a->Infinity] > Out[]:= 1 ????!!!!!!!!!!! > > > Huh? I just moved the 1 inside the brackets and got a wrong answer? > Makes me wonder about mathematica. > > bye, > > D. > > > Sent via Deja.com http://www.deja.com/ > Before you buy. > > This is clearly a bug, (though perhaps an understandable one). However, I feel the first thing that needs to be said is that in this, as in most other cases, Mathematica offers lots of ways to get the right answer. This is indeed its greatest strength. Personally I would never even think of using limit in a case like this (or most other cases) since the following approach is far more reliable: In[1]:= f[x_] := 1 + x - Sqrt[x^2 - x] In[2]:= Normal[f[x] + O[x, Infinity]^2] Out[2]= 3 - 2 There are also two ways to get the right answer by laoding standard packages: In[3]:= << Calculus`Limit` In[4]:= Limit[f[x], x -> Infinity] Out[4]= 3 - 2 or In[5]:= << NumericalMath`NLimit` In[6]:= NLimit[f[x], x -> Infinity] Out[6]= 1.5 Actually, even when all such answers agree I do not think you should rely on an answer given not just by Mathematica but by any symbolic algebra program. They should only be treated as "guesses" whcih should be justified mathematically. But this is another issue. There is also the question of how the bug arises. Of course not having access to the source code one can't be sure but one can make a guess. Starting with a new kernel (to remove the effects of the external packages): In[1]:= f[x_] := 1 + x - Sqrt[x^2 - x];g[x_] := f[1/x]; In[4]:= g[x] Out[4]= -2 1 1 1 - Sqrt[x - -] + - x x In[5]:= Limit[g[x], x -> 0] Out[5]= 1 In[7]:= Together[g[x]] Out[7]= 1 - x 1 + x - Sqrt[-----] x 2 x --------------------- x In[6]:= Limit[Together[g[x]], x -> 0] Out[6]= 3 - 2 It seems that in the second case Mathematica correctly used the l'Hospital rule. It is not clear to me how Mathematica arrives at its (wrong) answer 1 in the first case, though it seems to me not entirely surprising that it "can't see" the, not entirely obvious, need to apply Together before using the l'Hospital rule. -- Andrzej Kozlowski Toyama International University, JAPAN For Mathematica related links and resources try: <http://www.sstreams.com/Mathematica/>