MathGroup Archive 1990

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

Search the Archive

Integrate?

  • To: mathgroup at yoda.ncsa.uiuc.edu
  • Subject: Integrate?
  • From: Jeffrey P. Golden <jpg at ALLEGHENY.SCRC.Symbolics.COM>
  • Date: Sat, 3 Nov 90 20:55 EST

Since one of you brought MACSYMA into this, I guess I'll respond:

    Date: Fri, 2 Nov 90 18:21:48 +0100
    From: Harald Hanche-Olsen <hanche at imf.unit.no>

    Robert Staerk <staerk at iam.unibe.ch> writes ...

       Mathematica gives a wrong answer to the following integral:

				   2 Pi
				    /
				   |                  1/2
				   |    (2 - 2 cos(x))    dx
				   |
				  /
				  0

       Is this a known bug?

       In[1]:= Integrate[ Sqrt[2 - 2 Cos[x]], {x, 0, 2 Pi}]
       Out[1]= 0


       MAPLE V
       > int( sqrt(2 - 2 * cos(x)), x=0...2*Pi );

                                       8

As I'll try to demonstrate below, I don't think this is such an easy 
problem.  So, I wonder how Maple did it?

    This is apparently caused by Mathematicas attempts at being clever
    about things like complex square roots, branch cuts and the like.

I don't believe this theory.  As I show below, it is quite possible to 
get the answer of 0 by simply not being clever!  I don't actually know 
how Mathematica gets its answer of 0, a WRI person would have to tell 
us that.  But I do know how MACSYMA gets its answer of 0.  Mathematica 
might be losing here in the same way.

    Yes, it is known.  And some people think Mathematica is brain-dead
    because of it.  Myself, I haven't decided yet.  I keep alternating
    between Mathematica and Maple, just like you seem to do...

All CAS unfortunately get some integrals wrong.  I only fixed MACSYMA 
a few months ago to get e.g.  integrate(sqrt(x+1/x-2),x,0,1);  ->  4/3, 
instead of -4/3 .  How does MAPLE V do on that one?

    ------------------------------------------------

    Date: Thu, 1 Nov 90 13:52:13 -0500
    From: Jack <jack at brahms.udel.edu>

    Macsyma also gives the same incorrect result 0 for this integral
    (version 416.48 for Sparc Computers).  That really surprised me.

Here's how MACSYMA gets 0:


(c1) /* The following gives the wrong answer: */
     integrate(sqrt(2-2*cos(x)),x,0,2*%pi);

(d1)                             0

(c2) /* Here's the reason why: */
     /* Just look at the indefinite integral and then 
        take limits: */
     integral: integrate(sqrt(2-2*cos(x)),x);

                                  4
(d2)                 - -----------------------
                                  2
                               sin (x)
                       sqrt(------------- + 1)
                                        2
                            (cos(x) + 1)

(c3) upper_limit: limit(integral,x,2*%pi,minus);

(d3)                            - 4

(c4) lower_limit: limit(integral,x,0,plus);

(d4)                            - 4

(c5) upper_limit - lower_limit;

(d5)                             0

(c6) /* Two ways to get the correct answer: */
     /* The first works in any MACSYMA (I think), 
        the latter only in the development version: */
     2*integrate(sqrt(2-2*cos(x)),x,0,%pi);

(d6)                             8

(c7) integrate(sqrt(2-2*cos(x)),x,-%pi,%pi);

(d7)                             8


The above is not meant to offer any excuses for giving an 
incorrect result.  A wrong answer is bad news.  C7/D7 shows 
that we've done something, but not enough.  There are many 
ways to get the correct answer here: split the integration 
interval (and do all the consequent integrals correctly!), 
do a smart change of variables, use the halfangle formula, 
etc.  But not all of these approaches are necessarily 
appropriate for a computer algebra system.  Nevertheless, 
these approaches indicate to me, time allowing, that we can 
fix this bug in MACSYMA.  I'm not promising when.  

Again, bugs are bad news.  But unfortunately all CAS have 
them.  We try to do the best here we can.  (I have been 
planning a MACSYMA Newsletter article on this problem and 
related problems.  We need to tell our users what they 
unfortunately must watch out for.)

Anyway, this is a Mathematica Group list, so I apologize 
for going on so long.

From: Jeffrey P. Golden <jpg at ALLEGHENY.SCRC.Symbolics.COM>
Organization: Symbolics MACSYMA Division


  • Prev by Date: Limit[Sum[...,{n,1,Infinity}], n->Infinity]
  • Next by Date: mathematica bug
  • Previous by thread: Integrate?
  • Next by thread: Integrate?