Lines Matching full:atan
1 //===-- Double-precision atan function ------------------------------------===//
9 #include "src/math/atan.h"
21 // To compute atan(x), we divided it into the following cases:
23 // Since |x| > atan(|x|) > |x| - |x|^3/3, and |x|^3/3 < ulp(x)/2, we simply
24 // return atan(x) = x - sign(x) * epsilon.
28 // atan(x) = sign(x) * atan(|x|)
29 // = sign(x) * (atan(k) + atan((|x| - k) / (1 + |x|*k)).
30 // We store atan(k) in a look up table, and perform intermediate steps in
34 // atan(x) = sign(x) * (pi/2 - atan(1/|x|))
35 // = sign(x) * (pi/2 - atan(y)).
36 // Then we compute atan(y) using range reduction mod 2^-6 = 1/64 as the
39 // atan(y) = atan(k) + atan((y - k) / (1 + y*k))
40 // = atan(k) + atan((1/|x| - k) / (1 + k/|x|)
41 // = atan(k) + atan((1 - k*|x|) / (|x| + k)).
44 // atan(x) = sign(x) * (pi/2 - atan(1/|x|)).
46 // atan(1/|x|) <= 1/|x| <= 2^-53,
49 // atan(x) = sign(x) * (pi/2 - epsilon)
51 LLVM_LIBC_FUNCTION(double, atan, (double x)) {
100 // Approximating atan(x_r) using Taylor polynomial.
103 // atan(x) = sign(x) * (atan(k) + atan(x_r))
104 // = sign(x) * (atan(k) + atan( (|x| - k) / (1 + k * |x|) ))
128 // atan(x) ~ sign(x) * pi/2.
159 // Approximating atan(x_r) using Taylor polynomial.
162 // atan(x) = sign(x) * (pi/2 - atan(1/|x|))
163 // = sign(x) * (pi/2 - atan(k) - atan(x_r))
164 // = (-sign(x)) * (-pi/2 + atan(k) + atan((1 - k*|x|)/(|x| - k)))