Re: [sage-cell] Where Oh Where is my Divide By Zero Error?

81 views
Skip to first unread message

Andrey Novoseltsev

unread,
Mar 16, 2018, 10:27:41 PM3/16/18
to Jorge Garcia, sage-support, sage-cell

Jorge Garcia

unread,
Mar 16, 2018, 10:29:30 PM3/16/18
to Andrey Novoseltsev, SAGE support, sage-cell
Thanks! 
Message has been deleted
Message has been deleted
Message has been deleted

Johan S. H. Rosenkilde

unread,
Mar 18, 2018, 12:19:07 PM3/18/18
to sage-s...@googlegroups.com
Hi,

It is not related to exponentiation; it is due to the difference between
symbolic evaluation and real-valued evaluation when dividing by zero.

Real-valued arithmetic mirrors the IEEE floating point standard, I expect:

sage: 1.0/0
+infinity

While symbolic evaluation gives the divide-by-zero error:

sage: expr = 1.0/x
sage: expr(x=0)
<BOOM>
Traceback (most recent call last)
...
ValueError: power::eval(): division by zero

Note that the inline-function-notation "p(n) = ..." is really just
defining a symbolic expression. In the above snippet I rely on x being a
symbolic variable in a fresh Sage instance, thereby avoiding writing
"expr(x) = ...".

I don't have a better explanation for why this difference has been
adopted in Sage than the above: following IEEE standard vs doing the
mathematically safe-and-fail-early-solution. Perhaps someone more
knowledgeable about this can chime in.

Best,
Johan

Ralf Stephan

unread,
Mar 20, 2018, 3:20:36 AM3/20/18
to sage-support
On Sunday, March 18, 2018 at 5:19:07 PM UTC+1, Johan S. H. Rosenkilde wrote:
I don't have a better explanation for why this difference has been
adopted in Sage than the above: following IEEE standard vs doing the
mathematically safe-and-fail-early-solution. Perhaps someone more
knowledgeable about this can chime in.

Historically throwing this specific error was introduced with the massive effort of adapting GiNaC to Sage (2008-2012). There are various errors you can get by triggering different code parts. Another in symbolics:

sage: SR(1)/0
...
ZeroDivisionError: Symbolic division by zero

Regards,
Reply all
Reply to author
Forward
0 new messages