[sage-support] Re: [sage-cell] Where Oh Where is my Divide By Zero Error?
On Friday, March 16, 2018 at 7:29:30 PM UTC-7, A. Jorge Garcia wrote: > > Thanks! > > On Fri, Mar 16, 2018, 10:27 PM Andrey Novoseltsev> wrote: > >> On Fri, Mar 16, 2018 at 4:18 PM, Jorge Garcia > > wrote: >> > Dear Hive Mind: >> > >> > Why is there no Divide By Zero Error here: >> > >> http://sagecell.sagemath.org/?z=eJwljkELgkAUhO-C_2GiAtek1kuX2Eu4pBc3NjEqCqQ2E-QlpvX3cwuGd5jHzDdjZHGyw6BUZdgoFQXYx1JLa2WxRJTkSSSxPuAotYLUWumR64zRcDEJOecBtFhOA3QitHZpyLRFZ1BR03fDvdb9raISJLjrpKItqDReyNnq9Xh-vJTZkHkXdW9DjUcMvu__F2SIlNxhk-Tyt-UHH76usxUny_a9cMbnfLkgdiHcny1oICI9_8u37AuZcDtw=sage >> > >> > But there is a Divide By Zero Error here (as expected): >> > >> http://sagecell.sagemath.org/?z=eJwlj0FLw0AQhe-B_IcnVcimQTeXXmQPtRnsXrJhG6q2WAh2GwtlGmKif9_dBoY5zJvvzZsZ6rXewNerMUWGNwK9V7SqsUSht7ogvHxgR9aArDX2Lo5m6KS6z6WUGaxaPGQYVB5HXcJChWma5HP5KBdPLA78_PN9_UuCJgLZOnZ9MzicuRsH378u4_HMLVjJOCpV33DrklyKiStvkPttLmOAgg3SNF2TJegahSGfW2_JP0FTPq_GUaX2t9XTtQf7Iyg_J79K_AMYbUA7=sage >> > >> > Can someone please explain this to me? This came up in class and I was >> > looking for a "teachable moment" asking the students to fix the Divide >> By >> > Zero Error like this: >> > >> http://sagecell.sagemath.org/?z=eJwljkFrg0AUhO-C_2GKKbhW0t1LLmUvwddmLxq2EtKWBKTZWkGeYjX5-3XjbXgz37yJkJmDyQjbD3ySLUDWFhav5kjZQxhE6KVeKSllCqs3jylGrcKgj1lof01i9STXcvPM4swvf7_dLfae8GTt2A3V6NBwP43Ii3JW3-10abgGaxkGuR4qrl2sUiXFQud31F2rdvKoL0OSJDuyBFMiK-gdb-ZAKHe0bJ3dMNjrr3v0pxvA8xvkp6VvL_4B6uc8qg===sage >> > >> > Thanx, >> > AJG >> >> Someone probably can, but perhaps not on this list: it has something >> to do with 0^0 evaluating to 1 and I recall some earlier discussions >> about it. Forwarding to sage-support. >> > Maybe related to this: sage: 2/0 --- ZeroDivisionError Traceback (most recent call last) in () > 1 Integer(2)/Integer(0) /Users/palmieri/Desktop/Sage_stuff/sage_builds/VANILLA/sage-8.2.beta8/local/lib/python2.7/site-packages/sage/rings/integer.pyx in sage.rings.integer.Integer.__div__ (build/cythonized/sage/rings/integer.c:13231)() 1910 if type(left) is type(right): 1911 if mpz_sgn((right).value) == 0: -> 1912 raise ZeroDivisionError("rational division by zero") 1913 x = Rational.__new__(Rational) 1914 mpq_div_zz(x.value, (left).value, (right).value) ZeroDivisionError: rational division by zero sage: 2.0/0 +infinity I don't like this behavior much. What is the rationale? In inexact rings, zero division is not a thing? -- John -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
Re: [sage-support] Re: [sage-cell] Where Oh Where is my Divide By Zero Error?
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, -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
Re: [sage-support] Re: [sage-cell] Where Oh Where is my Divide By Zero Error?
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) 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 Andrey Novoseltsev writes: > On Fri, Mar 16, 2018 at 4:18 PM, Jorge Garciawrote: >> Dear Hive Mind: >> >> Why is there no Divide By Zero Error here: >> http://sagecell.sagemath.org/?z=eJwljkELgkAUhO-C_2GiAtek1kuX2Eu4pBc3NjEqCqQ2E-QlpvX3cwuGd5jHzDdjZHGyw6BUZdgoFQXYx1JLa2WxRJTkSSSxPuAotYLUWumR64zRcDEJOecBtFhOA3QitHZpyLRFZ1BR03fDvdb9raISJLjrpKItqDReyNnq9Xh-vJTZkHkXdW9DjUcMvu__F2SIlNxhk-Tyt-UHH76usxUny_a9cMbnfLkgdiHcny1oICI9_8u37AuZcDtw=sage >> >> But there is a Divide By Zero Error here (as expected): >> http://sagecell.sagemath.org/?z=eJwlj0FLw0AQhe-B_IcnVcimQTeXXmQPtRnsXrJhG6q2WAh2GwtlGmKif9_dBoY5zJvvzZsZ6rXewNerMUWGNwK9V7SqsUSht7ogvHxgR9aArDX2Lo5m6KS6z6WUGaxaPGQYVB5HXcJChWma5HP5KBdPLA78_PN9_UuCJgLZOnZ9MzicuRsH378u4_HMLVjJOCpV33DrklyKiStvkPttLmOAgg3SNF2TJegahSGfW2_JP0FTPq_GUaX2t9XTtQf7Iyg_J79K_AMYbUA7=sage >> >> Can someone please explain this to me? This came up in class and I was >> looking for a "teachable moment" asking the students to fix the Divide By >> Zero Error like this: >> http://sagecell.sagemath.org/?z=eJwljkFrg0AUhO-C_2GKKbhW0t1LLmUvwddmLxq2EtKWBKTZWkGeYjX5-3XjbXgz37yJkJmDyQjbD3ySLUDWFhav5kjZQxhE6KVeKSllCqs3jylGrcKgj1lof01i9STXcvPM4swvf7_dLfae8GTt2A3V6NBwP43Ii3JW3-10abgGaxkGuR4qrl2sUiXFQud31F2rdvKoL0OSJDuyBFMiK-gdb-ZAKHe0bJ3dMNjrr3v0pxvA8xvkp6VvL_4B6uc8qg===sage >> >> Thanx, >> AJG > > Someone probably can, but perhaps not on this list: it has something > to do with 0^0 evaluating to 1 and I recall some earlier discussions > about it. Forwarding to sage-support. -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: [sage-cell] Where Oh Where is my Divide By Zero Error?
Thanks! On Fri, Mar 16, 2018, 10:27 PM Andrey Novoseltsevwrote: > On Fri, Mar 16, 2018 at 4:18 PM, Jorge Garcia wrote: > > Dear Hive Mind: > > > > Why is there no Divide By Zero Error here: > > > http://sagecell.sagemath.org/?z=eJwljkELgkAUhO-C_2GiAtek1kuX2Eu4pBc3NjEqCqQ2E-QlpvX3cwuGd5jHzDdjZHGyw6BUZdgoFQXYx1JLa2WxRJTkSSSxPuAotYLUWumR64zRcDEJOecBtFhOA3QitHZpyLRFZ1BR03fDvdb9raISJLjrpKItqDReyNnq9Xh-vJTZkHkXdW9DjUcMvu__F2SIlNxhk-Tyt-UHH76usxUny_a9cMbnfLkgdiHcny1oICI9_8u37AuZcDtw=sage > > > > But there is a Divide By Zero Error here (as expected): > > > http://sagecell.sagemath.org/?z=eJwlj0FLw0AQhe-B_IcnVcimQTeXXmQPtRnsXrJhG6q2WAh2GwtlGmKif9_dBoY5zJvvzZsZ6rXewNerMUWGNwK9V7SqsUSht7ogvHxgR9aArDX2Lo5m6KS6z6WUGaxaPGQYVB5HXcJChWma5HP5KBdPLA78_PN9_UuCJgLZOnZ9MzicuRsH378u4_HMLVjJOCpV33DrklyKiStvkPttLmOAgg3SNF2TJegahSGfW2_JP0FTPq_GUaX2t9XTtQf7Iyg_J79K_AMYbUA7=sage > > > > Can someone please explain this to me? This came up in class and I was > > looking for a "teachable moment" asking the students to fix the Divide By > > Zero Error like this: > > > http://sagecell.sagemath.org/?z=eJwljkFrg0AUhO-C_2GKKbhW0t1LLmUvwddmLxq2EtKWBKTZWkGeYjX5-3XjbXgz37yJkJmDyQjbD3ySLUDWFhav5kjZQxhE6KVeKSllCqs3jylGrcKgj1lof01i9STXcvPM4swvf7_dLfae8GTt2A3V6NBwP43Ii3JW3-10abgGaxkGuR4qrl2sUiXFQud31F2rdvKoL0OSJDuyBFMiK-gdb-ZAKHe0bJ3dMNjrr3v0pxvA8xvkp6VvL_4B6uc8qg===sage > > > > Thanx, > > AJG > > Someone probably can, but perhaps not on this list: it has something > to do with 0^0 evaluating to 1 and I recall some earlier discussions > about it. Forwarding to sage-support. > -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: [sage-cell] Where Oh Where is my Divide By Zero Error?
On Fri, Mar 16, 2018 at 4:18 PM, Jorge Garciawrote: > Dear Hive Mind: > > Why is there no Divide By Zero Error here: > http://sagecell.sagemath.org/?z=eJwljkELgkAUhO-C_2GiAtek1kuX2Eu4pBc3NjEqCqQ2E-QlpvX3cwuGd5jHzDdjZHGyw6BUZdgoFQXYx1JLa2WxRJTkSSSxPuAotYLUWumR64zRcDEJOecBtFhOA3QitHZpyLRFZ1BR03fDvdb9raISJLjrpKItqDReyNnq9Xh-vJTZkHkXdW9DjUcMvu__F2SIlNxhk-Tyt-UHH76usxUny_a9cMbnfLkgdiHcny1oICI9_8u37AuZcDtw=sage > > But there is a Divide By Zero Error here (as expected): > http://sagecell.sagemath.org/?z=eJwlj0FLw0AQhe-B_IcnVcimQTeXXmQPtRnsXrJhG6q2WAh2GwtlGmKif9_dBoY5zJvvzZsZ6rXewNerMUWGNwK9V7SqsUSht7ogvHxgR9aArDX2Lo5m6KS6z6WUGaxaPGQYVB5HXcJChWma5HP5KBdPLA78_PN9_UuCJgLZOnZ9MzicuRsH378u4_HMLVjJOCpV33DrklyKiStvkPttLmOAgg3SNF2TJegahSGfW2_JP0FTPq_GUaX2t9XTtQf7Iyg_J79K_AMYbUA7=sage > > Can someone please explain this to me? This came up in class and I was > looking for a "teachable moment" asking the students to fix the Divide By > Zero Error like this: > http://sagecell.sagemath.org/?z=eJwljkFrg0AUhO-C_2GKKbhW0t1LLmUvwddmLxq2EtKWBKTZWkGeYjX5-3XjbXgz37yJkJmDyQjbD3ySLUDWFhav5kjZQxhE6KVeKSllCqs3jylGrcKgj1lof01i9STXcvPM4swvf7_dLfae8GTt2A3V6NBwP43Ii3JW3-10abgGaxkGuR4qrl2sUiXFQud31F2rdvKoL0OSJDuyBFMiK-gdb-ZAKHe0bJ3dMNjrr3v0pxvA8xvkp6VvL_4B6uc8qg===sage > > Thanx, > AJG Someone probably can, but perhaps not on this list: it has something to do with 0^0 evaluating to 1 and I recall some earlier discussions about it. Forwarding to sage-support. -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.