Use of C99 extra long double math functions after r236148

Warner Losh imp at bsdimp.com
Sun Aug 12 22:37:39 UTC 2012


On Jul 16, 2012, at 10:01 PM, Steve Kargl wrote:

> On Mon, Jul 16, 2012 at 10:40:25PM -0500, Stephen Montgomery-Smith wrote:
>> 
>> I came up with pseudo code that looks a bit like this.
>> 
>> complex casinh(complex z) {
>>  double x = z.re, y = z.im;
>> 
>>  if (y==0)
>>    return asinh(x);
>>  if (x==0) {
>>    if (fabs(y)<=1) return I*asin(y);
>>    else return signum(y)* (
>>      log(fabs(y)+sqrt(y*y-1))
>>      + I*PI/2);
> 
> Stop.  Please see msun/src/math_private.h. You cannot
> use I in any expression.  gcc in base and clang do not
> do the arithmetic correctly.  See msun/src/s_ccosh.c
> for how one might approach writing these functions.
> Also, consult n1256.pdf for x,y = +-0, +-inf, nan. 
> There are specific requirements that must be met.

Yes.  Pseudo code is OK for following the flow, but look at the exp code for why that's not entirely sufficient.  You have to be extremely fussy about all kinds of things.  Then again, exp is a lot more important to get right than the complex trig functions...

The pseudo code is a good place to start, but it just the barest start in the integration process...

Warner




More information about the freebsd-numerics mailing list