We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Maybe it's getting late but why is the power of 2 for the value 0 -> 1?
for (int i = 0; i <= 16; i++) {
println(i, pow(2, i));
}
(Code formatting keeps eating the code...)
Answers
Hmm, this forum behaves so strange sometimes with posting code...
That code does 2^0 and anything ^0 is 1.
Nice short math explanation video:
Anything to the power of zero is one. That's just a basic (and forgettable) mathematical rule.
Get out a calculator and check the value. If you don't have a calculator, try google or Wolfram Alpha.
https://www.google.com/search?q=2^0
http://www.wolframalpha.com/input/?i=2^0
http://www.wolframalpha.com/input/?i=x^0
x^³ is actually
1 * x*x*x
.1
is the origin, where it all starts.Likewise x^-³ is
1 / x/x/x
.And x^0 is obviously
1
. And it can't be anything else!For if the origin was
0
, the result would be0
always:0 * x*x*x
.And any other origin value would alter the result:
2 * x*x*x
isn't1 * x*x*x
!Please stop saying anything to the 0th power is 0.
0^0 is not 1, it is indeterminate. Thanks.
That is a special case and nobody was mentioning that 1 in particular:
https://en.Wikipedia.org/wiki/Exponentiation#History_of_differing_points_of_view
For when the base in non-zero and exponent is zero, all the explanations were correct:
https://en.Wikipedia.org/wiki/Exponentiation#Zero_exponent
https://en.Wikipedia.org/wiki/Empty_product
His original case was only talking about 2^0. We could get into an entire lesson on exponents, but he was only asking why 2^0 is 1.
Interestingly enough, both google and my calculator say 0^0 is 1. Only Wolfram Alpha says 0^0 is indeterminate.
And Processing itself returns 1.0 for
pow(0, 0)
, so from Processing's perspective, 0^0 is indeed 1! :pSince 0^0 is mathematically indeterminate (Wolfram is right) then Java, Processing and your calculator are technically wrong but it is common to assign 'real values' for mathematically indeterminate values but that doesn't make the value 'right' :)
BTW my calculator reported an error for 0^0 B-)
This video looks at problems associated with the number zero.
The original question was simply about why Processing reports 2^0 as 1, and the answer is that Processing reports anything^0 as 1. We've answered the question, and now we're going down a math tangent (get it?).
Processing (er, Java) could have returned NaN for 0^0, but they return 1. I just checked, and so does JavaScript.
But none of this matters to the original question. Processing returns 1 for 2^0 because 2^0 is 1.
The original question was answered in the first comment by bilmor, everything after that is just candyfloss but interesting. :)
from java's pow():
http://docs.oracle.com/javase/7/docs/api/java/lang/Math.html#pow(double,%20double)