Hello.
    I don't think there is a need for overflow handling here because
the argument is bound by the argument of the sqrt function :-)

    Since we have to compute sqrt (1 - x*x), the input is only valid
if 1 - x*x >= 0, implying that -1 <= x <= 1. For any x outside of this
set, the sqrt will return a invalid value, as imaginary numbers are
required to represent the answer.

    One can also argue a problem regarding division by 0, however in
the extremes x -> -1 by the right and x -> 1 by the left we have:

     sinh(atanh(-1)) = -1 / sqrt (0) = -inf
     sinh(atanh( 1)) =  1 / sqrt (0) = +inf

     cos(atanh(-1)) = 1 / sqrt (0) = +inf
     cos(atanh( 1)) = 1 / sqrt (0) = +inf

    Therefore it seems that the target has to support infinity anyway.

    Well, I think I can take a look about how glibc handles such cases
on targets where infinity is not supported to try to keep
compatibility, but I think this is safe :-).
On Fri, Oct 12, 2018 at 1:09 AM Jeff Law <l...@redhat.com> wrote:
>
> On 8/7/18 2:00 PM, Giuliano Augusto Faulin Belinassi wrote:
> > Related with bug 86829, but for hyperbolic trigonometric functions.
> > This patch adds substitution rules to both sinh(tanh(x)) -> x / sqrt(1
> > - x*x) and cosh(tanh(x)) -> 1 / sqrt(1 - x*x). Notice that the both
> > formulas has division by 0, but it causes no harm because 1/(+0) ->
> > +infinity, thus the math is still safe.
> >
> > Changelog:
> > 2018-08-07  Giuliano Belinassi <giuliano.belina...@usp.br>
> >
> >     * match.pd: add simplification rules to sinh(atanh(x)) and 
> > cosh(atanh(x)).
> >
> > All tests added by this patch runs without errors in trunk, however,
> > there are tests unrelated with this patch that fails in my x86_64
> > Ubuntu 18.04.
> I think these are going to need similar handling because the x*x can
> overflow.  Are the domains constrained in a way that is helpful?
>
> jeff

Reply via email to