[libc-commits] [PATCH] D133400: [libc][math] Implement asinf function correctly rounded for all rounding modes.
Tue Ly via Phabricator via libc-commits
libc-commits at lists.llvm.org
Wed Sep 7 09:04:19 PDT 2022
lntue added a comment.
In D133400#3774132 <https://reviews.llvm.org/D133400#3774132>, @orex wrote:
> Good job, Tue!
>
> I have an optional suggestion. You can use formula
> `asin(x)=1/2*acos(1-2*x^2)`
> and, of course,
> `acos(x)=pi/2-asin(x)`
> for cases where `|x|>=0.5` Probably it can be much faster than `sqrt`.
Thanks @orex for the suggestion! Unfortunately the formula `asin(x) = pi/4 - 1/2 * asin(1 - 2*x^2)` only works
well when `|1 - 2*x^2| <= 0.5`, i.e. `0.5 <= |x| <= sqrt(3)/2`.
For `sqrt(3)/2 < |x| <= 1`, we still need some sort of range reduction involving square root.
Nonetheless, I've tried adding another branch for `0.5 <= |x| <= sqrt(3)/2` using the formula
`asin(x) = pi/4 - 1/2 * asin(1 - 2*x^2)` and it actually makes both the throughput and the latency
slightly worse than 2 branches.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D133400/new/
https://reviews.llvm.org/D133400
More information about the libc-commits
mailing list