I think that (2) is the easiest for a user to understand.  Obviously, the
documentation aspect of (1) should be brought along.

The behavior of Common Lisp is always instructive in these regards.  The
complex arithmetic was generally very well thought out.

On Fri, Jan 2, 2009 at 7:14 PM, Phil Steitz <phil.ste...@gmail.com> wrote:

>  ... I noticed another thing.   Behavior for complex numbers with NaN and
>> infinite parts is, well, "interesting."  It is consistent with what we do
>> elsewhere in this class to just apply computational formulas and document
>> behavior for infinite and NaN; but the current implementation is hard to
>> document correctly and the results are a little strange for infinite values.
>>
>> I see three reasonable choices here, and am interested in others'
>> opinions.  Please select from the following or suggest something else.
>>
>> 1) Leave as is and just point out that the computational formula will
>> behave strangely for infinite values.
>>
>> 2) return {Complex.NaN} or {Complex.INF} respectively when the number has
>> a NaN or infinite part.
>>
>> 3) return {Complex.NaN} when either part is NaN; but for infinite values,
>> compute the argument using getArgument (atan2), generate the arguments for
>> the roots from this and select the real/im parts of the roots from {0, inf,
>> -inf} to match the argument (this will always be possible because atan2
>> always returns a multiple of pi/4 for infinite arguments).  For example, the
>> 4th roots of real positive infinity would be {inf + 0i, 0 + infi, -inf + 0i,
>> 0 + -infi}
>>
>> 2) is probably the most defensible mathematically; but 3) is closer to the
>> spirit of C99x.  Unfortunately, since our implementation of multiply is
>> 2)-like, 3) does not guarantee that nth roots actually solve the equation
>> r^n = z.
>>
>> Phil
>>
> Sorry, just realized that 3) will not work in general, so choice is 1),  2)
>  or a better idea.
>
>
> Phil
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
> For additional commands, e-mail: dev-h...@commons.apache.org
>
>


-- 
Ted Dunning, CTO
DeepDyve
4600 Bohannon Drive, Suite 220
Menlo Park, CA 94025
www.deepdyve.com
650-324-0110, ext. 738
858-414-0013 (m)

Reply via email to