From owner-freebsd-numerics@FreeBSD.ORG Sun Aug 12 23:05:57 2012 Return-Path: Delivered-To: freebsd-numerics@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 41FBD106566B for ; Sun, 12 Aug 2012 23:05:57 +0000 (UTC) (envelope-from peter@rulingia.com) Received: from vps.rulingia.com (host-122-100-2-194.octopus.com.au [122.100.2.194]) by mx1.freebsd.org (Postfix) with ESMTP id CF8CB8FC15 for ; Sun, 12 Aug 2012 23:05:56 +0000 (UTC) Received: from server.rulingia.com (c220-239-249-137.belrs5.nsw.optusnet.com.au [220.239.249.137]) by vps.rulingia.com (8.14.5/8.14.5) with ESMTP id q7CN5uOB075694 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 13 Aug 2012 09:05:56 +1000 (EST) (envelope-from peter@rulingia.com) X-Bogosity: Ham, spamicity=0.000000 Received: from server.rulingia.com (localhost.rulingia.com [127.0.0.1]) by server.rulingia.com (8.14.5/8.14.5) with ESMTP id q7CN5oqF021321 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 13 Aug 2012 09:05:50 +1000 (EST) (envelope-from peter@server.rulingia.com) Received: (from peter@localhost) by server.rulingia.com (8.14.5/8.14.5/Submit) id q7CN5oBK021320 for freebsd-numerics@freebsd.org; Mon, 13 Aug 2012 09:05:50 +1000 (EST) (envelope-from peter) Resent-From: Peter Jeremy Resent-Date: Mon, 13 Aug 2012 09:05:50 +1000 Resent-Message-ID: <20120812230550.GT20453@server.rulingia.com> Resent-To: freebsd-numerics@freebsd.org Received: from vps.rulingia.com (host-122-100-2-194.octopus.com.au [122.100.2.194]) by server.rulingia.com (8.14.5/8.14.5) with ESMTP id q6H4vAX0070417 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 17 Jul 2012 14:57:11 +1000 (EST) (envelope-from stephen@missouri.edu) Received: from wilberforce.math.missouri.edu (wilberforce.math.missouri.edu [128.206.184.213]) by vps.rulingia.com (8.14.5/8.14.5) with ESMTP id q6H4v8SO065998 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 17 Jul 2012 14:57:10 +1000 (EST) (envelope-from stephen@missouri.edu) Received: from [127.0.0.1] (wilberforce.math.missouri.edu [128.206.184.213]) by wilberforce.math.missouri.edu (8.14.5/8.14.5) with ESMTP id q6H4uj4S025077; Mon, 16 Jul 2012 23:56:46 -0500 (CDT) (envelope-from stephen@missouri.edu) Message-ID: <5004F08E.4040501@missouri.edu> From: Stephen Montgomery-Smith Mail-Followup-To: freebsd-numerics@freebsd.org User-Agent: Mozilla/5.0 (X11; Linux i686; rv:13.0) Gecko/20120615 Thunderbird/13.0.1 MIME-Version: 1.0 To: Warner Losh References: <20120711223247.GA9964@troutmask.apl.washington.edu> <20120713114100.GB83006@server.rulingia.com> <201207130818.38535.jhb@freebsd.org> <9EB2DA4F-19D7-4BA5-8811-D9451CB1D907@theravensnest.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> In-Reply-To: <6F750F84-34FF-4961-A2EA-F3E67A6872AE@bsdimp.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Diane Bruce , Steve Kargl , John Baldwin , David Chisnall , Bruce Evans , Bruce Evans , David Schultz , Peter Jeremy Subject: Re: Use of C99 extra long double math functions after r236148 X-BeenThere: freebsd-numerics@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussions of high quality implementation of libm functions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Date: Sun, 12 Aug 2012 23:05:57 -0000 X-Original-Date: Mon, 16 Jul 2012 23:56:46 -0500 X-List-Received-Date: Sun, 12 Aug 2012 23:05:57 -0000 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.