1. power(0,0)
- Posted by petelomax Nov 03, 2015
- 2061 views
After reviewing http://rosettacode.org/wiki/Zero_to_the_zero_power I have changed Phix to yield 1.
Does anyone here have any strong opinions on the matter?
2. Re: power(0,0)
- Posted by SDPringle Nov 03, 2015
- 2097 views
Talking about C99:
I was surprised to see the complex version of 0, in C and C++ yielded one result in this expression where as the real version of 0, in C and C++ yielded a distinct value.
Take power((0,0i),(0,0i)) and you get (nan, nan i) but take power(0,0) and you get 1.
Even among software languages for Mathematicians, 00 is 1 with the exception of Mathematica where you get Indeterminate.
It seems reasonable to me for power(0,0) to return 1, in a language like EUPHORIA.
3. Re: power(0,0)
- Posted by _tom (admin) Nov 03, 2015
- 2044 views
After reviewing http://rosettacode.org/wiki/Zero_to_the_zero_power I have changed Phix to yield 1.
Does anyone here have any strong opinions on the matter?
Testing on oE4.1 I get
can't raise 0 to power <= 0 --> See ex.err
https://www.math.hmc.edu/funfacts/ffiles/10005.3-5.shtml
From the Fun Fact files, here is a Fun Fact at the Easy level: Zero to the Zero Power
It is commonly taught that any number to the zero power is 1, and zero to any power is 0. But if that is the case, what is zero to the zero power?
Well, it is undefined (since xy as a function of 2 variables is not continuous at the origin).
But if it could be defined, what "should" it be? 0 or 1?
Presentation Suggestions: Take a poll to see what people think before you show them any of the reasons below.
The Math Behind the Fact: We'll give several arguments to show that the answer "should" be 1. The alternating sum of binomial coefficients from the n-th row of Pascal's triangle is what you obtain by expanding (1-1)n using the binomial theorem, i.e., 0n. But the alternating sum of the entries of every row except the top row is 0, since 0k=0 for all k greater than 1. But the top row of Pascal's triangle contains a single 1, so its alternating sum is 1, which supports the notion that (1-1)0=00 if it were defined, should be 1. The limit of xx as x tends to zero (from the right) is 1. In other words, if we want the xx function to be right continuous at 0, we should define it to be 1. The expression mn is the product of m with itself n times. Thus m0, the "empty product", should be 1 (no matter what m is). Another way to view the expression mn is as the number of ways to map an n-element set to an m-element set. For instance, there are 9 ways to map a 2-element set to a 3-element set. There are NO ways to map a 2-element set to the empty set (hence 02=0). However, there is exactly one way to map the empty set to itself: use the identity map! Hence 00=1. Here's an aesthetic reason. A power series is often compactly expressed as SUMn=0 to INFINITY an (x-c)n. We desire this expression to evaluate to a0 when x=c, but the n=0 term in the above expression is problematic at x=c. This can be fixed by separating the a0 term (not as nice) or by defining 00=1.
How to Cite this Page: Su, Francis E., et al. "Zero to the Zero Power." Math Fun Facts. <http://www.math.hmc.edu/funfacts>.
From calculus, it has always been 00 = 1 for me . The indeterminate result is some kind of computer science viewpoint.
_tom
4. Re: power(0,0)
- Posted by jimcbrown (admin) Nov 03, 2015
- 2009 views
From calculus, it has always been 00 = 1 for me . The indeterminate result is some kind of computer science viewpoint.
_tom
One can come to the conclusion that this is actually indetermine from a purely mathematical line of reasoning.
In general,
n1 = n / 1 = n
01 = 0 / 1 = 0
And also,
n-1 = 1 / n
n0 = n-1 * n1 = 1 / n * n / 1 = n / n
From this, it follows that
00 = 0-1 * 01 = 0 / 0
And, since anything multiplied by zero is zero, from zero divided by zero you can get anything back out - including 1 - hence it's indeterminate.
5. Re: power(0,0)
- Posted by tinstaafl Nov 15, 2015
- 1942 views
mathematically speaking, what 0/0 evaluates to is a question of *how* U approach zero (i.e., what function is used) for both the numerator and the denominator. practically speaking, i would prefer that Euphoria do what most other languages do. most of the time, i like to stay away from that black hole. ;)
6. Re: power(0,0)
- Posted by jmduro Nov 17, 2015
- 1845 views
According to this discussion, the best answer would be NAN (« Not a Number ») which is defined in IEEE 754 and which is commonly used for such cases.
7. Re: power(0,0)
- Posted by SDPringle Nov 17, 2015
- 1846 views
After reviewing http://rosettacode.org/wiki/Zero_to_the_zero_power I have changed Phix to yield 1.
Does anyone here have any strong opinions on the matter?
Testing on oE4.1 I get
can't raise 0 to power <= 0 --> See ex.err
https://www.math.hmc.edu/funfacts/ffiles/10005.3-5.shtml
From the Fun Fact files, here is a Fun Fact at the Easy level: Zero to the Zero Power
It is commonly taught that any number to the zero power is 1, and zero to any power is 0. But if that is the case, what is zero to the zero power?
Well, it is undefined (since xy as a function of 2 variables is not continuous at the origin).
But if it could be defined, what "should" it be? 0 or 1?
Presentation Suggestions: Take a poll to see what people think before you show them any of the reasons below.
The Math Behind the Fact: We'll give several arguments to show that the answer "should" be 1. The alternating sum of binomial coefficients from the n-th row of Pascal's triangle is what you obtain by expanding (1-1)n using the binomial theorem, i.e., 0n. But the alternating sum of the entries of every row except the top row is 0, since 0k=0 for all k greater than 1. But the top row of Pascal's triangle contains a single 1, so its alternating sum is 1, which supports the notion that (1-1)0=00 if it were defined, should be 1. The limit of xx as x tends to zero (from the right) is 1. In other words, if we want the xx function to be right continuous at 0, we should define it to be 1. The expression mn is the product of m with itself n times. Thus m0, the "empty product", should be 1 (no matter what m is). Another way to view the expression mn is as the number of ways to map an n-element set to an m-element set. For instance, there are 9 ways to map a 2-element set to a 3-element set. There are NO ways to map a 2-element set to the empty set (hence 02=0). However, there is exactly one way to map the empty set to itself: use the identity map! Hence 00=1. Here's an aesthetic reason. A power series is often compactly expressed as SUMn=0 to INFINITY an (x-c)n. We desire this expression to evaluate to a0 when x=c, but the n=0 term in the above expression is problematic at x=c. This can be fixed by separating the a0 term (not as nice) or by defining 00=1.
How to Cite this Page: Su, Francis E., et al. "Zero to the Zero Power." Math Fun Facts. <http://www.math.hmc.edu/funfacts>.
From calculus, it has always been 00 = 1 for me . The indeterminate result is some kind of computer science viewpoint.
_tom
-
One says 00 is a point of discontinuity and another says its limit is one. Hmm... Take the limits
lim x->0 0x = 0. Take this limit lim x->0 x0 = 1. So, if you consider the function (x,y)->xy (in other words power()), it is not continuous at (0,0) but if you fix either one you get two functions that have two different limits at (0,0)!
I cannot imagine a programmer writing a program that needs to calculate power(0,0). I feel equally content with OE returning an error for it.
8. Re: power(0,0)
- Posted by _tom (admin) Nov 17, 2015
- 1808 views
After reviewing http://rosettacode.org/wiki/Zero_to_the_zero_power I have changed Phix to yield 1.
Does anyone here have any strong opinions on the matter?
Approach the Limit
Solve baseexponent when base is zero:
? power( 0.1, 0 ) --> 1 ? power(0.000000000000000000000000000000000000000000000000000000000000000000000000001,0) --> 1
As the base approaches 0 zero the limit is 1 one. As a result some say 00 = 1 . The same people who taught me that the earth was flat--see history of Christopher Columbus--taught me 00= 1 .
At the Limit
The power function is using logarithms to get its result:
include std/math.e atom base, exponent -- trial run {base,exponent} = { 2, 3 } ? power( 10, exponent * log10( base ) ) --> 8 -- test the special case {base,exponent} = { 0, 0 } ? power( 10, exponent * log10( base ) ) --> error -- in function log10() may only take log of a positive number
At the limit we have an undefined case.
Pragmatic Answer
Stick with a crash and error message to give the safest result.
Stick with a crash and error message to give what openEuphoria does.
Stick with a crash and error message to give what my sliderule tells me.