1// polynomial for approximating erfc(x)*exp(x*x)
2//
3// Copyright (c) 2022-2023, Arm Limited.
4// SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
5
6deg = 12; // poly degree
7
8// interval bounds
9a = 0x1.60dfc14636e2ap0;
10b = 0x1.d413cccfe779ap0;
11
12f = proc(y) {
13  t = y + a;
14  return erfc(t) * exp(t*t);
15};
16
17poly = remez(f(x), deg, [0;b-a], 1, 1e-16);
18
19display = hexadecimal;
20print("rel error:", accurateinfnorm(1-poly(x)/f(x), [a;b], 30));
21print("in [",a,b,"]");
22print("coeffs:");
23for i from 0 to deg do round(coeff(poly,i), 52, RN);
24