From owner-freebsd-numerics@FreeBSD.ORG Mon Aug 13 00:32:26 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 49A0A106567E for ; Mon, 13 Aug 2012 00:32:26 +0000 (UTC) (envelope-from stephen@missouri.edu) Received: from wilberforce.math.missouri.edu (wilberforce.math.missouri.edu [128.206.184.213]) by mx1.freebsd.org (Postfix) with ESMTP id 0A15E8FC14 for ; Mon, 13 Aug 2012 00:32:25 +0000 (UTC) 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 q7D0WO6I085447 for ; Sun, 12 Aug 2012 19:32:24 -0500 (CDT) (envelope-from stephen@missouri.edu) Message-ID: <50284B19.3000307@missouri.edu> Date: Sun, 12 Aug 2012 19:32:25 -0500 From: Stephen Montgomery-Smith User-Agent: Mozilla/5.0 (X11; Linux i686; rv:14.0) Gecko/20120714 Thunderbird/14.0 MIME-Version: 1.0 To: freebsd-numerics@freebsd.org References: <20120717225328.GA86902@server.rulingia.com> <20120717232740.GA95026@troutmask.apl.washington.edu> <20120718001337.GA87817@server.rulingia.com> <20120718123627.D1575@besplex.bde.org> <20120722121219.GC73662@server.rulingia.com> <500DAD41.5030104@missouri.edu> <20120724113214.G934@besplex.bde.org> <501204AD.30605@missouri.edu> <20120727032611.GB25690@server.rulingia.com> <50121124.4000002@missouri.edu> <20120727052006.GB92860@night.db.net> In-Reply-To: <20120727052006.GB92860@night.db.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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: , X-List-Received-Date: Mon, 13 Aug 2012 00:32:26 -0000 On 07/27/2012 12:20 AM, Diane Bruce wrote: > I was very curious about that. Any chance of running that test harness > against the NetBSD routines? At least if we are very late we are very > much better. ;-) I just looked at the code used in NetBSD. The code is rather simple, and no effort is made to avoid large numerical errors, nor to manage the edge cases: https://www-asim.lip6.fr/trac/netbsdtsar/browser/vendor/netbsd/5/src/lib/libm/complex/cacosh.c?rev=2 https://www-asim.lip6.fr/trac/netbsdtsar/browser/vendor/netbsd/5/src/lib/libm/complex/cacos.c?rev=2 https://www-asim.lip6.fr/trac/netbsdtsar/browser/vendor/netbsd/5/src/lib/libm/complex/casin.c?rev=2 casin is like my proposed pseudo-code, which I realize is numerically unstable if |Re(z)| <= 1 and Im(z) is close to zero. cacos(z) = Pi/2 - casin(z), which is subtracting two nearly equal quantities if z is close to 1. cacosh computes the wrong branch: it should be sign(Im(z))*I*cacos(z). clog is essentially log(cabs(z)) + I*arg(z), which can have a relative error close to infinity if |z|=1. So I think we can do better.