# When is 0^0 NaN in Sage? sage: 1 == 0^0 == 0**0 == pow(0,0)
True

sage: power_mod(0,0,2)
Traceback (click to the left of this block for traceback)
...
ArithmeticError: 0^0 is undefined.

http://en.wikipedia.org/wiki/Exponentiation#IEEE_floating_point_standard

edit retag close merge delete

Sort by » oldest newest most voted

Here is another case:

sage: GF(7)(0)^0
---------------------------------------------------------------------------
ArithmeticError                           Traceback (most recent call last)

/home/jsrn/local/sage/<ipython console> in <module>()

/home/jsrn/local/sage/sage-4.5.3/local/lib/python2.6/site-packages/sage/rings/finite_rings/integer_mod.so in sage.rings.finite_rings.integer_mod.IntegerMod_int.__pow__ (sage/rings/finite_rings/integer_mod.c:16942)()

ArithmeticError: 0^0 is undefined.


The same goes for polynomial rings over fields: GF(7)[x](0)^0.

I think that the primary thing is for Sage to be consistent; as you hinted at, I would think that the following invariants should always hold:

a^x == a**x == pow(a,x)


and

a^x mod n == pow(a,x,n) == power_mod(a,x,n)


For all rings in which they make sense. The 0^0 case is sometimes convenient to define to 1, sometimes 0 and sometimes NaN, so I would think that always giving an error is sensible. It is kind of annoying to often have to work around in general formulas, but on the other hand, in each of these cases, Sage will force you to consider the behaviour that makes mathematical sense for you; otherwise, you might miss rare cases of errors. As an alternative, some sort of global setting (or ring-specific setting) might be added, so one could set the value.

The behaviour of simplify is another discussion, I guess. There, it might prove _very_ annoying to not simplify 0^some_expr, but then again, I do like consistency.

Maybe this should be taken to sage_devel; maybe it has already been there? Sorry for the discussion-like quality of the answer.

more

In the code, I see that that power_mod makes a special case for 0^0. Maybe it shouldn't? Mathematica leaves it as a more correct Indeterminate

Mathematica 7.0 for Mac OS X x86 (64-bit)

In:= 0^0

0
Power::indet: Indeterminate expression 0  encountered.

Out= Indeterminate

more

As an input: Matlab computes 0^0 to 1.

>> version
ans =
7.9.0.529 (R2009b)
>> 0^0
ans =
1

more