MathGroup Archive 1999

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

Search the Archive

RE: Bug in math4

  • To: mathgroup at smc.vnet.net
  • Subject: [mg20659] RE: [mg20633] Bug in math4
  • From: "Ersek, Ted R" <ErsekTR at navair.navy.mil>
  • Date: Sun, 7 Nov 1999 02:10:00 -0500
  • Sender: owner-wri-mathgroup at wolfram.com

Lennart Bengtsson wrote:
------------------------------
I just want to point out that there seems to be a serious bug
in the new mathematica version 4.0 for Solaris. See the following
example:

In[25]:= NIntegrate[Sqrt[2-Sin[x]],{x,1,4}]

Out[25]= 3.73785   (correct)

In[26]:= N[Integrate[Sqrt[2-Sin[x]],{x,1,4}]]

Out[26]= 3.73785 + 4.00431 I   (incorrect, the integrand is real)

The bug is not observed with version 3 of mathematica.

----------------------------

Consider the following:

In[1]:=
int = Integrate[Sqrt[2 - Sin[x]], {x, 157/100, 158/100}]

Out[1]=
-2*EllipticE[(-79/50 + Pi/2)/2, -2] + 
 2*EllipticE[(-157/100 + Pi/2)/2, -2] + 
 4*EllipticF[I*ArcSinh[1/Sqrt[2]], -2]


In[2]:=
N[int]

Out[2]=
0.01 + 4.00431*I    (*** Wrong answer ***)


In[3]:=
a = Take[int, 2]

Out[3]=
-2*EllipticE[(-79/50 + Pi/2)/2, -2] + 2*EllipticE[(-157/100 + Pi/2)/2, -2]


In[4]:=
N[a]

Out[4]=
0.01


In[5]:=
NIntegrate[Sqrt[2 - Sin[x]], {x, 157/100, 158/100}]

Out[5]=
0.01

Above we get the right answer if we throw away the last term of (int).  I
suspect Mathematica thought it had to throw in the extra term to get around
what it thought was a singularity in the anti-derivative.  

Why does it come out right in Version 3, but not in Version 4 ?  I suspect
Version 4 tries harder to locate singularities between the limits of
integration to avoid wrong answers given with Version 3.  However, it seems
the new method thinks there is a singularity in this problem when there is
none.

--------------------
Regards,
Ted Ersek

For Mathematica tips, tricks see 
http://www.dot.net.au/~elisha/ersek/Tricks.html


  • Prev by Date: Re:Color of GridLines
  • Next by Date: RE: Bug in math4
  • Previous by thread: Problem with Solve[]
  • Next by thread: RE: Bug in math4