Use of C99 extra long double math functions after r236148

Steve Kargl sgk at troutmask.apl.washington.edu
Sun Aug 12 23:05:19 UTC 2012


On Mon, Jul 16, 2012 at 10:12:21PM -0600, Warner Losh wrote:
> 
> 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...

I can't tell whether you agree with my urging of caution or whether
your being sarcastic.  The pseudo-code as written simply does not
apply once one looks at n1256.pdf.

-- 
Steve


More information about the freebsd-numerics mailing list