Re: Can Integrate[expr,{x,a,b}] give an incorrect result?

*To*: mathgroup at smc.vnet.net*Subject*: [mg82500] Re: Can Integrate[expr,{x,a,b}] give an incorrect result?*From*: Andrzej Kozlowski <akoz at mimuw.edu.pl>*Date*: Mon, 22 Oct 2007 05:42:47 -0400 (EDT)*References*: <20071020224211.967$wA@newsreader.com>

This is clearly a case of a misunderstanding, though I am not sure that I am at fault here. Note that I never try to reply to Craig's original posting and have not even read it carefully. I am simply not interested enough in the subject of definite integration and to tell the truth I can see little point in all the great effort that is being put into definite integration with symbolic limits (I do see a point to definite integration with numerical limits). Personally I would be quite happy if Mathematica returned all definite integrals with symbolic limits unevaluated. So, I only responded to Bobby's assertion that there was something wrong with Simplify or D. I then changed D to Integrate in my response, but even then I only asserted that Integrate is reliable in producing anti-derivatives in the algebraic sense (That is, functions g possibly with branch cuts etc in the complex plane such that D[g]=f for a given f). What I found provocative in your response is that you chose to respond to me rather than to Craig (or Daniel) although nothing in your response is related to any of the assertions that I made in mine. As for the algorithm that is implemented in "another CAS", you do not make it clear what exactly it does. If you mean that it can deal with this particular case and with a few similar ones I do not doubt that it can. If, however, you are asserting that it can always find a continuous integrand on an interval whenever it can be proved that it exists than I simply don't believe you. That's all that I wrote or at least meant. Andrzej Kozlowski On 21 Oct 2007, at 11:42, David W. Cantrell wrote: > [Message also posted to: comp.soft-sys.math.mathematica] > > Andrzej Kozlowski <akoz at mimuw.edu.pl> wrote: >> On 13 Oct 2007, at 09:32, David W. Cantrell wrote: >> >>> Andrzej Kozlowski <akoz at mimuw.edu.pl> wrote: >>>>> So, from that, D and/or Simplify must be wrong. >>>> >>>> Must they? Even without any investigation I would say that it is >>>> much more likely that this integral should not be evaluated by >>>> means of the Leibniz rule (substituting the limits into the >>>> anti-derivative and subtracting). >>> >>> Of course, the Leibniz rule cannot be used unless one _has_ an >>> antiderivative valid on the required interval. Mathematica does not >>> supply such an antiderivative in this case. >> >> This has been discussed many time before on this list (with your >> participation) but since you seem not to be satisfied, here it goes >> again, I hope for the last time. > > Unless I've said something false, in which case I would much > appreciate being corrected, it's not clear to me why you took the > trouble to respond this time. > > [snip] >> However >> if the original function is not complex analytic in the complex >> plane then there will not be a complex analytic anti-derivative. >> Instead, there will be "anti-derivatives" with singularities, and >> in unlucky cases they may fall on the interval of integration. This >> is exactly what happens in this case. > > Of course. > >>>> In fact, it is easy to see what happens in your >>>> special case: >>>> >>>> integrand = (r*(r - rho*Cos[alpha - t]))/ >>>> (3*(r^2 - 2*rho*Cos[alpha - t]*r + rho^2 + >>>> (z - zeta)^2)^3); >>>> int = integrand /. {r -> 1, rho -> 11/10, >>>> zeta -> 0, alpha -> 0, z -> 12/10} >>>> (1 - (11*Cos[t])/10)/(3*(73/20 - (11*Cos[t])/5)^3) >>>> >>>> First, let us compute the integral using Integrate: >>>> >>>> Integrate[int, {t, 0, 2*Pi}] >>>> (1772800*Pi)/(11512449*Sqrt[377]) >>>> >>>> N[%] >>>> 0.0249156 >>>> >>>> Now, let's do it by numerical integration: >>>> >>>> NIntegrate[int, {t, 0, 2*Pi}] >>>> 0.024915592618816908 >>>> >>>> so far, so good. Now let's compute the indefinte integral: >>>> >>>> indef = Integrate[int, t]; >>>> >>>> Using the Liebniz rule gives clearly the wrong answer: >>>> >>>> indef = Integrate[int, t]; >>>> >>>> but why should it give the right answer? >>> >>> It _must_ give the right answer if indef is actually an >>> antiderivative on the interval 0 to 2Pi, but it isn't. >> >> It depends on the meaning of "anti-derivative". > > The meaning of "antiderivative" in mathematics was well established > prior to the advent of symbolic algebra programs; their advent has not > changed that meaning. No mathematician I know would claim that indef > is an antiderivative on the interval 0 to 2Pi. > >> In the meaning that Mathematica and all other symbolic algebra >> programs use, a function can be an an anti-derivative of another >> function, even if it is singular or undefined at certain points in >> the complex plane provided it is an anti-derivative at almost all >> points (i.e. a generic anti-derivative). It is of course completely >> natural for Mathematica to use such anti-derivatives since it is >> precisely this kind of anti-derivatives that are found by the Risch >> algorithm. >> >>> >>>> The function indef is clearly discontinuous in the interval 0 to >>>> 2Pi >>> >>> True, but that discontinuity is merely an artifact of Mathematica's >>> workings. The integrand int is clearly continuous on the interval 0 >>> to 2Pi and, indeed, on all of R, and so there is an antiderivative >>> on R: >>> >>> 886400 Sqrt[377]/4340193273 (t - 2 ArcTan[44 Sin[t]/(44 Cos[t] - 3 >>> Sqrt[377] - 73)]) + 8800 Sin[t] (1078 Cos[t] - 8009)/(3837483 (44 >>> Cos[t] - 73)^2)) >>> >>> but I don't know how to get Mathematica to produce it. Of course, >>> using my antiderivative above with Leibniz rule, we get the correct >>> result for the definite integral. >>> >>>> Plot[indef, {t, 0, 2 Pi}] >>>> >>>> so the Leibniz rule does not apply. There is no reason at all to >>>> suspect the very reliable function Simplify and almost as reliabel >>>> Interate. >>> >>> There is very good reason to suspect that Integrate, when asked to >>> evaluate an indefinite integral, might give a result which is not >>> an antiderivative on some desired interval. This happens fairly >>> often, the subject of this thread being a case in point. >> >> Mathematica does not even attempt to find anti-derivatives on R in >> your sense. Instead of bringing up time and again same points that >> are covered in undergraduate calculus course I suggest learning a >> little about symbolic algebraic integration. > > Thanks, but I already know "a little" about it. > >> Here are two good references: >> >> Geddes, Czapor, Labhan "Algorithms for Computer Algebra", Kluwer, >> 1992 >> Davenport J. "On the Integration of Algebraic Functions", Springer- >> Verlag 1981. >> >> If you read one of these you will find that the concept of "anti- >> derivative" that your are using is not considered suitable for >> computer algebra (at least at its present stage of development >> unless there have been some dramatic developments recently that I am >> not aware of ). > > I'm using the concept of antiderivative as it is ordinarily used in > mathematics. > >> So, "you do not know how to obtain your answer with Mathematica" >> because it can't be done. > > Of course, it _could_ be done with Mathematica. I apologize. I > should have > said, more precisely, that I don't know how to get Mathematica to > produce > my antiderivative _easily_. (I would not call having to implement the > appropriate algorithm in Mathematica myself to be an easy way.) > >> Symbolic algebra programs use known algebraic algorithms. There is >> no point demanding that they should do something unless a suitable >> general algorithm is known. >> Of course, it is possible that you know an algorithmic (in the same >> sense that the Risch algorithm is "algorithmic") way of computing >> such anti-derivatives. If so, I am sure that Wolfram Research will >> be very keen to implement it. > > I wouldn't be so sure. A suitable algorithm has been known for > years, and > it is implemented quite successfully in another CAS, the name of > which I > would mention, were we not forbidden to do so in this newgroup. > >> But until then this is all there is to this entire issue. > > "then" was some years ago. > > ----------------------------------------------------- > > Then, in his most recent response, > Andrzej Kozlowski <akoz at mimuw.edu.pl> wrote: >> I still feel sufficiently provoked by your post to write one more >> reply, > > The only reason I can imagine that you would have been "provoked" by > my previous post is that you failed to understand something I had > said. I certainly had not intended to be provocative. > >> not to change what I wrote earlier in any fundamental way but >> just to make absolutely clear what the point of my first reply (to >> Bobby Treat) was, since it it appears to me that you have entirely >> missed it. > > No. Rather, I entirely understood it. > > [snip] > >> So in view of the above I can't make any sense of you claim that >> Integrate should be doubted or is not reliable > > Look at what I wrote. I did not make such a claim! I did, however, say > "There is very good reason to suspect that Integrate, when asked to > evaluate an indefinite integral, might give a result which is not an > antiderivative on some desired interval. This happens fairly often, > the > subject of this thread being a case in point." > Perhaps you overlooked the crucial phrase "on some desired interval." > >> unless what you >> actually meant was that using the anti-derivative returned by >> Integrate and the Newton-Leibniz formula is not reliable. This, >> however, is just a truism and in fact exactly what I wrote in my >> post. Anyway, this whole belongs to the realm of definite and not >> indefinite integration. Daniel Lichtblau has already posteda reply >> to Bobby the same thread (have you looked at it?) > > Not until you mentioned it. Several of the posts had had their title > changed to "give an incorrect result?" I had realized that and so had > already looked at them. But somehow, the title of Daniel's post got > further changed, to just "give an", causing me to be unaware that he > had responded. So thanks for mentioning his post. > >> where he included a link >> to a paper of his which explains in detail the difficulties faced by >> definite integration in this kind of setting. > > I see no link to, or even mention of, a paper in the post by Daniel in > this thread. Am I perhaps overlooking a second post by him here? > >> Definite integration still makes use of the Risch algorithm (and >> hence of >> derivatives with possible singular points) but it does not simple >> mindedly use the Newton-Leibniz formula. In fact, with numerical >> limits >> it correctly deals with the integral posted by the OP. > > No, it doesn't. Craig, the OP, said that > "Integrate[integrand,{t,0,2Pi},Assumptions->assumptions] returns 0" > and Bobby later confirmed that. > That's a definite integral with numerical limits and Mathematica > obviously does not deal with it correctly. The second result I posted > evaluated that definite integral. > > (Craig also mentioned use of NIntegrate. That was dealt with > correctly, > but of course NIntegrate is not what we're discussing here.) > >> Of course if it could use a purely real formula like >> yours in the case when definite integrals over an interval are >> involved, things would become much simpler i9n this particualr case, > > Right, much simpler. Indeed, the main reason that I posted in this > thread > originally is that I thought Craig might find my results to be useful, > despite the fact that I couldn't tell him how to get either of them > with > Mathematica, easily, at that time. But I now have an easy way to > obtain my > second result using Mathematica; see below. > >> but this approach does not appear to be algorithmic enough to >> incorporate it into a general integration procedure. > > Opinions may vary as to what is or is not algorithmic enough. Since > the approach has already been successfully implemented in another CAS, > I should think that it is algorithmic enough. > > ----------------------------------------------------- > > Concerning evaluation of the OP's definite integral in Mathematica, > version 5.2: > > The integrand was originally given as > (r*(r - rho*Cos[alpha - t]))/(3*(r^2 + rho^2 + (z - zeta)^2 - > 2*r*rho*Cos[alpha - t])^3) > > I helped Mathematica by making two trivial replacements: > > 1. (z - zeta)^2 by zz > and > 2. alpha - t by t (which is justified since the definite integral > is taken over exactly one cycle). > > Then Mathematica has no trouble getting an answer equivalent to the > second result from my previous post. > > In[8]:= > Assuming[r > 0 && rho > 0 && zz > 0, > Integrate[(r*(r - rho*Cos[t]))/ (3*(r^2 - 2*r*rho*Cos[t] + > rho^2 + zz)^3), {t, 0, 2 Pi}]] > > Out[8]= > (2*Pi*r^2*(r^4 - 2*rho^4 - rho^2*zz + zz^2 + > r^2*(rho^2 + 2*zz)))/(3*(((r - rho)^2 + zz)* > ((r + rho)^2 + zz))^(5/2)) > > Unless I've missed something, it seems that _both_ of my simplifying > replacements are needed if Mathematica is to get a correct result > for the > definite integral. > > My second replacement is useful because Mathematica does not seem > to be > aware of the fact that the original integral must be independent of > alpha. > The result, 0, below is incorrect. > > In[9]:= > Assuming[r > 0 && rho > 0 && zz > 0 && alpha > 0, > Integrate[(r*(r - rho*Cos[alpha - t]))/ (3*(r^2 - 2*r*rho*Cos[alpha > - t] > + rho^2 + zz)^3), {t, 0, 2 Pi}]] > > Out[9]= > If[alpha >= 3*Pi || alpha == Pi, 0, > Integrate[(r*(r - rho*Cos[alpha - t]))/(3*(r^2 + rho^2 + zz - > 2*r*rho*Cos[alpha - t])^3), {t, 0, 2*Pi}, Assumptions -> > alpha < 3*Pi && Pi != alpha]] > > I'm not sure why the first replacement is useful. But without it, > Mathematica produces a different sort of incorrect result for the > definite > integral. Being huge, I will not show the result here, but any > masochist > wishing to duplicate it (perhaps only possible in version 5.2?) can > use > > Assuming[r > 0 && rho > 0 && z > zeta, > Integrate[(r*(r - rho*Cos[t]))/ (3*(r^2 - 2*r*rho*Cos[t] + > rho^2 + (z - zeta)^2)^3), {t, 0, 2 Pi}]] > > David W. Cantrell

**Re: Hankel transform question**

**Mathematica Special Interest Group (Northern VA and Washington DC)**

**Re: Can Integrate[expr,{x,a,b}] give an incorrect result?**

**Re: Can Integrate[expr,{x,a,b}] give an incorrect result?**