1// polynomial for approximating asin(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 = double; 8 9prec=256; 10 11a = 0x1p-106; 12b = 0.25; 13 14deg = 11; 15 16backward = proc(poly, d) { 17 return d + d ^ 3 * poly(d * d); 18}; 19 20forward = proc(f, d) { 21 return (f(sqrt(d))-sqrt(d))/(d*sqrt(d)); 22}; 23 24poly = fpminimax(forward(f, x), [|0,...,deg|], [|dtype ...|], [a;b], relative, floating); 25 26display = hexadecimal!; 27print("rel error:", dirtyinfnorm(1-backward(poly, x)/f(x), [a;b])); 28print("in [", a, b, "]"); 29for i from 0 to deg do print(coeff(poly, i)); 30