From owner-freebsd-numerics@FreeBSD.ORG Sun Aug 12 23:11:33 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 EF743106566B for ; Sun, 12 Aug 2012 23:11:32 +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 0EF438FC0A for ; Sun, 12 Aug 2012 23:11:31 +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 q7CNBVAD075887 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 13 Aug 2012 09:11:32 +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 q7CNBPa4021751 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 13 Aug 2012 09:11:25 +1000 (EST) (envelope-from peter@server.rulingia.com) Received: (from peter@localhost) by server.rulingia.com (8.14.5/8.14.5/Submit) id q7CNBPLT021750 for freebsd-numerics@freebsd.org; Mon, 13 Aug 2012 09:11:25 +1000 (EST) (envelope-from peter) Resent-From: Peter Jeremy Resent-Date: Mon, 13 Aug 2012 09:11:25 +1000 Resent-Message-ID: <20120812231125.GL20453@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 q6M1bp7V055103 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 22 Jul 2012 11:37:51 +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 q6M1bkNJ004462 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sun, 22 Jul 2012 11:37:48 +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 q6M1bHfY099640; Sat, 21 Jul 2012 20:37:17 -0500 (CDT) (envelope-from stephen@missouri.edu) Message-ID: <500B594D.1020305@missouri.edu> From: Stephen Montgomery-Smith Mail-Followup-To: freebsd-numerics@freebsd.org User-Agent: Mozilla/5.0 (X11; Linux i686; rv:14.0) Gecko/20120714 Thunderbird/14.0 MIME-Version: 1.0 To: Bruce Evans References: <20120714120432.GA70706@server.rulingia.com> <20120717084457.U3890@besplex.bde.org> <5004A5C7.1040405@missouri.edu> <5004DEA9.1050001@missouri.edu> <20120717200931.U6624@besplex.bde.org> <5006D13D.2080702@missouri.edu> <20120718205625.GA409@troutmask.apl.washington.edu> <500725F2.7060603@missouri.edu> <20120719025345.GA1376@troutmask.apl.washington.edu> <50077987.1080307@missouri.edu> <20120719032706.GA1558@troutmask.apl.washington.edu> <5007826D.7060806@missouri.edu> <5007AD41.9070000@missouri.edu> <20120719205347.T2601@besplex.bde.org> <50084322.7020401@missouri.edu> <20120720035001.W4053@besplex.bde.org> <50085441.4090305@missouri.edu> <20120720162953.N2162@besplex.bde.org> <20120720184114.B2790@besplex.bde.org> <50097128.6030405@missouri.edu> <20120721032448.X5744@besplex.bde.org> <5009BD6C.9050301@missouri.edu> <20120721123522.T877@besplex.bde.org> <500A2565.9090009@missouri.edu> <20120721181204.A1702@besplex.bde.org> In-Reply-To: <20120721181204.A1702@besplex.bde.org> Content-Type: multipart/mixed; boundary="------------070704010607090802070100" X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: Diane Bruce , John Baldwin , David Chisnall , Bruce Evans , Steve Kargl , David Schultz , Peter Jeremy , Warner Losh 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:11:33 -0000 X-Original-Date: Sat, 21 Jul 2012 20:37:17 -0500 X-List-Received-Date: Sun, 12 Aug 2012 23:11:33 -0000 This is a multi-part message in MIME format. --------------070704010607090802070100 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Three things. 1. I think I now understand the casinh algorithm by Hull et al rather well. I implemented it in the attached code. Bruce, could you try it out against pari? It did compare rather well to Mathematica's ArcSinh function. I tested it mostly near the branch cut ends at I and -I. (The branch cut's behavior is somewhat similar to that of sqrt.) After this, I think getting casin, cacos and cacosh should be relatively straightforward. The hardest thing about cacos and cacosh will be figuring out where all the branch cuts and discontinuities are. I also worked quite hard to avoid underflows and overflows from happening. But I need to go through it again several times to check that the logic really works. 2. I have thought more about the problem of computing clog(z) when |z| is close to 1. I now think it might even require precision that is 3 times better than double precision. It is possible that you could, by chance, pick x and y so that |z| = 1 + 1e30. (I wrote a test program, and this did actually happen a few times.) So when you compute x^2+y^2-1, if you do it using double double precision, you will get 2e30, but only the most significant digits will be accurate. The ULP will be about 1e15. You need triple double precision to get ULP's close to 1. And I cannot even figure out how to do log(1+z) when z is close to 0! The trouble is, (1+x)^2+y^2-1 = 2x+x^2+y^2, and if x is negative and approximately -y^2, you are in the situation of subtracting nearly equal numbers! (Obviously if z is very close to 0, I could use Taylor's series.) 3. I haven't learned proper style yet. (Is it what you call KNF?) I have always had a distrust of consistency, especially when it comes to people's coding styles. Sorry, but this is going to be a bit painful for me. Stephen --------------070704010607090802070100--