This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Add sinh(tanh(x)) and cosh(tanh(x)) rules
- From: Segher Boessenkool <segher at kernel dot crashing dot org>
- To: Wilco Dijkstra <Wilco dot Dijkstra at arm dot com>
- Cc: Jeff Law <law at redhat dot com>, Richard Biener <richard dot guenther at gmail dot com>, Giuliano Augusto Faulin Belinassi <giuliano dot belinassi at usp dot br>, GCC Patches <gcc-patches at gcc dot gnu dot org>, "giuliano dot belinassi at gmail dot com" <giuliano dot belinassi at gmail dot com>, nd <nd at arm dot com>
- Date: Thu, 8 Nov 2018 13:46:44 -0600
- Subject: Re: [PATCH] Add sinh(tanh(x)) and cosh(tanh(x)) rules
- References: <DB5PR08MB103001D43201E2827778B49F83E30@DB5PR08MB1030.eurprd08.prod.outlook.com> <CAEFO=4CV1P23fmb_kAv8u=ubJ5PejVFC59gFGnbNm2TrO-P38Q@mail.gmail.com> <20181019134511.GA1712@gate.crashing.org> <CAEFO=4ApmEcpd-7ou2-_mdvMdGT4qphYdVcuZwpwYD=QvrDOeQ@mail.gmail.com> <DB5PR08MB1030FF50545C033B42839E2B83F90@DB5PR08MB1030.eurprd08.prod.outlook.com> <CAEFO=4CFeyjbRK5itK3ieb5mgEHtcEMSYd70cO4OgtWD2hcjpw@mail.gmail.com> <5b717a08-f994-0de8-5092-d11f5d9f8bd0@redhat.com> <DB5PR08MB1030411C02C5DA22F949882583C50@DB5PR08MB1030.eurprd08.prod.outlook.com>
Hi Wilco,
On Thu, Nov 08, 2018 at 01:33:19PM +0000, Wilco Dijkstra wrote:
> > But the max. error in sinh/cosh/atanh is less than 2 ULP, with some math
> > libraries. It could be < 1 ULP, in theory, so sinh(atanh(x)) less than
> > 2 ULP even.
>
> You can't add ULP errors in general - a tiny difference in the input can
> make a huge difference in the result if the derivative is > 1.
>
> Even with perfect implementations of 0.5000001ULP on easy functions with
> no large derivatives you could get a 2ULP total error if the perfectly rounded
> and actual result end up rounding in different directions in the 2nd function...
Sure. My point is that there can be math libraries where the original
sinh(atanh(x)) is more precise than what we replace it with here, for
certain values at least. So you need some fast math flag no matter what.
But we agree on that anyway :-)
> So you have to measure ULP error since it is quite counter intuitive.
It's hard to measure with DP, and worse with QP... Proving things is
often easier.
Segher