From owner-freebsd-numerics@FreeBSD.ORG Tue Aug 14 18:40: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 07575106566C for ; Tue, 14 Aug 2012 18:40:33 +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 B91168FC17 for ; Tue, 14 Aug 2012 18:40:27 +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 q7EIePQ4050088 for ; Tue, 14 Aug 2012 13:40:25 -0500 (CDT) (envelope-from stephen@missouri.edu) Message-ID: <502A9B99.7090309@missouri.edu> Date: Tue, 14 Aug 2012 13:40: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: <5017111E.6060003@missouri.edu> <501C361D.4010807@missouri.edu> <20120804165555.X1231@besplex.bde.org> <501D51D7.1020101@missouri.edu> <20120805030609.R3101@besplex.bde.org> <501D9C36.2040207@missouri.edu> <20120805175106.X3574@besplex.bde.org> <501EC015.3000808@missouri.edu> <20120805191954.GA50379@troutmask.apl.washington.edu> <20120807205725.GA10572@server.rulingia.com> <20120809025220.N4114@besplex.bde.org> <5027F07E.9060409@missouri.edu> <20120814003614.H3692@besplex.bde.org> <50295887.2010608@missouri.edu> <20120814055931.Q4897@besplex.bde.org> <50297468.20902@missouri.edu> <20120814173931.V934@besplex.bde.org> <502A820C.6060804@missouri.edu> <502A8494.2050707@missouri.edu> In-Reply-To: <502A8494.2050707@missouri.edu> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: Complex arg-trig functions 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: Tue, 14 Aug 2012 18:40:33 -0000 I was thinking more about the formulas of the type casinhl(z) = clogl(z+csqrtl(z^2+1)). It seems to be far more inaccurate than I originally thought. mpc uses this method, and it tries to adjust the number of bits it uses until it get the right answer. If you give it something like z = 1L + 1e-3000L*I, mpc takes an extraordinarily large amount of time to do the calculation (it is worse for acos than for asin). I added some printf statements to the code for mpc. To calculate to 100 bits, mpc is sometimes using a precision of 7000 bits for its internal calculations. Also, for its acos and atan functions, it tries it with a certain number of bits, then adds a small number to the precision, and tries again. With asin, it at least multiples the precision by 1.5 with each retry. I adjusted the code so that acos and atan do the same as asin, and now it goes very much faster. But they would still be better off using the Hull, Fairgrieve and Tang algorithm, which seems to be very superior. And in their case they wouldn't have to worry about underflow and overflow. I also looked at Mathematica. It doesn't seem to use the above formula. But whatever it does use, it is only marginally better.