[libc-commits] [libc] [libc][math][c23] Add acoshf16 C23 math function. (PR #130588)
Harrison Hao via libc-commits
libc-commits at lists.llvm.org
Sat Mar 22 03:09:32 PDT 2025
================
@@ -74,16 +66,29 @@ LLVM_LIBC_FUNCTION(float16, acoshf16, (float16 x)) {
// ([1, 1.25)).
//
// Brief derivation:
- // 1. Start from the definition: acosh(x) = y means x = cosh(y).
- // 2. Set x = 1 + delta. For small delta, y ≈ sqrt(2 * delta).
- // 3. Expand acosh(1 + delta) using Taylor series around delta=0:
+ // 1. Expand acosh(1 + delta) using Taylor series around delta=0:
// acosh(1 + delta) ≈ sqrt(2 * delta) * [1 - delta/12 + 3*delta^2/160
// - 5*delta^3/896 + 35*delta^4/18432 + ...]
- // 4. Truncate the series to fit accurately for delta in [0, 0.25].
- // 5. Polynomial coefficients (from sollya) used here are:
+ // 2. Truncate the series to fit accurately for delta in [0, 0.25].
+ // 3. Polynomial coefficients (from sollya) used here are:
// P(delta) ≈ 1 - 0x1.555556p-4 * delta + 0x1.333334p-6 * delta^2
// - 0x1.6db6dcp-8 * delta^3 + 0x1.f1c71cp-10 * delta^4
- if (LIBC_UNLIKELY(xf < 1.25f)) {
+ // 4. The Sollya commands used to generate these coefficients were:
+ // > display = hexadecimal;
+ // > round(1/12, SG, RN);
+ // > round(3/160, SG, RN);
+ // > round(5/896, SG, RN);
+ // > round(35/18432, SG, RN);
+ // With hexadecimal display mode enabled, the outputs were:
+ // 0x1.555556p-4
+ // 0x1.333334p-6
+ // 0x1.6db6dcp-8
+ // 0x1.f1c71cp-10
+ // 5. The maximum absolute error, estimated using:
+ // dirtyinfnorm(acosh(1 + x) - sqrt(2*x) * P(x), [0, 0.25])
+ // is:
+ // 0x1.d84281p-22
+ if (LIBC_UNLIKELY(x_u < 1.25f)) {
----------------
harrisonGPU wrote:
Okay, I have updated it. @lntue :-)
https://github.com/llvm/llvm-project/pull/130588
More information about the libc-commits
mailing list