On Sat, Nov 12, 2011 at 12:26 PM, Don <[email protected]> wrote:
> Hello Sage team,
>
> I ran into a definite integral that Sage can't seem to evaluate,
> for no obvious reason.  It can correctly find the indefinite
> integral for the function, and that is straightforward to evaluate.
> Here is the specific example, first as a definite integral then
> as an indefinite integral:

[...]

That's pretty weird.  Maxima (which Sage calls for this computation)
does the same thing in its default mode, so this isn't because of some
funny option we set to Maxima:

sage: s = integrate(1/(sqrt(x)*((1+sqrt(x))^2)),x,1,9)
sage: s._maxima_init_()
'integrate(((((x)^(1/2))+(1))^(-2))*((x)^(-1/2)),x,1,9)'
sage: !maxima
Maxima 5.23.2 http://maxima.sourceforge.net
...
(%i1) integrate(((((x)^(1/2))+(1))^(-2))*((x)^(-1/2)),x,1,9);
                          9
                         /
                         [            1
(%o1)                    I  ---------------------- dx
                         ]               2
                         /  (sqrt(x) + 1)  sqrt(x)
                          1
(%i2) integrate(((((x)^(1/2))+(1))^(-2))*((x)^(-1/2)),x);
                                        2
(%o2)                            - -----------
                                   sqrt(x) + 1


-------

I wonder if Sage should not call Maxima for definite integrals -- only
call Maxima for finding a primitive, then do the rest itself?

Here's a version of the integrate function that does what I'm speculating about:

def integrate2(f, x, a, b):
    g = integrate(f, x)
    return g(x=b) - g(x=a)

Here is some sample usage:

sage: integrate2(1/(sqrt(x)*((1+sqrt(x))^2)),   x, 1, 9)
1/2

sage: integrate2(x^3,   x, 2, pi)
1/4*pi^4 - 4




>
> % sage
> ----------------------------------------------------------------------
> | Sage Version 4.7.2, Release Date: 2011-10-29                       |
> | Type notebook() for the GUI, and license() for information.        |
> ----------------------------------------------------------------------
> sage: integrate(1/(sqrt(x)*((1+sqrt(x))^2)),x,1,9)
> integrate(1/((sqrt(x) + 1)^2*sqrt(x)), x, 1, 9)
> sage: integrate(1/(sqrt(x)*((1+sqrt(x))^2)),x)
> -2/(sqrt(x) + 1)
> sage:
> Exiting Sage (CPU time 0m0.55s, Wall time 0m15.24s).
>
>
> Just as a sanity check on whether there is something funny about
> this integral that I'm missing, I ran it through the proprietary
> competition, but both Maple and Mathematica did fine with it:
>
> % maple
>    |\^/|     Maple 15 (X86 64 LINUX)
> ._|\|   |/|_. Copyright (c) Maplesoft, a division of Waterloo Maple
> Inc. 2011
>  \  MAPLE  /  All rights reserved. Maple is a trademark of
>  <____ ____>  Waterloo Maple Inc.
>      |       Type ? for help.
>> int(1/(sqrt(x)*((1+sqrt(x))^2)),x=1..9);
>                                      1/2
>
>> quit
>>
> memory used=6.7MB, alloc=5.7MB, time=0.18
>
> % math
> Mathematica 8.0 for Linux x86 (64-bit)
> Copyright 1988-2010 Wolfram Research, Inc.
>
> In[1]:= Integrate[1/(Sqrt[x]*((1+Sqrt[x])^2)),{x,1,9}]
>
>        1
> Out[1]= -
>        2
>
> In[2]:=
> % exit
>
> Any ideas on why Sage can't do this one?
>
> Don Winsor
> Electrical Engineering and Computer Science dept.
> University of Michigan, Ann Arbor
>
> --
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to 
> [email protected]
> For more options, visit this group at 
> http://groups.google.com/group/sage-support
> URL: http://www.sagemath.org
>



-- 
William Stein
Professor of Mathematics
University of Washington
http://wstein.org

-- 
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to