Result of 0^0

Report problems with documented functionality
User avatar
Brazolek123
Posts: 187
Joined: 06 Jun 2016, 16:02

Result of 0^0

08 Apr 2018, 08:46

Not sure if its intentional, bug or whether is it important or not, but:

Code: Select all

msgbox % 0**0
Returns 0.

It's mathematically ambiguous but almost all of the programming languages or math engines treat it as 1.
What you think?
joefiesta
Posts: 497
Joined: 24 Jan 2016, 13:54
Location: Pa., USA

Re: Result of 0^0

08 Apr 2018, 09:23

I found it very interesting that you called it "ambiguous". That is, until I researched it. I never realized it could be considered anything but 1. See: https://en.wikipedia.org/wiki/Zero_to_the_power_of_zero
Since algebra, calculus and most other branches of mathematics require (define?) 0**0 be 1, and since it is the generally and widely accepted value for computational purposes, I see it as a bug. While 0**0 may be useful as 0 in mathematical analysis ("Mathematical analysis is the branch of mathematics dealing with limits and related theories, such as differentiation, integration, measure, infinite series, and analytic functions", from https://en.wikipedia.org/wiki/Mathematical_analysis), the purposes of mathematical functions in AutohotKey are all algebraic.

You will find much discussion of this (rather interesting) topic online. It has been argued for centuries. But, AHK should keep in line with all other modern computational programming languages.
joefiesta
Posts: 497
Joined: 24 Jan 2016, 13:54
Location: Pa., USA

Re: Result of 0^0

08 Apr 2018, 09:27

I found a very simplified argument for 0**0 = 1 (from: http://scienceline.ucsb.edu/getkey.php?key=2626 ) it is the essentially the most frequently and easiest to understand logic behind the reason.

Any number to the zero power always gives one.

One rule for exponents is that exponents add when you have the same base. So if you have a number, x, and exponents, a and b, then:
xa * xb = x(a+b)
So then if we make one of the exponents negative:xa * x-b = x(a-b)
And if the exponents are the same magnitude (a = b)xa * x-b = xa * x-a = x(a-a) = x0

Now, remember that if you have a negative exponent, it means you have one divided by the number to the exponent:
x-a = 1/xa
So, we can also write xa * x-a in a different way:
xa * x-a = xa * 1/xa = xa/xa
And a number divided by itself is always 1 so:
xa * x-a = xa* 1/xa = xa/xa = 1:
So now we've shown that:
xa * x-a = x(a-a) = x0
and
xa * x-a = xa * 1/xa:
This means that any number x0 = 1.

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 10 guests