From owner-freebsd-numerics@FreeBSD.ORG Sun Aug 12 23:12:01 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 DCCC81065676 for ; Sun, 12 Aug 2012 23:12:01 +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 49BCF8FC08 for ; Sun, 12 Aug 2012 23:12:01 +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 q7CNC1q8075905 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 13 Aug 2012 09:12:01 +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 q7CNBsZC021784 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 13 Aug 2012 09:11:54 +1000 (EST) (envelope-from peter@server.rulingia.com) Received: (from peter@localhost) by server.rulingia.com (8.14.5/8.14.5/Submit) id q7CNBs8N021783 for freebsd-numerics@freebsd.org; Mon, 13 Aug 2012 09:11:54 +1000 (EST) (envelope-from peter) Resent-From: Peter Jeremy Resent-Date: Mon, 13 Aug 2012 09:11:54 +1000 Resent-Message-ID: <20120812231154.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 q6MJaqO4006711 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 23 Jul 2012 05:36:52 +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 q6MJanqZ009529 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 23 Jul 2012 05:36:51 +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 q6MJaSsf070184; Sun, 22 Jul 2012 14:36:29 -0500 (CDT) (envelope-from stephen@missouri.edu) Message-ID: <500C563D.9000605@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: Steve Kargl References: <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> <500B594D.1020305@missouri.edu> <20120722125300.P2246@besplex.bde.org> <500C1B1A.5070107@missouri.edu> <20120722172119.GA83243@troutmask.apl.washington.edu> In-Reply-To: <20120722172119.GA83243@troutmask.apl.washington.edu> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Diane Bruce , John Baldwin , David Chisnall , Bruce Evans , Bruce Evans , 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:12:02 -0000 X-Original-Date: Sun, 22 Jul 2012 14:36:29 -0500 X-List-Received-Date: Sun, 12 Aug 2012 23:12:02 -0000 On 07/22/2012 12:21 PM, Steve Kargl wrote: > On Sun, Jul 22, 2012 at 10:24:10AM -0500, Stephen Montgomery-Smith wrote: >> >> mpfr is OK, but terribly cludgy. > > I almost chocked on my coffee reading this statement. > >> Having it compute clog is easy. But >> having it computing casinh is going to be very painful. If I cannot use >> pari, I will probably use C++ code based around a floating point package >> called cln. It is used in GiNaC, which is a rather cool way of >> embedding symbolic expressions inside C++ code. They are both available >> in the ports. > > I you looked at MPC? http://www.multiprecision.org/index.php?prog=mpc >>From the MPC manual: > > 4.6 Branch Cuts And Special Values > > Some complex functions have branch cuts, across which the function is > discontinous. In GNU MPC, the branch cuts chosen are the same as those > specified for the corresponding functions in the ISO C99 standard. > > Likewise, when evaluated at a point whose real or imaginary part is > either infinite or a NaN or a signed zero, a function returns the same > value as those specified for the corresponding function in the ISO C99 > standard. > > 5.9 Trigonometric Functions > > - Function: int mpc_asinh (mpc_t rop, mpc_t op, mpc_rnd_t rnd) > - Function: int mpc_acosh (mpc_t rop, mpc_t op, mpc_rnd_t rnd) > - Function: int mpc_atanh (mpc_t rop, mpc_t op, mpc_rnd_t rnd) > > Set rop to the inverse hyperbolic sine, inverse hyperbolic cosine, inverse > hyperbolic tangent of op, rounded according to rnd with the precision of > rop. The branch cut of mpc_acosh is (-\infty, 1). > Oops, my apologies. Reading the manuals and the literature has always been my biggest weakness. I have this unfortunate tendency to keep reinventing the wheel. (It does slow you down, but you also understand things a lot better!) I will try out these mpc_asinh, etc functions. Incidentally, I did find a few edge cases when my program actually beat Mathematica! (I know I was correct, and not Mathematica, by looking at power series expansions.) It was things like I + 1e-200. So if they disagree, I might check to see if it is mpc or my program that is correct. The real difficulty with casinh and cacosh is not the computation of clog, but the calculation of z+csqrt(z*z+1)-1. It is very hard when z is close to I or -I. The paper by Hull et al really does an excellent job of handling the special cases.