Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

Re: question about Integrate

  • To: mathgroup at smc.vnet.net
  • Subject: [mg49269] Re: [mg49241] question about Integrate
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Sat, 10 Jul 2004 02:48:39 -0400 (EDT)
  • References: <200407090626.CAA20492@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

On 9 Jul 2004, at 15:26, Florian Jaccard wrote:

> *This message was transferred with a trial version of CommuniGate(tm) 
> Pro*
> Dear specialists,
>
> I asked my students to compute the area of the following closed curve :
>
> x[t_] := Sin[t]; y[t_] := E^Cos[t];
>
> ParametricPlot[{x[t], y[t]},
>    {t, 0, 2*Pi}];
>
> I expected the following input :
>
> 2*NIntegrate[x[t]* Derivative[1][y][t],{t, Pi, 0}]
>
> which gives the following output :
>
> 3.5509993784243483
>
> (They also could have done it like this :
> 2*NIntegrate[y[t]*Derivative[1][x][t],{t, 0, Pi}]
> and it gives the same output)
>
> As the help browser says  "N[Integrate[ . ]] calls NIntegrate for 
> integrals
> that cannot be done symbolically" , I never told my students to avoid 
> that
> way :
>
> 2*N[Integrate[x[t]*Derivative[1][y][t],{t, Pi, 0}]]
>
> But, surprise, it gives an other answer :
>
> 2.1262
>
> Checking carefully, I could see that NIntegrate did it fine, but
> N[Integrate...] is wrong. It seems that the special functions BesselI 
> and
> StruveL (used by Mathematica if you type Integrate[...]) are making the
> mistake...
>
>
> Now, what should I tell my students ? To never believe Integrate if not
> checked with NIntegrate ?
> Must I recognize that there is a bug in Integrate, or what did I 
> understand
> wrong ?
>
> Thanks for your help !
>
> Florian  JACCARD 	
>
>
>

It seems you have just encountered the same bug in Integrate in 
Mathematica 5.0 that two other person pointed out in recent postings. 
In Matheamtica 4.2 the answer given by Integrate is correct.

What should you tell your students? Well, a bug is a bug, and they 
should already know that computer programs have bugs and that this is 
not likely to change anytime soon. Also, I think it is worth telling 
them that NIntegrate is more reliable than Integrate and explaining 
why. It is very instructive to understand why there are so many 
problems with Integrate and not  with NIntegrate - the reason is not 
that Integrate has been programmed by less careful programmers. Finally 
there is the question, of how it is possible that bugs that were not 
present in version 4 now appear in version 5. Many people seem to find 
this hard to accept, but it is indeed an unfortunate side effect of 
many improvements which have been made in Integrate in version 5.  It 
is instructive to understand how this can come about. You can try to do 
it yourself: unprotected Integrate and try to re-define it to avoid the 
above error for the largest class of integrals of this kind you can 
think of. It is very easy to do this using Mathematica's pattern 
matching but there is a high chance that you will not notice that 
something matches your pattern that shouldn't and suddenly you have 
fixed one bug but created another. Then there is another way in which 
improvements can make things (temporarily) worse. I don't know how many 
people still remember that before Mathematica 5, this group used to 
receive many postings complaining that Integrate could not manage some 
particular not very hard integral. Someone would then point out that if 
you applied Simplify or FullSimplify to the integrand first, Integrate 
would then be able to give an answer. I think, there have been no such 
messages since version 5. Obviously Integrate is now making much better 
use of Simplify or FullSimplify. But, probably, that also means that 
any bugs in these functions are being passed on to Integrate, which was 
not the case in version 4. In fact I am only speculating that this 
might be happening, but I think it illustrates quite convincingly how 
making things better in general can make them worse in some particular 
cases.

Andrzej Kozlowski
Chiba, Japan
http://www.mimuw.edu.pl/~akoz/


  • Prev by Date: Hypergeometric and MeijerG
  • Next by Date: neuroscience
  • Previous by thread: question about Integrate
  • Next by thread: Re: question about Integrate