Re: [Patch] Log10 and hyperbolic functions for SQL:2016 compliance - Mailing list pgsql-hackers

From Dean Rasheed
Subject Re: [Patch] Log10 and hyperbolic functions for SQL:2016 compliance
Date
Msg-id CAEZATCUVK18HxMp4Xz_XuGKNZiKG05oPHTvkVYGMdKFuo4XYDg@mail.gmail.com
Whole thread Raw
In response to Re: [Patch] Log10 and hyperbolic functions for SQL:2016 compliance  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: [Patch] Log10 and hyperbolic functions for SQL:2016 compliance
List pgsql-hackers
On Sun, 3 Feb 2019 at 15:12, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> Andrew Gierth <andrew@tao11.riddles.org.uk> writes:
> > The spec doesn't require the inverse functions (asinh, acosh, atanh),
> > but surely there is no principled reason to omit them?
>
> +1 --- AFAICS, the C library has offered all six since C89.
>

+1 for including the inverse functions. However, it looks to me like
the inverse functions are C99-specific, so they might not be available
on all supported platforms. If they're not, we may need to provide our
own implementations.

I did a bit of research and had play. It looks like it might not be
too hard to provide our own implementations, but it does take a bit of
care to avoid rounding and overflow errors. Attached are some
standalone C programs where I tested various algorithms. A decent
approach seems to be to either use log1p() (which is itself
C99-specific, hence that's the first thing I played with) or to use a
single round of Newton-Raphson to correct rounding errors, in a
similar way to how we implement cbrt() on platforms that don't have
that.

Of course that may all be moot -- those functions may in fact be
available everywhere we care about, but it was interesting to play
around with them anyway.

Regards,
Dean

Attachment

pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: Fix optimization of foreign-key on update actions
Next
From: Alvaro Herrera
Date:
Subject: Re: monitoring CREATE INDEX [CONCURRENTLY]