Re: Inaccurate results from numeric ln(), log(), exp() and pow() - Mailing list pgsql-hackers

From Merlin Moncure
Subject Re: Inaccurate results from numeric ln(), log(), exp() and pow()
Date
Msg-id CAHyXU0zdNwh0G-ofPjZxCRa3Qrf6k3AnhHyaSGUYZzhYq72JEA@mail.gmail.com
Whole thread Raw
In response to Inaccurate results from numeric ln(), log(), exp() and pow()  (Dean Rasheed <dean.a.rasheed@gmail.com>)
Responses Re: Inaccurate results from numeric ln(), log(), exp() and pow()  (Dean Rasheed <dean.a.rasheed@gmail.com>)
List pgsql-hackers
On Wed, Sep 16, 2015 at 2:31 AM, Dean Rasheed <dean.a.rasheed@gmail.com> wrote:
> Hi,
>
> I recently noticed that numeric log() produces inaccurate results for
> certain ranges of inputs. This isn't just small errors in the last 1
> or 2 digits, but sometimes quite large errors, with over half the
> significant digits returned being incorrect.

yikes.

> The initial issue was a block of code to estimate the weight of the
> logarithm, repeated in 3 different places, and called from ln(), log()
> and pow(). After coming up with a fix for that, however, testing
> revealed a whole range of additional issues causing further
> inaccuracies in those functions and also in exp().
<snip>
> AFAICT, this kind of slowdown only happens in cases like this where a
> very large number of digits are being returned.

Can you clarify "very large"?

merlin



pgsql-hackers by date:

Previous
From: Euler Taveira
Date:
Subject: pltcl: sentence improvement
Next
From: Thom Brown
Date:
Subject: Re: [PROPOSAL] Covering + unique indexes.