# New Ticket Created by  Sam S. 
# Please include the string:  [perl #128785]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=128785 >


Perl 6 agrees with pretty much all programming languages that 0**0 == 1, and 
does so consistently for the Int, int, Rat, FatRat, and Num types.

Just the Complex type doesn't play along:

    ➜  say (0+0i) ** 0;
    NaN+NaN\i

    ➜  say (0+0i) ** (0+0i);
    0+0i

I think these should both of these print 1+0i.


------ Mathematical background: ------

The value of "Zero to the power of zero" seems to be a historically 
controversial topic in mathematics: 
https://en.wikipedia.org/wiki/Exponentiation#Zero_to_the_power_of_zero

>From that wiki article I gather that (0**0 == 1) is popular among those 
>working with practical formulae and actual values, and (0**0 == undefined) 
>popular among those focusing theoretical considerations about limits. 
>Unsurprisingly, programming languages have sided with the former definition...

In any case, I don't see a reason to treat Complex differently from the other 
numeric types.
In fact, isn't the whole idea of complex numbers, to be a generalization of 
real numbers so that as long as the imaginary part is 0, you get the exact same 
results as with real numbers?

Then again, I'm not a mathematician. Input from an expert would be appreciated.


------ Other programming languages: ------

The ones I checked, seem to agree with my line of thought:

Perl 5:

    $ perl -E 'use Math::Complex;  say cplx(0,0) ** 0;'
    1
    $ perl -E 'use Math::Complex;  say cplx(0,0) ** cplx(0,0);'
    1

Ruby:

    $ ruby -e 'puts Complex(0,0) ** 0'           
    1+0i
    $ ruby -e 'puts Complex(0,0) ** Complex(0,0)'
    1+0i

Python:

    $ python
    >>> print((0+0j) ** 0)
    (1+0j)
    >>> print((0+0j) ** (0+0j))
    (1+0j)

For more examples, see: http://rosettacode.org/wiki/Zero_to_the_zero_power

Reply via email to