Decimals and other numbers

Devin Jeanpierre jeanpierreda at gmail.com
Fri Jan 9 03:58:47 EST 2015


On Fri, Jan 9, 2015 at 12:49 AM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> Devin Jeanpierre wrote:
>
>> On Thu, Jan 8, 2015 at 6:43 PM, Dave Angel <davea at davea.name> wrote:
>>> What you don't say is which behavior you actually expected.  Since 0**0
>>> is undefined mathematically, I'd expect either an exception or a NAN
>>> result.
>>
>> It can be undefined, if you choose for it to be. You can also choose
>> to not define 0**1, of course.
>
> No you can't -- that would make arithmetic inconsistent. 0**1 is perfectly
> well defined as 0 however you look at it:
>
> lim of x -> 0 of x**1 = 0
> lim of y -> 1 of 0**y = 0

This is a misunderstanding of limits. Limits are allowed to differ
from the actual evaluated result when you substitute the limit point:
that's what it means to be discontinuous.

What you call making  arithmetic "inconsistent", I call making the
function inside the limit discontinuous at 0.

>
>> If 0**0 is defined, it must be 1. I
>> Googled around to find a mathematician to back me up, here:
>> http://arxiv.org/abs/math/9205211 (page 6, "ripples").
>
> Not quite. I agree that, *generally speaking* having 0**0 equal 1 is the
> right answer, or at least *a* right answer, but not always. It depends on
> how you get to 0**0...

You don't "get to" a number. Those are limits. Limits and arithmetic
are different.

(Well, sort of. :)

> Since you can get difference results depending on the method you use to
> calculate it, the "technically correct" result is that 0**0 is
> indeterminate.

No, only limits are indeterminate. Calculations not involving limits
cannot be indeterminate.

-snip-
> log(Q) = 0*-inf
>
> What is zero times infinity? In the real number system, that is
> indeterminate, again because it depends on how you calculate it

In the real number system, infinity does not exist. It only exists in
limits or extended number systems.

> : naively it
> sounds like it should be 0, but infinity is pretty big and if you add up
> enough zeroes in the right way you can actually get something non-zero.
> There's no one right answer. So if the log of Q is indeterminate, then so
> must be Q.
>
> But there are a host of good reasons for preferring 0**0 = 1. Donald Knuth
> writes (using ^ for power):
>
>     Some textbooks leave the quantity 0^0 undefined, because the
>     functions 0^x and x^0 have different limiting values when x
>     decreases to 0. But this is a mistake. We must define x^0=1
>     for all x , if the binomial theorem is to be valid when x=0,
>     y=0, and/or x=-y. The theorem is too important to be arbitrarily
>     restricted! By contrast, the function 0^x is quite unimportant.
>
> More discussion here:
>
> http://mathforum.org/dr.math/faq/faq.0.to.0.power.html

I've already been citing Knuth. :P

>> I expected 1, nan, or an exception, but more importantly, I expected
>> it to be the same for floats and decimals.
>
> Arguably, *integer* 0**0 could be zero, on the basis that you can't take
> limits of integer-valued quantities, and zero times itself zero times
> surely has to be zero.

No. No no no. On natural numbers no other thing makes sense than 1.
All of the definitions of exponentiation for natural numbers require
it, except for those derived from analytical notions of
exponentiation. (Integers just give you ratios of natural
exponentials, so again no.)

-- Devin



More information about the Python-list mailing list