Re: Re: Simple integral wrong

*To*: mathgroup at smc.vnet.net*Subject*: [mg25094] Re: [mg25085] Re: [mg25021] Simple integral wrong*From*: Andrzej Kozlowski <andrzej at bekkoame.ne.jp>*Date*: Fri, 8 Sep 2000 03:00:41 -0400 (EDT)*Sender*: owner-wri-mathgroup at wolfram.com

on 00.9.8 11:28 AM, Richard Fateman at fateman at cs.berkeley.edu wrote: > The problem pointed out here is that Mathematica gives, for the > indefinite integral, a form that cannot be used via the fundamental > theorem of calculus, to compute the definite integral. > First of all it would be nice if the result were "simplified" > to Sqrt[Sin[z]^2]. It might be nice but also wrong, since the two answers are only equal in the first and third quadrants (for real z) e.g: In[23]:= Sqrt[Cos[z]^2]*Tan[z] /. z -> 7*Pi/4 Out[23]= 1 -(-------) Sqrt[2] In[24]:= Sqrt[Sin[z]^2] /. z -> 7Pi/4 Out[24]= 1 ------- Sqrt[2] > Then it would be nice if it were noted that integration through > points at which Sqrt[0] were computed would result in possible > problems. > Rather than saying "I understand how Mathematica might compute this > wrong > result" and it is therefore forgivable, I would recommend trying > to figure out how to conditionalize the result so that illegal > substitutions can be avoided. This is basically a question of interface rather anything to do with "bugs" etc. I must admit I am also disturbed when Mathematica "innocently" returns what looks like a mathematically wrong answer. However, in many cases, including this one, the answer only "looks" wrong. A good case can be made for the view that Integrate[Abs[Cos[x]], {x, 0, (Pi)*a}] /. a -> 3/4 is simply not a legitimate way to try to get an answer to the question posed, particularly that Integrate[Abs[Cos[x]], {x, 0, (Pi)*(3/4)}] returns the correct answer. There is a deeper philosophical issue involved here. In my first posting I wrote that "there is nothing mathematically wrong" with the answer returned by Mathematica, but actually a more correct view would be that everything is wrong with both the answer and the question. The input Integrate[Abs[Cos[x]], {x, 0, (Pi)*a}] has no mathematical meaning until an interpretation is assigned to a, and also until it has been agreed what sort of mathematical (?) object an answer to this sort of question is supposed to be. Mathematica chooses to return as its "answer" a formula which for some interpretations of a is mathematically correct. Other possible approaches (probably even more unsatisfactory) would be to return no answer at all, or to return a long lecture on the theory of complex integration. (A long statement beginning with If might be seen as a compact form of the latter solution). In any case, as I wrote above, these are really questions about the interface. The problem seems to me to be that there is no consistent and clear principle about what sort of "object" a Mathematica answer should be, and that what appear to be inconsistent approaches are used in different situations. > I would like to think we can get BETTER results from computer > programs, (compared to humans) not worse. How can we build > more sophisticated routines on top of computer algebra systems > if all lower level steps have to be checked by humans? > (like ooh... you used an absolute value function: no telling > what might be broken. or even worse ... you used Sqrt as in > Sqrt[Cos[x]^2] which Mathematica might not distinguish from > Abs... > > RJF Well, this very much depends on what you mean by "better". I don't think most mathematicians would accept as correct any result that could only be verified by a computer program (well, maybe if one could check every step of the algorithm that is being used, which obviously we don't do in the case of programs like Mathematica). Hence all results returned by such programs can be treated basically as guesses, which require further work to confirm. That means that understanding what is going on is and is going to remain essential, whether the answers returned are "correct" or not. That is why I am not terribly worried by "wrong" answers as long as that are easily understandable. Actually I think they can be more useful than right answers which are not "understandable" (like the billionth digit of Pi etc), though of course understandable right answers are preferable. > Andrzej Kozlowski wrote: >> >> My mathematica 4 (for MacOS) gives: >> >> In[1]:= >> Table[Integrate[Abs[Cos[x]], {x, 0, (Pi/2)*n}], {n, 1, 5, 2}] >> Out[2]= >> {1, 3, 5} >> >> which undobtedly is correct, so I suppose you must be referring to something >> else. >> >> Perhaps you have in mind something like this: >> >> In[3]:= >> Integrate[Abs[Cos[x]], {x, 0, (Pi)*a}] /. a -> 3/4 >> Out[3]= >> 1 >> -(-------) >> Sqrt[2] >> >> In[4]:= >> Integrate[Abs[Cos[x]], {x, 0, (Pi)*(3/4)}] >> Out[4]= >> 1 >> 2 - ------- >> Sqrt[2] >> >> The first answer is "wrong" but it is quite understandable and, in a way, >> reasonable how it is obtained. To see this note that Mathematica gives: >> >> In[5]:= >> Integrate[Abs[Cos[x]], {x, 0, z}] >> Out[5]= >> 2 >> Sqrt[Cos[z] ] Tan[z] >> >> The indefinite integral is interpreted as a path integral in the complex >> plane. Is this answer right or wrong? There is nothing mathematically wrong >> with it, except that the function Abs[Cos[z]] is not analytic everywhere and >> there is no "unique" correct answer, independent of the path chosen (and >> hence also of z). In my opinion Mathematica does here as much as could be >> reasonably expected of it in this sort of situation. The alternative would >> be for it not to give any answer to "path integrals" involving non-analytic >> functions. At least then there would be less complaint about "bugs" in >> integration. >> >> -- >> Andrzej Kozlowski >> Toyama International University, JAPAN >> >> For Mathematica related links and resources try: >> <http://www.sstreams.com/Mathematica/> >> >> on 9/2/00 2:57 AM, Paul Cally at cally at kronos.maths.monash.edu.au wrote: >> >>> Try integrating | cos u| from u=0 to u = Pi x. Despite the integrand >>> being everywhere >>> non-negative, Mathematica 4 gives a result which jumps DOWNWARDS by 2 at >>> >>> x=1/2, 3/2, 5/2, .... I thought these simple integration errors had been >>> sorted out by >>> Wolfram years ago! >>> >>> Paul Cally >>> >>> -- >>> >>> +--------------------------------------------------------------------------+ >>> |Assoc Prof Paul Cally | Ph: +61 3 9905-4471 | >>> |Dept of Mathematics & Statistics | Fax: +61 3 9905-3867 | >>> |Monash University | paul.cally at sci.monash.edu.au | >>> |PO Box 28M, Victoria 3800 | | >>> |AUSTRALIA | http://www.maths.monash.edu.au/~cally/ | >>> +--------------------------------------------------------------------------+ >>> >>> >>> >>> >>> > -- Andrzej Kozlowski Toyama International University JAPAN http://platon.c.u-tokyo.ac.jp/andrzej/ http://sigma.tuins.ac.jp/

**Re: More troubles coming from indexed variables**

**Faulty feature of Factor?**

**Re: Simple integral wrong**

**Re: Re: Simple integral wrong**