Re: Re: Simple integral wrong
- To: mathgroup at smc.vnet.net
- Subject: [mg25140] Re: [mg25085] Re: [mg25021] Simple integral wrong
- From: Andrzej Kozlowski <andrzej at bekkoame.ne.jp>
- Date: Sun, 10 Sep 2000 03:14:58 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
I must make a correction to the last message. The solution Sqrt[Sin[z]^2] is
actually better than Sqrt[Cos[z]^2]*Tan[z] since it gives the correct value
at z=Pi/2 etc. (It was I who got confused and thought it was the other way
round).
Also, I misunderstood your meaning of "simplified" failing to notice that it
was written in quotation marks.
Andrzej
on 00.9.9 11:20 AM, Andrzej Kozlowski at andrzej at bekkoame.ne.jp wrote:
> on 00.9.9 0:41 AM, Richard Fateman at fateman at EECS.Berkeley.EDU wrote:
>
>>
>>
>> Andrzej Kozlowski wrote:
>>>
>>> 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]
>>
>> Actually, the non-equivalence of the two expressions as demonstrated by
>> substitution is NOT convincing.
>> As we know, the sqrt(2) has TWO values, +1.41... and - 1.41... and
>> Mathematica is choosing the wrong ones sometimes. If you return, for
>> the square-root, a set of the two values, then the answers are
>> equivalent
>> at any point. All you've shown above is that Mathematica still doesn't
>> know how to simplify square roots, not that the expressions are
>> different.
>
> It seems to me that you are just trying to confuse the issue here. You wrote:
>
>>>> First of all it would be nice if the result were "simplified"
>>>> to Sqrt[Sin[z]^2].
>
> First of all, it would be a strange program that "simplified"
> Sqrt[Cos[z]^2]*Tan[z] to Sqrt[Sin[z]^2]. And if you meant to say that
> Mathematica should have "chosen" Sqrt[Sin[z]^2] as its answer rather than
> Sqrt[Cos[z]^2]*Tan[z], than that would be almost as bad since while
> Sqrt[Cos[z]^2]*Tan[z] gives the wrong answer for certain z, Sqrt[Sin[z]^2] is
> wrong more often.
>>>
>>>> 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.
>> If it is not legitimate, then Mathematica should note that, don't you
>> think?
>> Imagine if the computation were in the middle of 8 hours of computing
>> time,
>> and were hidden inside a much larger expression. It is unreasonable to
>> REQUIRE every human user of Mathematica to check over its answers, don't
>> you think?
>
> That's what I meant by "a matter of interface".
>>
>>> 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.
>>
>> I disagree. Based on your approach, the answer should be
>> If{some_test[a], answer1[a], answer2[a]], which Mathematica can and
>> should
>> return.
>>
>> Actually, we need to do something about the path as well, since the
>> integrand
>> is not analytic.
>
> Well, that is actually what I meant. Mathematica is often asked to return an
> answer where there is no unique answer. It sometimes will simply return the
> input unevaluated (as in Sqrt[a^2]), sometimes an "If" statement and sometimes
> just an answer which is only valid under some conditions. That's what I meant
> when I wrote that there is no clear principle about what constitutes a
> "Mathematica answer". On the other hand one may argue that there is a good
> reason for the absence of such a principle. In some areas Mathematica enters
> into territory where there are no known general algorithms that in all cases
> lead to correct solutions. In fact integration is an obvious example of this
> sort of situation, but there are others. One then has the choice between not
> returning any answer (or, in Mathematica's case returning the input
> unevaluated) or using ad hoc methods which which will give the right answer in
> certain cases but may also give erroneous ones in other. In mathematics this
> sort of thing does not arise because we are not forced to use general
> algorithms to solve particular problems, but can treat each as a special case.
> Obviously this is not a feasible approach for computer science. When I wrote
> that the main issue is one of interface I was referring mainly to these sort
> of situations. Basically the question is how to make the user aware that he is
> entering into a territory where there are no general methods and where correct
> answers are not guaranteed. I do not think Mathematica is very good at this.
> Sometimes warning messages are issued (e.g. by Solve, then it is using inverse
> functions), but in other cases only partially true or even wrong solutions are
> returned without any warning, even though this cannot be said to involve a
> "bug", because this sort of thing is to some extent inevitable (unless when
> restricted Mathematica only to those areas where perfectly general and
> infallible methods exist, which would make it a pretty boring and much less
> useful program).
>
> I think this deals with all the rest of the points you make. You seem to be
> assuming that everything can be dealt by general algorithms and the problem is
> only with implementing them. Well, maybe because our subjects are different,
> (I am an algebraic top0ologist) but to me this seems ridiculous. I can produce
> countless examples of mathematical problems which can't be dealt by any
> general algorithm, and others, where there are general algorithms which break
> down in various special cases. In fact from my point of view essentially all
> interesting mathematics is of this kind. This does make computer programs
> useless but it means that the program has to be used as a subsidiary tool, the
> main one being your brain and your knowledge of mathematics. With this
> approach I am, as I wrote, not terribly worried by Mathematica giving answers
> like the one in this case, because I can see what they mean and make as good
> use them as I would of a "correct answer", whatever that may mean in this case
> (and that itself is not quite well defined actually).
>
>
> Andrzej
>
>
>>
>> Of course if one uses a computer algebra system whose model of
>> mathematics
>> is broken, or which has outright bugs in it, then there are
>> difficulties,
>> just as if you were using a C compiler with a bug.
>
>
>>
>>>
>>> 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.
>>
>> And if the answer is very plausible, but wrong just the same, what are
>> you going to do? It is the responsibility of the computer scientists
>> and the mathematicians who build computer algebra systems to avoid the
>> commission of errors that result in errors.
>>
>> The view of certain physicist-programmers that suggest it is ok to
>> return
>> wrong answers because a good scientist would always seek independent
>> confirmation, suggest that the role of computers in symbolic mathematics
>> is trivialized to doing only what can be reproduced or confirmed by
>> paper and pencil in a reasonable time. I believe the role of computers
>> can be a good deal stronger. For example, a computer could be the
>> world's most expert source of knowledge about integration. It could
>> include
>> all tabulated integrals, and all algorithms. Of course a algorithm W
>> that sometimes returns wrong answers could NOT be used unless the
>> program
>> itself used some failure-proof program that called W, and rejected all
>> answers that were wrong.
>>
>> RJF
>>
>>> 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/
>
> --
> Andrzej Kozlowski
> Yokohama, JAPAN
>
> http://platon.c.u-tokyo.ac.jp/andrzej/
> http://sigma.tuins.ac.jp/
--
Andrzej Kozlowski
Yokohama, JAPAN
http://platon.c.u-tokyo.ac.jp/andrzej/
http://sigma.tuins.ac.jp/