Mark Dickinson added the comment:

Well, C99 covers pow for *real* numbers just fine;  it's complex numbers where 
no-one wants to pin down what the behaviour should be.  So I don't think we 
need the man page reference.

If we're writing tests for complex pow, we might also want to consider adding 
tests for multiplication and division;  those aren't entirely trivial either 
for special cases.

I do agree that (for the most part), complex pow applied to arguments with zero 
imaginary part should behave like regular float pow.  There are some cases 
where it's clear what the behaviour should be, and others that are murkier.

E.g., for a positive real z and arbitrary complex w, the special cases for z**w 
should behave in the same way as for exp for z > 0, and with some reflection of 
that behaviour for 0 < z < 1;  1**w should always be 1.

For nonzero finite values it's straightforward:  we just want to compute the 
best approximation to exp(w * log(z)), with the branch cut for the log along 
the negative real axis as usual.

But there are a *lot* of special cases to think about.  Consider that each real 
or imaginary part of the input is either:

(1) -infinity,
(2) -finite,
(3) -0.0
(4) +0.0
(5) +finite
(6) +infinity
(7) nan

and that we've got 2 complex inputs, or in effect 4 real inputs.  This divides 
our argument space into 7**4 = 2401 pieces.  With luck we can find rules that 
cover lots of those pieces at once, but it's still going to be a long job.

It doesn't help that it isn't particularly clear what the underlying 
mathematical model should be.  For floats, we can think about the two-point 
compactification of the real line (okay, with a doubled zero, which messes 
things up a little bit), which is a fairly sane space to work in.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue15996>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to