1/* e_asinf.c -- float version of e_asin.c.
2 */
3
4/*
5 * ====================================================
6 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
7 *
8 * Developed at SunPro, a Sun Microsystems, Inc. business.
9 * Permission to use, copy, modify, and distribute this
10 * software is freely granted, provided that this notice
11 * is preserved.
12 * ====================================================
13 */
14
15/*
16 Modifications for single precision expansion are
17 Copyright (C) 2001 Stephen L. Moshier <moshier@na-net.ornl.gov>
18 and are incorporated herein by permission of the author. The author
19 reserves the right to distribute this material elsewhere under different
20 copying permissions. These modifications are distributed here under
21 the following terms:
22
23 This library is free software; you can redistribute it and/or
24 modify it under the terms of the GNU Lesser General Public
25 License as published by the Free Software Foundation; either
26 version 2.1 of the License, or (at your option) any later version.
27
28 This library is distributed in the hope that it will be useful,
29 but WITHOUT ANY WARRANTY; without even the implied warranty of
30 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
31 Lesser General Public License for more details.
32
33 You should have received a copy of the GNU Lesser General Public
34 License along with this library; if not, see
35 <https://www.gnu.org/licenses/>. */
36
37#if defined(LIBM_SCCS) && !defined(lint)
38static char rcsid[] = "$NetBSD: e_asinf.c,v 1.5 1995/05/12 04:57:25 jtc Exp $";
39#endif
40
41#include <float.h>
42#include <math.h>
43#include <math_private.h>
44#include <math-underflow.h>
45#include <libm-alias-finite.h>
46
47static const float
48one = 1.0000000000e+00, /* 0x3F800000 */
49huge = 1.000e+30,
50
51pio2_hi = 1.57079637050628662109375f,
52pio2_lo = -4.37113900018624283e-8f,
53pio4_hi = 0.785398185253143310546875f,
54
55/* asin x = x + x^3 p(x^2)
56 -0.5 <= x <= 0.5;
57 Peak relative error 4.8e-9 */
58p0 = 1.666675248e-1f,
59p1 = 7.495297643e-2f,
60p2 = 4.547037598e-2f,
61p3 = 2.417951451e-2f,
62p4 = 4.216630880e-2f;
63
64float __ieee754_asinf(float x)
65{
66 float t,w,p,q,c,r,s;
67 int32_t hx,ix;
68 GET_FLOAT_WORD(hx,x);
69 ix = hx&0x7fffffff;
70 if(ix==0x3f800000) {
71 /* asin(1)=+-pi/2 with inexact */
72 return x*pio2_hi+x*pio2_lo;
73 } else if(ix> 0x3f800000) { /* |x|>= 1 */
74 return (x-x)/(x-x); /* asin(|x|>1) is NaN */
75 } else if (ix<0x3f000000) { /* |x|<0.5 */
76 if(ix<0x32000000) { /* if |x| < 2**-27 */
77 math_check_force_underflow (x);
78 if(huge+x>one) return x;/* return x with inexact if x!=0*/
79 } else {
80 t = x*x;
81 w = t * (p0 + t * (p1 + t * (p2 + t * (p3 + t * p4))));
82 return x+x*w;
83 }
84 }
85 /* 1> |x|>= 0.5 */
86 w = one-fabsf(x: x);
87 t = w*0.5f;
88 p = t * (p0 + t * (p1 + t * (p2 + t * (p3 + t * p4))));
89 s = sqrtf(t);
90 if(ix>=0x3F79999A) { /* if |x| > 0.975 */
91 t = pio2_hi-(2.0f*(s+s*p)-pio2_lo);
92 } else {
93 int32_t iw;
94 w = s;
95 GET_FLOAT_WORD(iw,w);
96 SET_FLOAT_WORD(w,iw&0xfffff000);
97 c = (t-w*w)/(s+w);
98 r = p;
99 p = 2.0f*s*r-(pio2_lo-2.0f*c);
100 q = pio4_hi-2.0f*w;
101 t = pio4_hi-(p-q);
102 }
103 if(hx>0) return t; else return -t;
104}
105libm_alias_finite (__ieee754_asinf, __asinf)
106

source code of glibc/sysdeps/ieee754/flt-32/e_asinf.c