Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 12 Aug 2012 23:05:57 -0000
From:      Stephen Montgomery-Smith <stephen@missouri.edu>
To:        Warner Losh <imp@bsdimp.com>
Cc:        Diane Bruce <db@db.net>, Steve Kargl <sgk@troutmask.apl.washington.edu>, John Baldwin <jhb@freebsd.org>, David Chisnall <theraven@freebsd.org>, 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:  <5004F08E.4040501@missouri.edu>
Resent-Message-ID: <20120812230550.GT20453@server.rulingia.com>
In-Reply-To: <6F750F84-34FF-4961-A2EA-F3E67A6872AE@bsdimp.com>
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> <6F750F84-34FF-4961-A2EA-F3E67A6872AE@bsdimp.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 07/16/2012 11:12 PM, 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...
>
> Warner

OK, I'll have a go at making it proper code.  But before I can do that, 
I notice that we don't have a clog function.  The pseudo code is obvious:

return log(hypot(z.re,z.im)) + I*atan2(z.re,z.im)

so this will give me good practice at getting the difficult stuff correct.

Give me a while, because I can see this isn't going to be totally 
straightforward.  I'm going to have questions as I start going through this.



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