Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 Sep 2012 02:51:24 +1000 (EST)
From:      Bruce Evans <brde@optusnet.com.au>
To:        Stephen Montgomery-Smith <stephen@missouri.edu>
Cc:        freebsd-numerics@FreeBSD.org
Subject:   Re: Complex arg-trig functions
Message-ID:  <20120917022614.R2943@besplex.bde.org>
In-Reply-To: <5055ECA8.2080008@missouri.edu>
References:  <5017111E.6060003@missouri.edu> <50297E43.7090309@missouri.edu> <20120814201105.T934@besplex.bde.org> <502A780B.2010106@missouri.edu> <20120815223631.N1751@besplex.bde.org> <502C0CF8.8040003@missouri.edu> <20120906221028.O1542@besplex.bde.org> <5048D00B.8010401@missouri.edu> <504D3CCD.2050006@missouri.edu> <504FF726.9060001@missouri.edu> <20120912191556.F1078@besplex.bde.org> <20120912225847.J1771@besplex.bde.org> <50511B40.3070009@missouri.edu> <20120913204808.T1964@besplex.bde.org> <5051F59C.6000603@missouri.edu> <20120914014208.I2862@besplex.bde.org> <50526050.2070303@missouri.edu> <20120914212403.H1983@besplex.bde.org> <50538E28.6050400@missouri.edu> <20120915231032.C2669@besplex.bde.org> <50548E15.3010405@missouri.edu> <5054C027.2040008@missouri.edu> <5054C200.7090307@missouri.edu> <20120916041132.D6344@besplex.bde.org> <50553424.2080902@missouri.edu> <20120916134730.Y957@besplex.bde.org> <5055ECA8.2080008@missouri.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 16 Sep 2012, Stephen Montgomery-Smith wrote:

> On 09/16/2012 12:14 AM, Bruce Evans wrote:
>> On Sat, 15 Sep 2012, Stephen Montgomery-Smith wrote:
>> 
>>> One more thing I would like an opinion on.
>>> 
>>> In my code I check for |z| being small, and then use the approximations:
>>> casinh(z) = z
>>> cacos(z) = Pi - z
>> 
>> Actually Pi/2 - z.
>> 
>>> catanh(z) = z
>>> 
>>> However these approximations are not used in the papers by Hull et al,
>>> and the code works just fine if I don't include these in the code.
>> 
>> Probably a bug in the papers.
>
> It is not a bug in the papers.  The algorithms they provide really do work 
> when |z| is small.  In fact, you have to deal separately with the cases |x| 
> is small and |y| is small (z=x+I*y), so dealing with both of them being small 
> is not any additional problem.
>
> And now I see your other post, that using PI/2 is problematic especially when 
> rounding is not to nearest.  (Then the problem of rounding PI/2 properly is 
> relegated to the acos function, and so it is someone else's problem.)
>
> So all things being said and done, I am going to remove the use of these 
> approximations.

I don't like that.  It will be much slower on almost 1/4 of arg space.
The only reason to consider not doing it is that the args that it
applies to are not very likely, and optimizing for them may pessimize
the usual case.

I just found a related optimization for atan2().  For x > 0 and
|y|/x < 2**-(MANT_DIG+afew), atan2(y, x) is evaluated as essentially
sign(y) * atan(|y|/x).  But in this case, its value is simply y/x
with inexact.  Again the optimization applies to almost 1/4 of arg
space.  It gains more than the normal overhead of an atan() call by
avoiding secondary underflows when y/x underflows.

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120917022614.R2943>