xref: /freebsd/contrib/arm-optimized-routines/pl/math/tools/asinf.sollya (revision 5b56413d04e608379c9a306373554a8e4d321bc0)
1// polynomial for approximating asinf(x)
2//
3// Copyright (c) 2023, Arm Limited.
4// SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
5
6f = asin(x);
7dtype = single;
8
9a = 0x1p-24;
10b = 0.25;
11
12deg = 4;
13
14backward = proc(poly, d) {
15  return d + d ^ 3 * poly(d * d);
16};
17
18forward = proc(f, d) {
19  return (f(sqrt(d))-sqrt(d))/(d*sqrt(d));
20};
21
22approx = proc(poly, d) {
23  return remez(1 - poly(x) / forward(f, x), deg - d, [a;b], x^d/forward(f, x), 1e-16);
24};
25
26poly = 0;
27for i from 0 to deg do {
28  i;
29  p = roundcoefficients(approx(poly,i), [|dtype ...|]);
30  poly = poly + x^i*coeff(p,0);
31};
32
33display = hexadecimal!;
34print("rel error:", accurateinfnorm(1-backward(poly, x)/f(x), [a;b], 30));
35print("in [", a, b, "]");
36for i from 0 to deg do print(coeff(poly, i));
37