[all-commits] [llvm/llvm-project] aa3f93: [libc][math] Add float-only implementation for ata...
lntue via All-commits
all-commits at lists.llvm.org
Thu Nov 20 06:42:35 PST 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: aa3f930931e65b02bacac0c7dfa52a181a0fd5bb
https://github.com/llvm/llvm-project/commit/aa3f930931e65b02bacac0c7dfa52a181a0fd5bb
Author: lntue <lntue at google.com>
Date: 2025-11-20 (Thu, 20 Nov 2025)
Changed paths:
M libc/src/__support/math/CMakeLists.txt
M libc/src/__support/math/atanf.h
A libc/src/__support/math/atanf_float.h
M libc/test/src/math/atanf_test.cpp
M libc/test/src/math/exhaustive/CMakeLists.txt
A libc/test/src/math/exhaustive/atanf_float_test.cpp
Log Message:
-----------
[libc][math] Add float-only implementation for atanf. (#167004)
Algorithm:
```
1) atan(x) = sign(x) * atan(|x|)
2) If |x| > 1 + 1/32, atan(|x|) = pi/2 - atan(1/|x|)
3) For 1/16 < |x| < 1 + 1/32, we find k such that: | |x| - k/16 | <= 1/32.
Let y = |x| - k/16, then using the angle summation formula, we have:
atan(|x|) = atan(k/16) + atan( (|x| - k/16) / (1 + |x| * k/16) )
= atan(k/16) + atan( y / (1 + (y + k/16) * k/16 )
= atan(k/16) + atan( y / ((1 + k^2/256) + y * k/16) )
4) Let u = y / (1 + k^2/256), then we can rewritten the above as:
atan(|x|) = atan(k/16) + atan( u / (1 + u * k/16) )
~ atan(k/16) + (u - k/16 * u^2 + (k^2/256 - 1/3) * u^3 +
+ (k/16 - (k/16)^3) * u^4) + O(u^5)
```
With all the computations are done in single precision (float), the
total of approximation errors and rounding errors is bounded by 4 ULPs.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list