I always thought any power of 1 equals 1, but Math.pow(1, Infinity)
returns NaN. Why not 1?
Java Math pow() The pow() method returns the result of the first argument raised to the power of the second argument.
The method calculates multiplication of the base with itself exponent times and returns the result of type double .
Math. pow is slow because it deals with an equation in the generic sense, using fractional powers to raise it to the given power. It's the lookup it has to go through when computing that takes more time. Simply multiplying numbers together is often faster, since native calls in Java are much more efficient.
It's a static method on Math class, which means you don't have to instantiate a Math instance to call it. The power of a number is the number of times the number is multiplied by itself.
This is more of a math question than a Javascript question, and you therefore use mathematical explanations such as the following (http://mathforum.org/library/drmath/view/53372.html):
When you have something like "infinity," you have to realize that it's not a number. Usually what you mean is some kind of limiting process. So if you have "1^infinity" what you really have is some kind of limit: the base isn't really 1, but is getting closer and closer to 1 perhaps while the exponent is getting bigger and bigger, like maybe (x+1)^(1/x) as x->0+.
The question is, which is happening faster, the base getting close to 1 or the exponent getting big? To find out, let's call:
L = lim x->0 of (x+1)^(1/x)
Then:
ln L = lim x->0 of (1/x) ln (x+1) = lim x->0 of ln(x+1) / x
So what's that? As x->0 it's of 0/0 form, so take the derivative of the top and bottom. Then we get lim x->0 of 1/(x+1) / 1, which = 1. So ln L = 1, and L = e. Cool!
Is it really true? Try plugging in a big value of x. Or recognize this limit as a variation of the definition of e. Either way, it's true. The limit is of the 1^infinity form, but in this case it's e, not 1. Try repeating the work with (2/x) in the exponent, or with (1/x^2), or with 1/(sqrt(x)), and see how that changes the answer.
That's why we call it indeterminate - all those different versions of the limit approach 1^infinity, but the final answer could be any number, such as 1, or infinity, or undefined. You need to do more work to determine the answer, so 1^infinity by itself is not determined yet. In other words, 1 is just one of the answers of 1^infinity.
An answer of "indeterminate" is not a number.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With