Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 12 Aug 2012 22:37:39 -0000
From:      Warner Losh <imp@bsdimp.com>
To:        Steve Kargl <sgk@troutmask.apl.washington.edu>
Cc:        Diane Bruce <db@db.net>, John Baldwin <jhb@freebsd.org>, David Chisnall <theraven@freebsd.org>, Stephen Montgomery-Smith <stephen@missouri.edu>, Bruce Evans <bde@freebsd.org>, Bruce Evans <brde@optusnet.com.au>, David Schultz <das@freebsd.org>, Peter Jeremy <peter@rulingia.com>
Subject:   Re: Use of C99 extra long double math functions after r236148
Message-ID:  <6F750F84-34FF-4961-A2EA-F3E67A6872AE@bsdimp.com>
Resent-Message-ID: <20120812223731.GD20453@server.rulingia.com>
In-Reply-To: <20120717040118.GA86840@troutmask.apl.washington.edu>
References:  <20120711223247.GA9964@troutmask.apl.washington.edu> <20120713114100.GB83006@server.rulingia.com> <201207130818.38535.jhb@freebsd.org> <9EB2DA4F-19D7-4BA5-8811-D9451CB1D907@theravensnest.org> <C527B388-3537-406F-BA6D-2FA45B9EAA3B@FreeBSD.org> <20120713155805.GC81965@zim.MIT.EDU> <20120714120432.GA70706@server.rulingia.com> <20120717084457.U3890@besplex.bde.org> <5004A5C7.1040405@missouri.edu> <5004DEA9.1050001@missouri.edu> <20120717040118.GA86840@troutmask.apl.washington.edu>

next in thread | previous in thread | raw e-mail | index | archive | help

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





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6F750F84-34FF-4961-A2EA-F3E67A6872AE>