summaryrefslogtreecommitdiff
path: root/libc/test/src/math/asin_test.cpp
AgeCommit message (Collapse)Author
2025-10-21[libc][math] Add tolerance to math tests so that they still work when ↵lntue
accurate path is skipped. (#164522)
2025-06-11[libc] Move libc_errno.h to libc/src/__support and make ↵lntue
LIBC_ERRNO_MODE_SYSTEM to be header-only. (#143187) This is the first step in preparation for: https://discourse.llvm.org/t/rfc-make-clang-builtin-math-functions-constexpr-with-llvm-libc-to-support-c-23-constexpr-math-functions/86450
2025-04-25[libc][math] Implement double precision asin correctly rounded for all ↵lntue
rounding modes. (#134401) Main algorithm: The Taylor series expansion of `asin(x)` is: ```math \begin{align*} asin(x) &= x + x^3 / 6 + 3x^5 / 40 + ... \\ &= x \cdot P(x^2) \\ &= x \cdot P(u) &\text{, where } u = x^2. \end{align*} ``` For the fast path, we perform range reduction mod 1/64 and use degree-7 (minimax + Taylor) polynomials to approximate `P(x^2)`. When `|x| >= 0.5`, we use the transformation: ```math u = \frac{1 + x}{2} ``` and apply half-angle formula to reduce `asin(x)` to: ```math \begin{align*} asin(x) &= sign(x) \cdot \left( \frac{\pi}{2} - 2 \cdot asin(\sqrt{u}) \right) \\ &= sign(x) \cdot \left( \frac{\pi}{2} - 2 \cdot \sqrt{u} \cdot P(u) \right). \end{align*} ``` Since `0.5 <= |x| <= 1`, `|u| <= 0.5`. So we can reuse the polynomial evaluation of `P(u)` when `|x| < 0.5`. For the accurate path, we redo the computations in 128-bit precision with degree-15 (minimax + Taylor) polynomials to approximate `P(u)`.
2023-04-20[libc][math] Remove placeholder implementations of asin and pow.Tue Ly
Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D148781
2023-03-07[libc][math] Switch math functions to use libc_errno and fix some errno and ↵Tue Ly
floating point exceptions. Switch math functions to use libc_errno and fix some errno and floating point exceptions Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D145349
2023-02-07[libc][NFC] Move UnitTest and IntegrationTest to the 'test' directory.Siva Chandra Reddy
This part of the effort to make all test related pieces into the `test` directory. This helps is excluding test related pieces in a straight forward manner if LLVM_INCLUDE_TESTS is OFF. Future patches will also move the MPFR wrapper and testutils into the 'test' directory.
2022-10-31[libc][math] Add place-holder implementation for asin to unblock demo examples.Tue Ly
Add a place-holder implementation for asin to unblock libc demo examples. Reviewed By: michaelrj Differential Revision: https://reviews.llvm.org/D137105