4 ms·
Perhaps a related question: How should it be defined in a math library for a programming language? Should it return 1, or throw an exception?
by analog31 13y ago
Perhaps a related question: How should it be defined in a math library for a programming language? Should it return 1, or throw an exception?
- biot 13y agoWhy is that even a question? It should return the correct answer, of course. Edit: At the very least, that behaviour should be a configurable option for those who desire something other than what most mathematicians accept as being the correct answer.
- my_username_is_ 13y agoThe whole point of this is that there isn't necessarily a single right answer. As another user pointed out, mathematicians define 0^0 to be 1, but you don't necessarily have to accept that as truth in the way that 1+1=2.
- xamuel 13y agoIf the calculator is powerful enough (as in the case of Mathematica) to evaluate Taylor series, for example the Maclaurin series for e^x when x=0, then in doing so it implicitly admits 0^0=1. If it simultaneously says 0^0 is not 1, then the calculator is inconsistent. (Mathematica IS inconsistent in this example)
- kijin 13y agoIn JavaScript, Math.pow(0, 0) == 1. In Python and Ruby, 0 asterisk asterisk 0 == 1. In Windows Calculator, 0 [x^y] 0 == 1. So I guess the consensus is that you should return 1.
- krilnon 13y agoMathematica (or do we call it Wolfram Language now?) evaluates 0^0 as Indeterminate and warns: `Power::indet: "Indeterminate expression 0^0 encountered."`
- stephencanon 13y agoMath libraries (and language standards) should follow the guidance in IEEE-754 unless they have a very good reason not to do so. "pow(x, +/-0) is 1 for any x (even a zero, quiet NaN, or infinity)." "pown(x, 0) is 1 for any x (even a zero, quiet NaN, or infinity)." - but - "powr(+/-0, +/-0) signals the invalid operation [and returns NaN]." "pown" refers to the function on R x N defined by repeated multiplication; "powr" is the function on R x R defined by exp(y log(x)). "pow" refers to the mental hodgepodge of the two that most people intend when they write x^y without really thinking about it.