Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix asinh of negative values #72486

Merged
merged 2 commits into from
Jun 19, 2020
Merged

Fix asinh of negative values #72486

merged 2 commits into from
Jun 19, 2020

Commits on May 24, 2020

  1. Fix asinh of negative values

    When `x` has large magnitude, `x + ((x * x) + 1.0).sqrt()` approaches
    `x + x.abs()`. For negative values of `x`, this leads to catastrophic
    cancellation, resulting in large errors or even 0 being passed to
    `ln`, producing incorrect results including `-inf`.
    
    Becuase asinh is an odd function, i.e. -asinh(x) = asinh(-x) for all
    x, we can avoid the catastrophic cancellation and obtain correct
    results by taking the absolute value of `self` for the first
    term. `self * self` is always positive, so in effect this gives us
    `x.abs().asinh().copysign(x)` which as discussed above is
    algebraically equivalent, but is much more accurate.
    Ralith committed May 24, 2020
    Configuration menu
    Copy the full SHA
    730f736 View commit details
    Browse the repository at this point in the history

Commits on Jun 19, 2020

  1. Remove now-redundant branch

    Ralith committed Jun 19, 2020
    Configuration menu
    Copy the full SHA
    35a2915 View commit details
    Browse the repository at this point in the history