1// polynomial for approximating asinh(x)
2//
3// Copyright (c) 2022-2023, Arm Limited.
4// SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
5
6// Polynomial is used in [2^-26, 1]. However it is least accurate close to 1, so
7// we use 2^-6 as the lower bound for coeff generation, which yields sufficiently
8// accurate results in [2^-26, 2^-6].
9a = 0x1p-6;
10b = 1.0;
11
12f = (asinh(sqrt(x)) - sqrt(x))/x^(3/2);
13
14approx = proc(poly, d) {
15  return remez(1 - poly(x)/f(x), deg-d, [a;b], x^d/f(x), 1e-10);
16};
17
18poly = 0;
19for i from 0 to deg do {
20  i;
21  p = roundcoefficients(approx(poly,i), [|D ...|]);
22  poly = poly + x^i*coeff(p,0);
23};
24
25
26display = hexadecimal;
27print("coeffs:");
28for i from 0 to deg do coeff(poly,i);
29