Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1j87Xc-0003kg-T2 for pgsql-bugs@arkaria.postgresql.org; Sat, 29 Feb 2020 19:12:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j87Xa-0007qI-Kf for pgsql-bugs@arkaria.postgresql.org; Sat, 29 Feb 2020 19:12:46 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1j87Xa-0007qB-8z for pgsql-bugs@lists.postgresql.org; Sat, 29 Feb 2020 19:12:46 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j87XX-0004YW-Ga for pgsql-bugs@lists.postgresql.org; Sat, 29 Feb 2020 19:12:44 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id 01TJCdq5013049; Sat, 29 Feb 2020 14:12:39 -0500 From: Tom Lane To: Dean Rasheed cc: anyhowstep@hotmail.com, PostgreSQL mailing lists Subject: Re: BUG #16281: LN() function inaccurate at 1000th fractional digit In-reply-to: References: <16281-279f299d9c06e56f@postgresql.org> <962.1582904341@sss.pgh.pa.us> Comments: In-reply-to Dean Rasheed message dated "Sat, 29 Feb 2020 17:16:02 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <13047.1583003559.1@sss.pgh.pa.us> Date: Sat, 29 Feb 2020 14:12:39 -0500 Message-ID: <13048.1583003559@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Dean Rasheed writes: > Looking more closely at ln_var(), it seems that there was an oversight > related to the way that it computes the local_rscale for the Taylor > series expansion --- it fails to account for the fact that the result > is multiplied by fact (2^(nsqrt+1), where nsqrt is the number of > square roots performed in the range reduction phase, which in practice > is at most 22). > Since 2^22 has 7 decimal digits, multiplying by 2^22 almost entirely > wipes out the 8-digit safety margin used in the Taylor series > expansion. The attached patch corrects that. Looks sane to me. > With this patch, all the examples originally posted return the correct > results (calculated with bc). I'd be interested to know how the OP > constructed these examples, and whether there were any that were off > by more than 1 ULP. Yeah, that would be interesting. regards, tom lane