Use expm1f(x) = exp(x) - 1 for |x| > ln(2).
For |x| <= ln(2), divide it into 3 subintervals: [-ln2, -1/8], [-1/8, 1/8], [1/8, ln2]
and use a degree-6 polynomial approximation generated by Sollya's fpminmax for each interval.
Errors < 1.5 ULPs when we use fma to evaluate the polynomials.
Details
- Reviewers
sivachandra - Commits
- rG4e5f8b4d8d9d: [libc] Add implementation of expm1f.
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
LGTM but I have added a comment to add a sollya script. Good to go after that.
libc/src/math/generic/expm1f.cpp | ||
---|---|---|
28 | I think we should add a sollya script for this under a directory named utils/mathtools so that future tuning can have a starting point to play with. And then, instead of inline comments like this, you can point to that sollya script at the top of this function. | |
libc/test/src/math/expm1f_test.cpp | ||
31 | Nitty nit: The name should probably be LlvmLibcExpm1fTest (ie. with the Exmpm1 capitalized.) |
Add more detail about generating polynomial coefficients with Sollya to utils/mathtools/expm1f.sollya.
Add differential and perf tests.
I think we should add a sollya script for this under a directory named utils/mathtools so that future tuning can have a starting point to play with. And then, instead of inline comments like this, you can point to that sollya script at the top of this function.