Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mPpB2-0002u6-2A for pgsql-hackers@arkaria.postgresql.org; Mon, 13 Sep 2021 16:51:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mPpB0-0001vA-CB for pgsql-hackers@arkaria.postgresql.org; Mon, 13 Sep 2021 16:51:26 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mPpB0-0001v2-4D for pgsql-hackers@lists.postgresql.org; Mon, 13 Sep 2021 16:51:26 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mPpAx-00024j-9l for pgsql-hackers@lists.postgresql.org; Mon, 13 Sep 2021 16:51:25 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 5B77D5C01BC; Mon, 13 Sep 2021 12:51:21 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Mon, 13 Sep 2021 12:51:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=yIfQEu52JoeHIqK7o6sbeseyqpJsBzMrd7u854CgUik=; b=oUao1wDo p1t0zC15y74MEJFpwy9WffejKRKDXG6DqufrdTxkcEKc50fXfKjXmnabsxVO5WML i1IaibJOo8eX20uFcxYVflDGcx6T+Gza6yLPA94QAUsi/2JFtCFXjgEsdXLdwZHO 8dO5Z0oqHPsko1vtjzhF0IMCfdN6e2B3eY9pOfU2/2e+0XYOLPBJV0GOHcWG6Z8e O2Q4Gol0YLly9D5XHtBreygffOwbSSN6CjlmX57KYliHG3hiaS8A1AycgGvogoPI JWILAts9iAmLcUeLF3LQQvHNIgSmbMEKqUfmj9YYujwnw9ZCl/tVhWbamzeurIlh 06p3FC5dapd95w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudegjedguddtvdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvuffkgggtugfgjgesthekredttddtjeenucfhrhhomheptehlvhgr rhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh eqnecuggftrfgrthhtvghrnhepudejveejffejveduudetvdekieeuiedtvdeileefkeev jedufeeguedvjefhueelnecuffhomhgrihhnpegvnhhtvghrphhrihhsvggusgdrtghomh enucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhv hhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 13 Sep 2021 12:51:20 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 9AA392A085A; Mon, 13 Sep 2021 13:51:17 -0300 (-03) Date: Mon, 13 Sep 2021 13:51:17 -0300 From: Alvaro Herrera To: Dean Rasheed Cc: Jaime Casanova , Tom Lane , Yugo NAGATA , PostgreSQL Hackers , Dave Page Subject: Re: Numeric x^y for negative x Message-ID: <202109131651.raa5zr4znnfk@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2021-Sep-12, Dean Rasheed wrote: > So the fix is just to remove the upper bound on this local_rscale, as > we do for the full-precision calculation. This doesn't impact > performance, because it's only computing the logarithm to 8 > significant digits at this stage, and when x is very close to 1 like > this, ln_var() has very little work to do -- there is no argument > reduction to do, and the Taylor series terminates on the second term, > since 1-x is so small. I came here just to opine that there should be a comment about there not being a clamp to the maximum scale. For example, log_var says "Set the scales .. so that they each have more digits ..." which seems clear enough; I think the new comment is a bit on the short side. > Coming up with a test case that doesn't have thousands of digits is a > bit fiddly, so I chose one where most of the significant digits of the > result are a long way after the decimal point and shifted them up, > which makes the loss of precision in HEAD more obvious. The expected > result can be verified using bc with a scale of 2000. I couldn't get bc (version 1.07.1) to output the result; it says Runtime warning (func=(main), adr=47): non-zero scale in exponent Runtime error (func=(main), adr=47): exponent too large in raise -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/