On Nov 27, 2:16 am, kcrisman <kcris...@gmail.com> wrote:
> Here's this in Sage.  See the end of this post for a solution you
> might like better than the ramblings in between :)
>
> ----------------------------------------------------------------------
> | Sage Version 4.7.2, Release Date: 2011-10-29                       |
> | Type notebook() for the GUI, and license() for information.        |
> ----------------------------------------------------------------------
> sage: var('m r a R')
> (m, r, a, R)
> sage: assume(2*m-3==0)
> ^[[A^[ integrate(1/r^(2*m+2)*(2*(r/a)^2-(r/a)^4),r)
> -2*r^(-2*m + 1)/((2*m - 1)*a^2) - log(r)/a^4
> sage: forget()
> sage: assume(2*m-1<0)
> sage:  integrate(1/r^(2*m+2)*(2*(r/a)^2-(r/a)^4),r)
> -2*r^(-2*m + 1)/((2*m - 1)*a^2) + r^(-2*m + 3)/((2*m - 3)*a^4)
>
> Just to make the point that this is something we can't really avoid,
> using Maxima as the default integration engine.
>
> Maxima 5.25.0http://maxima.sourceforge.net
> using Lisp SBCL 1.0.24
> Distributed under the GNU Public License. See the file COPYING.
> Dedicated to the memory of William Schelter.
> The function bug_report() provides bug reporting information.
> (%i1) integrate(1/r^(2*m+2)*(2*(r/a)^2-(r/a)^4),r);
> Is  2 m - 3  zero or nonzero?
>
> zero
> ;
>                                  1 - 2 m
>                               2 r           log(r)
> (%o1)                        ------------ - ------
>                               2                4
>                              a  (1 - 2 m)     a
> (%i2) integrate(1/r^(2*m+2)*(2*(r/a)^2-(r/a)^4),r);
> Is  2 m - 3  zero or nonzero?
>
> nonzero;
> Is  2 m - 1  zero or nonzero?
>
> nonzero;
>                               1 - 2 m       3 - 2 m
>                            2 r             r
> (%o2)                     ------------ - ------------
>                            2              4
>                           a  (1 - 2 m)   a  (3 - 2 m)
>
> "Bottom line, sage currently has to be coddled excessively via
> assumptions into giving any result at all, verses system which give
> results which may happen to be incorrect for certain values. "
>
> But that sounds dangerous to me, at least for this particular
> example.   How is it different from this example?
>
> sage: var('n')
> n
> sage: integrate(x^n,x)
> ValueError: Computation failed since Maxima requested additional
> constraints; using the 'assume' command before integral evaluation
> *may* help (example of legal syntax is 'assume(n+1>0)', see `assume?`
> for more details)
> Is  n+1  zero or nonzero?
>
> If anything, we've probably been too cavalier with our use of Maxima's
> fine-grained simplification and other routines at times; it seems
> dangerous to go the other way.
>
> At the same time, we have
>
> sage: integrate(x^n,x,algorithm='sympy')
> x^(n + 1)/(n + 1)
>
> which will at least sometimes do what you are interested in.    See
> the PS for the fact that it doesn't always do so.
>
> - kcrisman
>
> PS to devs:
>
> However
>
> sage:  integrate(1/r^(2*m+2)*(2*(r/a)^2-(r/a)^4),r,algorithm='sympy')
> ---------------------------------------------------------------------------
> AttributeError                            Traceback (most recent call
> last)
> v, a, b)
>      37     else:
>      38         result = sympy.integrate(ex, (v, a._sympy_(),
> b._sympy_()))
> ---> 39     return result._sage_()
>      40
>      41 def mma_free_integrator(expression, v, a=None, b=None):
>
> AttributeError: 'Integral' object has no attribute '_sage_'
>
> That looks like a bug in our sympy interface.  Any takers?

Note that:
sage:  var('m r a')
(m, r, a)
sage: f=expand(1/r^(2*m+2)*(2*(r/a)^2-(r/a)^4))
sage: f.integrate(r,algorithm="sympy")
-2*r^(-2*m + 1)/((2*m - 1)*a^2) + r^(-2*m + 3)/((2*m - 3)*a^4)

Andrzej Chrzeszczyk

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

Reply via email to