Re: Can Integrate[expr,{x,a,b}] give an incorrect result?
- To: mathgroup at smc.vnet.net
- Subject: [mg82626] Re: Can Integrate[expr,{x,a,b}] give an incorrect result?
- From: "David W.Cantrell" <DWCantrell at sigmaxi.net>
- Date: Fri, 26 Oct 2007 05:27:33 -0400 (EDT)
- References: <20071024002631.769$08@newsreader.com> <ffn0t3$5vr$1@smc.vnet.net>
Andrzej Kozlowski <akoz at mimuw.edu.pl> wrote: > As I don't see anything concrete to reply to in your post I will just > restate my version of this whole argument and leave it at that. > > I originally replied to Bobby's post in which he seemed to question > the reliability of Simplify or D (or, perhaps, of indefinite > integration). I replied that Mathematica's Simplify and D were > practically 100% reliable and Integrate (by which I have always > meant the function that computes indefinite integrals) was nearly as > reliable except when its heuristics failed or perhaps when it entered > an unimplemented branch of the Risch algorithm. I attributed the > problem the OP was having to the way Mathematica evaluated the > definite integral by applying the Newton-Leibniz rule without > detecting that it should't do so in this case. You may well have made that attribution in your head. But what you _wrote_ made it seem to me as though you thought Mathematica was faultless in this matter, at least in relation to the specific problems at hand, and that Bobby or the OP was instead at fault. I have now re-read your original reply, and it still seems that way to me. That, in large measure, is why I replied to you, rather than to Bobby or the OP. BTW, if I had seen Daniel Lichtblau's reply, I most likely would never have replied to you. Unlike you, he made it clear that Mathematica was at fault. (I overlooked Daniel's post only because its severely curtailed title, "give an", made it seem as though it were not part of this thread.) > I did not comment in any way on why the latter problem occured, > except for remarking that it happened rather often. You did not make that remark in your reply to Bobby; look at what you wrote. OTOH, I made such a remark when replying to you: "This happens fairly often, the subject of this thread being a case in point." > At this point you entered, with a reply to me, whose purpose I still > do not understand. I explained that above. > When I read it it seemed to me that you must be > disagreeing with something I had written. As there was nothing at all > about Simplify or D in your message, I naturally concluded that you > were criticizing the way Mathematica performed indefinite integration > - what I call Integrate. You seem to be suggesting that Integrate > should somehow find a different anti-derivative. I did not say that _per se_, but perhaps it's reasonable that you thought I seemed to suggest such. But your "should" is too strong a word since there are at least two options which would keep Mathematica from making the error in integration from 0 to 2Pi, mentioned by the OP: 1. Leave the result of indefinite integration as it is, but then, since that result is not an antiderivative on the desired interval, improve Mathematica's detection of discontinuities so that it will not apply Newton-Leibniz incorrectly. or 2. Change the result of indefinite integration in problems in which the classic Weierstrass substitution, u = tan(x/2), had been used so that discontinuities introduced as an artifact of that substitution are not present in the result. My preference is option 2. In problems such as that mentioned by the OP, since option 2 gives an antiderivative on R, it allows us to use Newton-Leibniz naively, there being then no discontinuities with which to be concerned. But again, I cannot say that the people at Wolfram Research should choose option 2, instead of option 1. For all I know, they may have an excellent reason for rejecting the option I prefer. > That's why I asked > you for another algorithm - (for indefinite integration of course) > that would return a different anti-derivative than the Risch > algorithm. But now it turns out that you had nothing at all to add to > what I had written, except perhaps the claim, which you did not make > in your first post, that there is a reliable method of detecting > discontinuities in the antiderivative. I didn't say that in my first post because one need not detect discontinuities if you know that there are none to detect! The algorithm performs as I described previously. Thus, for the OP's problem, it returns an antiderivative on R. > But actually, if you re-read > your own post you will see that in it you are (or at least seem to > be) suggesting that a different anti-derivative should have been > found rather than the discontinuities in the one actually used by > Mathematica should have been detected. These are two rather different > claims. Indeed, they are different. The former corresponds to my "option 2" above, the latter to my "option 1". > In any case, even assuming that what you meant was "that Mathematica > should be better at detecting discontinuities in the anti-derivative" Option 1. > I don't see in what way that is different from what I originally > wrote? It differs significantly. You didn't say, or even hint, "that Mathematica should be better at" anything. It seemed -- and still seems -- to me that you were blaming Bobby or perhaps the OP, rather than Mathematica. As I said previously, that is why I responded to you, rather than to someone else. ------------------------------------------- The following examples and comments will likely be of interest to anyone following this thread. (It should also answer a few questions raised in some private emails.) The classic Weierstrass substitution is u = tan(x/2). Its use typically introduces spurious discontinuities in the result of an indefinite integration. Consider In[4]:= Integrate[1/(2 - Cos[alpha - x]), x] Out[4]= -((2*ArcTan[Sqrt[3]*Tan[(alpha - x)/2]])/Sqrt[3]) Although the function to be integrated is continuous on R, the result of Integrate has discontinuities on R, due to the presence of Tan[(alpha - x)/2], surely caused by a Weierstrass substitution. BTW, someone had questioned my assertion that Mathematica and other CASs use Weierstrass substitution. That's certainly a reasonable question because I have no way of proving that they use it. I based my assertion on (1) what I had read in the literature and (2) the form of answers, such as Out[4] above, which clearly seem to be the results of Weierstrass substitutions. In a court of law, (1) might be called mere "hearsay" and (2) might be called "circumstantial evidence". In any event, until someone from Wolfram Research assures me that Weierstrass substitution is not used, I shall assume that it is used. Now consider the definite integration In[5]:= defint = Integrate[1/(2 - Cos[alpha - x]), {x, 0, 2*Pi}]; defint /. alpha -> 20 Out[5]= 0 That is incorrect, presumably due to an improper use of Newton-Leibniz. Not surprisingly, if we set alpha to 20 in the integration, we do get the correct answer: In[6]:= Integrate[1/(2 - Cos[20 - x]), {x, 0, 2*Pi}] Out[6]= 2*Pi/Sqrt[3] The algorithm which I had mentioned takes a result such as Out[4], having spurious jump discontinuities on R caused by the Weierstrass substitution, and produces an antiderivative without those jumps. For 1/(2 - Cos[alpha - x]), such an antiderivative on R is # (x - 2 ArcTan[Sin[alpha - x]/(2 + Sqrt[3] - Cos[alpha - x])])/Sqrt[3] Note that # is a little messier than Out[4]; perhaps that's why Wolfram Research prefers Out[4], despite its discontinuities on R. OTOH, for a definite integration on the real line, it is impossible to misuse Newton-Leibniz with #, and so no error such as Out[5] could occur. David W. Cantrell