Use of C99 extra long double math functions after r236148
Bruce Evans
brde at optusnet.com.au
Sun Aug 12 23:13:50 UTC 2012
On Thu, 19 Jul 2012, Bruce Evans wrote:
> On Wed, 18 Jul 2012, Stephen Montgomery-Smith wrote:
>
>> I went on a long road trip yesterday, so I didn't get any code written, but
>> I did have a lot of thoughts about clog and casinh.
>>
>> First, the naive formula (here z=x+I*y)
>> clog(z) = cpack(log(hypot(x,y)),atan2(x,y))
>> is going to work in a lot more edge cases then one might expect. This is
>> because hypot and atan2, especially atan2, already do a rather good job
>> getting the edge cases right. I am thinking in particular of when x or y
>> are 0 or -0, or one of them is infinity or -infinity.
>
> Right, clog is deceptively simple. This is because it decomposes perfectly
> into 2 real functions of 2 real variables and both of these functions are
> standard and already implemented almost as well as possible. ISTR das
> saying that it had a complicated case, but I don't see even one. atan2()
Duh, I forget that log() must be applied to hypot(). You found the
surprisingly large inaccuracies from (too-?) simple avoidance of
overflow in hypot() soon after I first replied. Is there a problem
even without overflow? I think log contracts any errors in hypot()
so there isn't, but then why doesn't it contract any error in the
overflow avoidance?
Bruce
More information about the freebsd-numerics
mailing list