Complex arg-trig functions
Bruce Evans
brde at optusnet.com.au
Tue Sep 18 06:41:57 UTC 2012
On Mon, 17 Sep 2012, Stephen Montgomery-Smith wrote:
> On 09/17/2012 05:50 PM, Stephen Montgomery-Smith wrote:
>
>>> cacos*() and casin*() should benefit even more from an up-front raising
>>> of inexact, since do_hard_work() has 7 magic statements to raise inexact
>>> where sum_squares has only 1.
>>
>> Where is the code that raises inexact up-front?
>
> I don't see why having code upfront will make it much more efficient. Out of
> these 7 magic statements, at most two of them will be called.
7 instead of 1 is more complex, and uses more branch prediction resources.
> But I could put something like
>
> if ((x == 0 && y == 0) || (x == 0 && y == 1) || (int)(1+tiny) == 1) {
> ........
> at the beginning of do_hard_work and catanh.
I put without (x == 0 && y == 1) in catanh(). (x == 0 && y == 1) in it
is a bug, since catanh(I) = I*Pi/2 with inexact. However, I seemed to
have missed (x == 1 && y == 0) -> catanh(1) = +Inf without inexact.
do_hard_work() is too late for this, since the following earlier cases
also need it:
- large x or y (neither infinite)
- small x and y (not both 0, except for acosh(0) = Pi/2 with inexact, etc.)
(the lost optimization).
> OK, I think I made changes more or less according to your suggestions.
>
> In the case A < A_crossover, a threshold like DBL_EPSILON*DBL_EPSILON/128 is
> required. I think the one you set is too large. It is important that
> sqrt(x) + x/2 is sqrt(x). (Again I don't think your tests would pick this
> up, because you need to do a lot of tests where y is close to or equal to 1.)
Well, there were 2**12 of them with y = 1+denormal, with 7 different
denormals, but none with y = 1. Will test some more. (I'm testing
denormals with a few 1's in their lower bits since experience shows
that values with 0's in their lower bits are too special. For example,
ax*ax is exact if enough lower bits in ax are 0.)
Bruce
More information about the freebsd-numerics
mailing list