aboutsummaryrefslogtreecommitdiff
path: root/pl/math/tools/erfc.sollya
diff options
context:
space:
mode:
Diffstat (limited to 'pl/math/tools/erfc.sollya')
-rw-r--r--pl/math/tools/erfc.sollya60
1 files changed, 44 insertions, 16 deletions
diff --git a/pl/math/tools/erfc.sollya b/pl/math/tools/erfc.sollya
index 8c40b4b5db6b..1e2791291ebb 100644
--- a/pl/math/tools/erfc.sollya
+++ b/pl/math/tools/erfc.sollya
@@ -1,23 +1,51 @@
-// polynomial for approximating erfc(x)*exp(x*x)
+// tables and constants for approximating erfc(x).
//
-// Copyright (c) 2022-2023, Arm Limited.
+// Copyright (c) 2023, Arm Limited.
// SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
-deg = 12; // poly degree
-
-// interval bounds
-a = 0x1.60dfc14636e2ap0;
-b = 0x1.d413cccfe779ap0;
+display = hexadecimal;
+prec=128;
-f = proc(y) {
- t = y + a;
- return erfc(t) * exp(t*t);
+// Tables
+print("{ i, r, erfc(r), 2/sqrt(pi) * exp(-r^2) }");
+for i from 0 to 3787 do {
+ r = 0.0 + i / 128;
+ t0 = double(erfc(r) * 2^128);
+ t1 = double(2/sqrt(pi) * exp(-r * r) * 2^128);
+ print("{ " @ t0 @ ",\t" @ t1 @ " },");
};
-poly = remez(f(x), deg, [0;b-a], 1, 1e-16);
+// Constants
+print("> 2/sqrt(pi)");
+double(2/sqrt(pi));
-display = hexadecimal;
-print("rel error:", accurateinfnorm(1-poly(x)/f(x), [a;b], 30));
-print("in [",a,b,"]");
-print("coeffs:");
-for i from 0 to deg do round(coeff(poly,i), 52, RN);
+print("> 1/3");
+double(1/3);
+
+print("> P5");
+double(2/15);
+double(1/10);
+double(2/9);
+double(2/45);
+
+print("> P6");
+double(1/42);
+double(1/7);
+double(2/21);
+double(4/315);
+
+print("> Q");
+double( 5.0 / 4.0);
+double( 6.0 / 5.0);
+double( 7.0 / 6.0);
+double( 8.0 / 7.0);
+double( 9.0 / 8.0);
+double(10.0 / 9.0);
+
+print("> R");
+double(-2.0 * 4.0 / (5.0 * 6.0));
+double(-2.0 * 5.0 / (6.0 * 7.0));
+double(-2.0 * 6.0 / (7.0 * 8.0));
+double(-2.0 * 7.0 / (8.0 * 9.0));
+double(-2.0 * 8.0 / (9.0 * 10.0));
+double(-2.0 * 9.0 / (10.0 * 11.0));