Ask Your Question
1

Sympy integration algorithm towards -infinity

asked 2012-01-21 19:00:39 +0200

Green diod gravatar image

updated 2023-01-10 00:01:08 +0200

tmonteil gravatar image

Following achrzesz hint about integral's algorithm option, I tried (Sage 4.7.2):

integral(1/x^2, x, -infinity, -1, algorithm='sympy')

Unfortunately, I got:

Traceback (click to the left of this block for traceback)
...
AttributeError: 'MinusInfinity' object has no attribute '_sympy_'

What's going wrong?

edit retag flag offensive close merge delete

Comments

1

The workarounds are good for now. I've opened the auspicious ticket # 12345 (http://trac.sagemath.org/sage_trac/ticket/12345) for the underlying issue.

kcrisman gravatar imagekcrisman ( 2012-01-23 13:15:50 +0200 )edit

3 Answers

Sort by ยป oldest newest most voted
1

answered 2012-01-21 19:20:30 +0200

Shashank gravatar image

It seems to be a bug. sympy can recognize infinity but not minus infinity of sage. You can try to directly call sympy integrate instead

import sympy as sp
a=sp.Symbol('a')
b=sp.integrate(1/x^2,(x,a,-1))._sage_()
b.substitute(a=-oo)
edit flag offensive delete link more

Comments

How do you get this infinity symbol? But most importantly, do you input this code in a simple python interpreter or in Sage? What is this _sage_() method?

Green diod gravatar imageGreen diod ( 2012-01-23 11:50:43 +0200 )edit

How do you get this infinity symbol?

Green diod gravatar imageGreen diod ( 2012-01-23 11:50:44 +0200 )edit

Every element from another program (such as sympy) has a `_sage_` method to convert its things back to Sage objects. The infinity symbol is just one of the several ways to represent infinity in Sage (and several other programs of this type); in principle, it should be equivalent to using `infinity`, but apparently this bug leaves it to not work for Sympy.

kcrisman gravatar imagekcrisman ( 2012-01-23 13:17:32 +0200 )edit

All right, but how do you input the infinity symbol?

Green diod gravatar imageGreen diod ( 2012-01-23 13:21:14 +0200 )edit
1

-oo is just minus oo the alphabets

Shashank gravatar imageShashank ( 2012-01-23 13:59:56 +0200 )edit
1

answered 2012-01-21 19:12:29 +0200

achrzesz gravatar image

sage: from sympy import *

sage: integrate(1/x^2, (x, -oo, -1), algorithm='sympy')

1

edit flag offensive delete link more

Comments

How do you get this infinity symbol?? Anyway, I still get the same error even at the console using -infinity

Green diod gravatar imageGreen diod ( 2012-01-23 11:49:52 +0200 )edit
0

answered 2013-06-05 21:45:23 +0200

Eviatar Bach gravatar image

This works as of Sage 5.1 (see trac #12345). (Please tell me if old questions shouldn't be necromanced; I just add answers for future reference to questions where the issue has been fixed.)

edit flag offensive delete link more

Comments

1

Seems fine to me! Or you could have commented under where I mentioned the ticket first, either is fine. Having complete info is good. Maybe we should close questions like that...

kcrisman gravatar imagekcrisman ( 2013-06-05 21:52:07 +0200 )edit
1

I am not sure we should close such questions, or at least we should'nt delete them, since trac points to them, and we should keep examples, even if they are fixed. That said, it could be nice to have a better integration between ask and trac, as well as a system of 'categories' that allow to separate questions related to a sage bug or questions related to a failed build, or questions related to how to use sage (probably the most interesting for the readers). I am currently trying to do this via tags (removing `bug` tag where this is not a bug, and adding `confirmed_bug` or `fixed_bug` tag when this is a bug), but it is quite a long task, and having an automated link between ask and trac could be of great help.

tmonteil gravatar imagetmonteil ( 2013-06-06 06:10:07 +0200 )edit

No, we shouldn't *delete* them; closing just means it's been resolved, I would say. But it's not really that important.

kcrisman gravatar imagekcrisman ( 2013-06-06 13:17:24 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2012-01-21 19:00:39 +0200

Seen: 6,650 times

Last updated: Jun 05 '13