Re: Inconsistent behaviour of Integrate
- To: mathgroup at smc.vnet.net
- Subject: [mg112485] Re: Inconsistent behaviour of Integrate
- From: Andreas Maier <andimai at web.de>
- Date: Fri, 17 Sep 2010 06:40:44 -0400 (EDT)
- References: <i6q0no$l8i$1@smc.vnet.net>
On Sep 15, 10:39 am, Bill Rowe <readn... at sbcglobal.net> wrote: > On 9/14/10 at 5:12 AM, andi... at web.de (Andreas Maier) wrote: > > >I'm using Mathematica 7.0.1.0 on Linux x86 (64bit). I have a > >notebook file, where I integrate the same integral twice: > >In[1]:= Integrate[Sqrt[(x - 1/2)^2 + (y - 1/2)^2], {x, 0, 1}, {y, 0, > >1}] Out[1]= 1/6 (Sqrt[2] + ArcSinh[1]) > >In[2]:= Integrate[Sqrt[(x - 1/2)^2 + (y - 1/2)^2], {x, 0, 1}, {y, 0, > >1}] Out[2]= 1/24 (4 Sqrt[2] + Log[17 + 12 Sqrt[2]]) > >As you can see from the output, integrating the same integral a > >second time gives a different result. If I integrate the same > >integral a third and a fourth time I always get the second result > >again. Only if I restart the mathematica kernel, I get the first > >result again. The results are equivalent, since > >Log[17 + 12 Sqrt[2]] = Log[(1 + Sqrt[2])^4] = 4* Log[(1 + Sqrt[2]) = = > >4* ArcSinh[1] > >but somehow Mathematica seems to be able to do this simplification > >only once. Is this inconsistent behaviour a bug? > > No. This issue has been discussed here previously. Basically, > default time constraints on Integrate cause it to return an > answer before some transformations have been done. The second > time the same integral is done, Integrate makes use of the > cached results from the first which allows further > transformations to be done within the default time constraints. > > >Is there a possibility to give mathematica a hint, so that he always > >find the first solution 1/6 (Sqrt[2] + ArcSinh[1]) to the integral? > > You can use ClearSystemCache to clear out the cached results > from the previous evaluation. That is > > In[1]:= Integrate[ > Sqrt[(x - 1/2)^2 + (y - 1/2)^2], {x, 0, 1}, {y, 0, 1}] > > Out[1]= (1/6)*(Sqrt[2] + ArcSinh[1]) > > In[2]:= ClearSystemCache[] > > In[3]:= Integrate[ > Sqrt[(x - 1/2)^2 + (y - 1/2)^2], {x, 0, 1}, {y, 0, 1}] > > Out[3]= (1/6)*(Sqrt[2] + ArcSinh[1]) > > But given the time it requires to evaluate the integral, why do > it twice if you get an acceptable answer the first time? Call me conservative, but I expected to get the same result, when I'm doing the same calculation again. So I thought, this could be a bug in Mathematica and I gave the simplest example, where I encountered this "bug". Of course it doesn't make sense to compute this special integral twice, especially since it's value is well known in the literature (see http://mathworld.wolfram.com/SquarePointPickin= g.html). But I wanted to compute a few more complex integrals of this kind (see http://mathworld.wolfram.com/UnitSquareIntegral.html). But since mathematica seems to generate not very consistent results with such a simple box integrals, I'm wondering how useful the results will be for more complex ones. Andreas Maier