From owner-freebsd-current@FreeBSD.ORG Wed Jul 25 17:53:28 2012 Return-Path: Delivered-To: freebsd-current@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5D7631065670; Wed, 25 Jul 2012 17:53:28 +0000 (UTC) (envelope-from sgk@troutmask.apl.washington.edu) Received: from troutmask.apl.washington.edu (troutmask.apl.washington.edu [128.95.76.21]) by mx1.freebsd.org (Postfix) with ESMTP id 2EBBF8FC1C; Wed, 25 Jul 2012 17:53:28 +0000 (UTC) Received: from troutmask.apl.washington.edu (localhost.apl.washington.edu [127.0.0.1]) by troutmask.apl.washington.edu (8.14.5/8.14.5) with ESMTP id q6PHrRxa073075; Wed, 25 Jul 2012 10:53:27 -0700 (PDT) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.14.5/8.14.5/Submit) id q6PHrRw4073074; Wed, 25 Jul 2012 10:53:27 -0700 (PDT) (envelope-from sgk) Date: Wed, 25 Jul 2012 10:53:27 -0700 From: Steve Kargl To: Rainer Hurling Message-ID: <20120725175327.GA72991@troutmask.apl.washington.edu> References: <20120708233624.GA53462@troutmask.apl.washington.edu> <4FFBF16D.2030007@gwdg.de> <2A1DE516-ABB4-49D7-8C3D-2C4DA2D9FCF5@bsdimp.com> <4FFC412B.4090202@gwdg.de> <20120710151115.GA56950@zim.MIT.EDU> <4FFC5E5D.8000502@gwdg.de> <20120710225801.GB58778@zim.MIT.EDU> <50101EDE.6030509@gwdg.de> <20120725170004.GA72338@troutmask.apl.washington.edu> <50102DD3.6010700@gwdg.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <50102DD3.6010700@gwdg.de> User-Agent: Mutt/1.4.2.3i Cc: David Schultz , freebsd-current@FreeBSD.org, Bruce Evans Subject: Re: Use of C99 extra long double math functions after r236148 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Jul 2012 17:53:28 -0000 On Wed, Jul 25, 2012 at 07:33:07PM +0200, Rainer Hurling wrote: > On 25.07.2012 19:00 (UTC+2), Steve Kargl wrote: > > > >If you actually want to test expl() to see if it is producing > >a decent result, you need a reference solution that contains > >a higher precision. I use mpfr with 256 bits of precision. > > > >troutmask:fvwm:kargl[213] ./testl -V 2 > >ULP = 0.3863 > > x = 2.000000000000000000e+00 > >libm: 7.389056098930650227e+00 0x1.d8e64b8d4ddadcc4p+2 > >mpfr: 7.389056098930650227e+00 0x1.d8e64b8d4ddadcc4p+2 > >mpfr: 7.3890560989306502272304274605750078131803155705518\ > > 47324087127822522573796079054e+00 > >mpfr: > >0x7.63992e35376b730ce8ee881ada2aeea11eb9ebd93c887eb59ed77977d109f148p+0 > > > >The 1st 'mpfr:' line is produced after converting the results > >fof mpfr_exp() to long double. The 2nd 'mpfr:' line is > >produced by mpfr_printf() where the number of printed > >digits depends on the 256-bit precision. The last 'mpfr:' > >line is mpfr_printf()'s hex formatting. Unfortunately, it > >does not normalize the hex representation to start with > >'0x1.', which makes comparison somewhat difficult. > > > > Many thanks also for this mpfr example. This helps me to understand a > little bit more what is going here. So on amd64 even the expl() result > is far from what mpfr provides. Of course!. MPFR is a multiple precision library. One specifies the precision, and mpfr returns a value with that precision. #include int main(void) { int i, j[5] = {24, 53, 64, 113, 256}; mpfr_t x, f; for (i = 0; i < 5; i++) { /* Set working precision to j[i]. */ mpfr_inits2(j[i], x, f, MPFR_RNDN); mpfr_set_ui(x, 2, MPFR_RNDN); mpfr_exp(f, x, MPFR_RNDN); mpfr_printf("exp(%Re) = %Re\n", x, f); mpfr_clears(x, f, NULL); } } troutmask:fvwm:kargl[222] cc -o z -I/usr/local/include a.c -L/usr/local/lib\ -lmpfr -lgmp troutmask:fvwm:kargl[223] ./z exp(2e+00) = 7.38905621e+00 exp(2e+00) = 7.3890560989306504e+00 exp(2e+00) = 7.3890560989306502274e+00 exp(2e+00) = 7.38905609893065022723042746057500802e+00 exp(2e+00) = 7.38905609893065022723042746057500781\ 3180315570551847324087127822522573796079054e+00 -- Steve