Lines Matching +full:range +full:- +full:double

2  * Double-precision erfc(x) function.
4 * Copyright (c) 2023-2024, Arm Limited.
5 * SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
13 #define P20 0x1.5555555555555p-2 /* 1/3. */
14 #define P21 0x1.5555555555555p-1 /* 2/3. */
16 #define P40 0x1.999999999999ap-4 /* 1/10. */
17 #define P41 0x1.999999999999ap-2 /* 2/5. */
18 #define P42 0x1.11111111111111p-3 /* 2/15. */
20 #define P50 0x1.5555555555555p-3 /* 1/6. */
21 #define P51 0x1.c71c71c71c71cp-3 /* 2/9. */
22 #define P52 0x1.6c16c16c16c17p-5 /* 2/45. */
31 /* Ri = -2 * i / ((i+1)*(i+2)). */
32 #define R5 -0x1.e79e79e79e79ep-3
33 #define R6 -0x1.b6db6db6db6dbp-3
34 #define R7 -0x1.8e38e38e38e39p-3
35 #define R8 -0x1.6c16c16c16c17p-3
36 #define R9 -0x1.4f2094f2094f2p-3
40 Let d = x - r, and scale = 2 / sqrt(pi) * exp(-r^2). For x near r,
42 erfc(x) ~ erfc(r) - scale * d * poly(r, d), with
44 poly(r, d) = 1 - r d + (2/3 r^2 - 1/3) d^2 - r (1/3 r^2 - 1/2) d^3
45 + (2/15 r^4 - 2/5 r^2 + 1/10) d^4
46 - r * (2/45 r^4 - 2/9 r^2 + 1/6) d^5
52 with p0 = 1, and p1(r) = -r.
55 are scaled to avoid hitting the subnormal range.
57 Note that for x < 0, erfc(x) = 2.0 - erfc(-x).
60 erfc(0x1.46cfe976733p+4) got 0x1.e15fcbea3e7afp-608
61 want 0x1.e15fcbea3e7adp-608. */
62 double
63 erfc (double x) in erfc()
68 double a = asdouble (ia); in erfc()
71 /* erfc(nan)=nan, erfc(+inf)=0 and erfc(-inf)=2. */ in erfc()
76 if (x < -6.0) in erfc()
82 /* |x| < 0x1p-511 => accurate to 0.5 ULP. */ in erfc()
83 if (unlikely (ia < asuint64 (0x1p-511))) in erfc()
84 return 1.0 - x; in erfc()
88 double z = a + Shift; in erfc()
89 uint64_t i = asuint64 (z) - asuint64 (Shift); in erfc()
90 double r = z - Shift; in erfc()
92 double erfcr = __v_erfc_data.tab[i].erfc; in erfc()
93 double scale = __v_erfc_data.tab[i].scale; in erfc()
95 /* erfc(x) ~ erfc(r) - scale * d * poly (r, d). */ in erfc()
96 double d = a - r; in erfc()
97 double d2 = d * d; in erfc()
98 double r2 = r * r; in erfc()
99 /* Compute p_i as a regular (low-order) polynomial. */ in erfc()
100 double p1 = -r; in erfc()
101 double p2 = fma (P21, r2, -P20); in erfc()
102 double p3 = -r * fma (P20, r2, -0.5); in erfc()
103 double p4 = fma (fma (P42, r2, -P41), r2, P40); in erfc()
104 double p5 = -r * fma (fma (P52, r2, -P51), r2, P50); in erfc()
107 double p6 = fma (Q5 * r, p5, p4) * R5; in erfc()
108 double p7 = fma (Q6 * r, p6, p5) * R6; in erfc()
109 double p8 = fma (Q7 * r, p7, p6) * R7; in erfc()
110 double p9 = fma (Q8 * r, p8, p7) * R8; in erfc()
111 double p10 = fma (Q9 * r, p9, p8) * R9; in erfc()
113 double p90 = fma (p10, d, p9); in erfc()
114 double p78 = fma (p8, d, p7); in erfc()
115 double p56 = fma (p6, d, p5); in erfc()
116 double p34 = fma (p4, d, p3); in erfc()
117 double p12 = fma (p2, d, p1); in erfc()
118 double y = fma (p90, d2, p78); in erfc()
123 y = fma (-fma (y, d2, d), scale, erfcr); in erfc()
126 double off = asdouble (sign >> 1); in erfc()
127 double fac = asdouble (asuint64 (0x1p-128) | sign); in erfc()
133 result gets into the subnormal range. */ in erfc()
134 if (unlikely (y < 0x1p-1022)) in erfc()
135 force_eval_double (opt_barrier_double (0x1p-1022) * 0x1p-1022); in erfc()
147 TEST_SIG (S, D, 1, erfc, -6.0, 28.0)
149 TEST_SYM_INTERVAL (erfc, 0, 0x1p-26, 40000)
150 TEST_INTERVAL (erfc, 0x1p-26, 28.0, 100000)
151 TEST_INTERVAL (erfc, -0x1p-26, -6.0, 100000)
153 TEST_INTERVAL (erfc, -6.0, -inf, 40000)