Hacker News new | past | comments | ask | show | jobs | submit login
Zero to the Power of Zero (wikipedia.org)
38 points by known 5 months ago | hide | past | favorite | 27 comments

After reading this I think a mathematically sound approach is to leave 0^0 undefined.

Then because of practicality define 0^0 = 1 accepting some weirdness around 0^0 (limits to 0^0 not being 1).

With "practicality" I mean for mathematicians the convenience for some definitions, perhaps like this: "While we know that 0^0 is undefined, we proceed with the definition 0^0 = 1, because in our domain the disconuity doesn't matter [...]". This could be a footnote.

For programmers just let the pow() function(s) return 1.

It's a pity (or in a more positive way: spicy) that nature doesn't hold the principle of the least surprise. It's something we can't or shouldn't fix.

I think that you are overcomplicating the underlying reasoning. Consider: How many functions are there from the empty set to the empty set? One, right?

I consider the debate over 0^0 to be easily solved with type signatures. If you consider the function pow(float, float), 0^0 should be undefined. If you consider the function pow(float, int), then 0^0 should be 1. The problem is that people view these two different power functions as a single function.

Speaking as a mathamatician, and replacing "float" with "real number":

We really like like to pretend that the integers are a subset of the real numbers. As such, we really like to pretend that the function pow : real X int -> real is a restriction of the function pow : real X real -> real.

Speaking as a programmer, I really expect the effect of casting between numeric types is only precision.

If pow(0f,0) != pow (0f, 0f), then you break both of these assumptions.

Shouldn't the int version be enbedded in the float version? Shouldn't they agree for equal values?

That's the point. They are two independent functions so they don't need to agree.

Why do they agree everywhere else then?

I wouldn't say it's the type of numbers, rather whether they're constant.

(Const 0)^(var 0) is 0.

(Var 0)^(const 0) is 1.

(Const 0)^(const 0) is undefined.

(Var 0)^(var 0) is defined based on the functions that define those variables.

But isn’t the following expected to be true?

  pow(0.0f, 0.0f) == (float)pow(0, 0)
If one is defined then so should the other. (At least, for developers’ benefit.)

Which languages are you thinking of? I just checked Haskell and Python, and they both give 1 for both integer and floating-point exponentiation.

Good referenced reasoning about it here https://www.nctm.org/tmf/dr.math/faq/faq.0.to.0.power.html

From the programmer’s standpoint, the reasoning goes like this. In C++, the initial value you pass to std::accumulate depends on the operator. For addition, 0 is the “natural” choice. For multiplication, it is 1. So, if you raise a number to some power using this function, you implicitly or explicitly start with 1. Followed by accumulation of the zero number of 0s this leaves you with 1.

C++ pow() is a function of doubles, not ints. You can't define it in terms of std::accumulate.

The integers are a subset of the reals, so the rule still should hold.

But that's exactly the issue. Pick one subset, and it's 0. Pick a different subset, and it's 1. There is no rule which always makes sense.

Why not just agree that pow(a, b) is discontinuous at a = 0.0?

This logic is broken.

If you take 1 as the initial value, and run the operation n ≥ 1 times, the initial value is used at least once.

But if you run the operation zero times, the initial value is never used, so the result is undefined.

How is nothing multiplied nothing times 1? I feel dumb asking this,but, why is it not 0 or NaN.

2^4 == 2222 == 16

0^0 == 0000 == 0

Why is it not that simple?

Why should the answer be 0?

We have an intuition that 0 is the identity element for addition, so it makes sense to treat it as the starting point for many things.

However, when we look at multiplication, 0 looks very different. Instead of preserving the other value, as it does with addition, multiplying by 0 changes the other value in an information destroying way (e.g if you know that x * 0 = 0, you have no idea what x is). This property of 0 is so distinct from the other numbers, that when we consider the integers (or reals, or complex numbers) as a structure that only has multiplication, but not addition, we typically exclude 0 from consideration.

Since (discrete) exponentiation is a multiplicative process, it makes sense to consider it in terms of the integers under multiplication; and so excluding 0. When we consider integers under multiplication, we notice that 1 has the same properties that 0 had under addition. Namely, 1 * x = x for all x. Given this, it makes sense to treat 1 as the "empty" element, the same way you want to do with 0 in additive contexts.

Thank you for the explanation, the reasoning sort of makes sense but I still can't wrap my head around how on the left side of the equation there is nothing(0) on the right hand there is something. Something cannot come out of nothing when considering natural phenomena in reality.

Let's take 2^3 * 2^5, we know that we can just add the numbers in the exponent to get 2^8. We can extend this, for example what would 2^3 * 2^0 be? If we want our rule to be consistent, it would be 2^3, implying that 2^0 = 1.

This works fine for all numbers except for 0. Like you pointed out, 0^5 = 0, 0^1 = 0, so it would make sense that 0^0 = 0? but if x^0 = 1, we have an issue.

Why is x^0=1? How can something be generated out of any equation where the only number is 0 (nothing)

> We can extend this, for example what would 2^3 * 2^0 be? If we want our rule to be consistent, it would be 2^3, implying that 2^0 = 1

replace 2 with x.

Another way to see it is 2^2 = 4 = 8 / 2 = 2^3 / 2 2^1 = 2 = 4 / 2 = 2^2 / 2 2^0 = ? how about 2^1 / 2 = 1

Again, replace 2 with x and the same follows.

With this example though, when x = 0, it's obvious that it no longer works since 0^0 would be 0^1 / 0 = 0/0

In the context of multiplication, raising a number to the zero-th power is a NOP (no operation, or nothing). So, for any x, x^0 = 1 times (x^0) = 1 times nothing = 1.

Multiplying by a number raised to the zero-th power is a NOP.

This comes up frequently in the context of polynomials, where the constant term is often expressed as the x^0 term.

E.g in f(x) = 3x^2 + 2x^1 + 1x^0 , we would like to have f(0)=0.

In many cases this is important because we express polynomials as a sum:

f(x) = sum (n from 0 to 2) { (n+1)x^n }, so having x^0 behave reasonably at x=0 allows us to avoid needed to special case the n=0 term.

This is one of the things most mathematicians usually don't care much about. Unlike programming (or automated theorem proving), mathematics can tolerate slight ambiguities that end up not mattering for the argument at hand, because it's ultimately read by people who understand the context.

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact