From owner-freebsd-numerics@FreeBSD.ORG Sun Aug 12 23:09:45 2012 Return-Path: Delivered-To: freebsd-numerics@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 001CB1065678 for ; Sun, 12 Aug 2012 23:09:44 +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 7869B8FC08 for ; Sun, 12 Aug 2012 23:09:44 +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 q7CN9iht075795 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 13 Aug 2012 09:09:44 +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 q7CN9big021554 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 13 Aug 2012 09:09:38 +1000 (EST) (envelope-from peter@server.rulingia.com) Received: (from peter@localhost) by server.rulingia.com (8.14.5/8.14.5/Submit) id q7CN9bBf021553 for freebsd-numerics@freebsd.org; Mon, 13 Aug 2012 09:09:37 +1000 (EST) (envelope-from peter) Resent-From: Peter Jeremy Resent-Date: Mon, 13 Aug 2012 09:09:37 +1000 Resent-Message-ID: <20120812230937.GP20453@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 q6JIdJod019066 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 20 Jul 2012 04:39:20 +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 q6JIdHg0082003 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 20 Jul 2012 04:39:19 +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 q6JIcvP1053673; Thu, 19 Jul 2012 13:38:57 -0500 (CDT) (envelope-from stephen@missouri.edu) Message-ID: <50085441.4090305@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: 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> In-Reply-To: <20120720035001.W4053@besplex.bde.org> Content-Type: multipart/mixed; boundary="------------010001010601030602040403" 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:09:45 -0000 X-Original-Date: Thu, 19 Jul 2012 13:38:57 -0500 X-List-Received-Date: Sun, 12 Aug 2012 23:09:45 -0000 This is a multi-part message in MIME format. --------------010001010601030602040403 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 07/19/2012 01:12 PM, Bruce Evans wrote: > On Thu, 19 Jul 2012, Stephen Montgomery-Smith wrote: > >> I have the ULP down to about 1.2 now. I don't see how I can do >> better, because I have to invoke log functions twice, and probably >> each one has a ULP of about 0.6. >> >> Also I decided to use 1/2 log(x*x+y*y) when x and y are not too large. > > That's close to Apple complex.c clog(). Once you don't use hypot(), > it is clearly best to use log1p(): > > log(sqrt(x*x + y*y)) = log(|x|) + 1/2 log(1 + (y*y)/(x*x)) > = log(|x|) + 1/2 log1p((y*y)/(x*x)) > > where |x| >= |y| so that log1p()'s arg is as small as possible. > >> I am really rather proud of how I got around the large ULP when >> hypot(x,y) is close to 1. I would be glad if any of you could look at >> the code when you get a chance. > > WIll look more closely later. I see that you already use log1p() and much > more. Apple clog() uses not so much more, mainly by depending on extra > precision in hardware. The above also avoids overflow and use of hypot() > for all finite x and and y, but is probably too simple. I think their solution merely avoids the overflow/underflow problem, and was not meant to address the problem I worked on. However, their solution will fail if y=1e100 and y=1e-100. This caused me to realize that my solution failed to account for underflow, so here is my next iteration. --------------010001010601030602040403--