MathGroup Archive 2000

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

Search the Archive

Re: Re: Simple integral wrong

  • To: mathgroup at smc.vnet.net
  • Subject: [mg25125] Re: [mg25085] Re: [mg25021] Simple integral wrong
  • From: Richard Fateman <fateman at EECS.Berkeley.EDU>
  • Date: Sun, 10 Sep 2000 03:14:46 -0400 (EDT)
  • Organization: computer science division, uc berkeley
  • References: <B5DEA5DA.797F%andrzej@bekkoame.ne.jp>
  • Sender: owner-wri-mathgroup at wolfram.com


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.

> 
> > 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?

>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.

>Mathematica chooses to return as its "answer" a formula which for some
> interpretations of a is mathematically correct. 

The notion of "choice" here is not really appropriate.  Mathematica fell
into
this hole because it is not programmed with sufficient understanding of
the situation to produce other answers.  The program ends with one
thing, and
that's what it returns.  It reflects, more than anything else, the lack
of
understanding of the programmer of what the full answer is.

>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). 

Yes!
> In any case, as I wrote above, these are really questions about
> the interface. 
No, if the Mathematica program really computed the correct answer(s) and
then chose the simple/wrong one, then it would be an interface problem.
In fact, Mathematica only computed ONE answer, an arguably wrong answer,
and that is in the core of the Mathematica system, not part of
the interface.  If you want to build a whole new system that knows
about path integrals, you will have to avoid ever asking the existing
core system about path integrals.  Thus the core is essentially
wrong.
>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.
In the same program..
> 
> > 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.

The validity of a mathematical proof that can be only confirmed by
extensive
computation (like the 4 color problem) is not worth discussing here.  It
is
nice to be able to confirm independently, any published result, but this
is
NOT what happens in computational science.  Can you imagine a
mathematician
refusing to carry an umbrella until the computer-assisted weather
prediction
program's computation was checked by hand?
Given the fact that serious applied mathematical arithmetic computations
may simply
not be humanly "checkable", why do we say that SYMBOLIC computations are
inherently different and should be treated as guesses?  In fact, the
situation
is quite the reverse technologically speaking.  When arithmetic is
performed,
it is usually inexact and by accumulation of round-off, the results may
be
substantially different from the ideal.  In symbolic computation, X+Y is
exactly X+Y, not X+Y+epsilon.

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/


  • Prev by Date: Re: Square Roots mod n (n composite)
  • Next by Date: Re: Re: Simple integral wrong
  • Previous by thread: Re: Simple integral wrong
  • Next by thread: Re: Re: Simple integral wrong