2 * IBM Accurate Mathematical Library
3 * written by International Business Machines Corp.
4 * Copyright (C) 2001, 2011 Free Software Foundation
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
19 /******************************************************************/
20 /* MODULE_NAME:uasncs.c */
22 /* FUNCTIONS: uasin */
24 /* FILES NEEDED: dla.h endian.h mpa.h mydefs.h usncs.h */
25 /* doasin.c sincos32.c dosincos.c mpa.c */
26 /* sincos.tbl asincos.tbl powtwo.tbl root.tbl */
28 /* Ultimate asin/acos routines. Given an IEEE double machine */
29 /* number x, compute the correctly rounded value of */
30 /* arcsin(x)or arccos(x) according to the function called. */
31 /* Assumption: Machine arithmetic operations are performed in */
32 /* round to nearest mode of IEEE 754 standard. */
34 /******************************************************************/
37 #include "asincos.tbl"
42 #include "math_private.h"
48 void __doasin(double x
, double dx
, double w
[]);
49 void __dubsin(double x
, double dx
, double v
[]);
50 void __dubcos(double x
, double dx
, double v
[]);
51 void __docos(double x
, double dx
, double v
[]);
52 double __sin32(double x
, double res
, double res1
);
53 double __cos32(double x
, double res
, double res1
);
55 /***************************************************************************/
56 /* An ultimate asin routine. Given an IEEE double machine number x */
57 /* it computes the correctly rounded (to nearest) value of arcsin(x) */
58 /***************************************************************************/
61 __ieee754_asin(double x
){
62 double x1
,x2
,xx
,s1
,s2
,res1
,p
,t
,res
,r
,cor
,cc
,y
,c
,z
,w
[2];
71 k
= 0x7fffffff&m
; /* no sign */
73 if (k
< 0x3e500000) return x
; /* for x->0 => sin(x)=x */
74 /*----------------------2^-26 <= |x| < 2^ -3 -----------------*/
78 t
= (((((f6
*x2
+ f5
)*x2
+ f4
)*x2
+ f3
)*x2
+ f2
)*x2
+ f1
)*(x2
*x
);
79 res
= x
+t
; /* res=arcsin(x) according to Taylor series */
81 if (res
== res
+1.025*cor
) return res
;
89 s2
= ((((((c7
*xx
+ c6
)*xx
+ c5
)*xx
+ c4
)*xx
+ c3
)*xx
+ c2
)*xx
*xx
*x
+
90 ((a1
.x
+a2
.x
)*x2
*x2
+ 0.5*x1
*x
)*x2
) + a2
.x
*p
;
92 s2
= ((x
-res1
)+s1
)+s2
;
95 if (res
== res
+1.00014*cor
) return res
;
98 if (w
[0]==(w
[0]+1.00000001*w
[1])) return w
[0];
102 res1
=ABS(w
[0]+1.1*w
[1]);
103 return (m
>0)?__sin32(y
,res
,res1
):-__sin32(y
,res
,res1
);
108 /*---------------------0.125 <= |x| < 0.5 -----------------------------*/
109 else if (k
< 0x3fe00000) {
110 if (k
<0x3fd00000) n
= 11*((k
&0x000fffff)>>15);
111 else n
= 11*((k
&0x000fffff)>>14)+352;
112 if (m
>0) xx
= x
- asncs
.x
[n
];
113 else xx
= -x
- asncs
.x
[n
];
115 p
=xx
*xx
*(asncs
.x
[n
+2]+xx
*(asncs
.x
[n
+3]+xx
*(asncs
.x
[n
+4]+xx
*(asncs
.x
[n
+5]
116 +xx
*asncs
.x
[n
+6]))))+asncs
.x
[n
+7];
118 res
=asncs
.x
[n
+8] +t
;
119 cor
= (asncs
.x
[n
+8]-res
)+t
;
120 if (res
== res
+1.05*cor
) return (m
>0)?res
:-res
;
122 r
=asncs
.x
[n
+8]+xx
*asncs
.x
[n
+9];
123 t
=((asncs
.x
[n
+8]-r
)+xx
*asncs
.x
[n
+9])+(p
+xx
*asncs
.x
[n
+10]);
126 if (res
== res
+1.0005*cor
) return (m
>0)?res
:-res
;
131 z
=(w
[0]-ABS(x
))+w
[1];
132 if (z
>1.0e-27) return (m
>0)?min(res
,res1
):-min(res
,res1
);
133 else if (z
<-1.0e-27) return (m
>0)?max(res
,res1
):-max(res
,res1
);
136 return (m
>0)?__sin32(y
,res
,res1
):-__sin32(y
,res
,res1
);
140 } /* else if (k < 0x3fe00000) */
141 /*-------------------- 0.5 <= |x| < 0.75 -----------------------------*/
143 if (k
< 0x3fe80000) {
144 n
= 1056+((k
&0x000fe000)>>11)*3;
145 if (m
>0) xx
= x
- asncs
.x
[n
];
146 else xx
= -x
- asncs
.x
[n
];
148 p
=xx
*xx
*(asncs
.x
[n
+2]+xx
*(asncs
.x
[n
+3]+xx
*(asncs
.x
[n
+4]+xx
*(asncs
.x
[n
+5]
149 +xx
*(asncs
.x
[n
+6]+xx
*asncs
.x
[n
+7])))))+asncs
.x
[n
+8];
151 res
=asncs
.x
[n
+9] +t
;
152 cor
= (asncs
.x
[n
+9]-res
)+t
;
153 if (res
== res
+1.01*cor
) return (m
>0)?res
:-res
;
155 r
=asncs
.x
[n
+9]+xx
*asncs
.x
[n
+10];
156 t
=((asncs
.x
[n
+9]-r
)+xx
*asncs
.x
[n
+10])+(p
+xx
*asncs
.x
[n
+11]);
159 if (res
== res
+1.0005*cor
) return (m
>0)?res
:-res
;
164 z
=(w
[0]-ABS(x
))+w
[1];
165 if (z
>1.0e-27) return (m
>0)?min(res
,res1
):-min(res
,res1
);
166 else if (z
<-1.0e-27) return (m
>0)?max(res
,res1
):-max(res
,res1
);
169 return (m
>0)?__sin32(y
,res
,res1
):-__sin32(y
,res
,res1
);
173 } /* else if (k < 0x3fe80000) */
174 /*--------------------- 0.75 <= |x|< 0.921875 ----------------------*/
176 if (k
< 0x3fed8000) {
177 n
= 992+((k
&0x000fe000)>>13)*13;
178 if (m
>0) xx
= x
- asncs
.x
[n
];
179 else xx
= -x
- asncs
.x
[n
];
181 p
=xx
*xx
*(asncs
.x
[n
+2]+xx
*(asncs
.x
[n
+3]+xx
*(asncs
.x
[n
+4]+xx
*(asncs
.x
[n
+5]
182 +xx
*(asncs
.x
[n
+6]+xx
*(asncs
.x
[n
+7]+xx
*asncs
.x
[n
+8]))))))+asncs
.x
[n
+9];
184 res
=asncs
.x
[n
+10] +t
;
185 cor
= (asncs
.x
[n
+10]-res
)+t
;
186 if (res
== res
+1.01*cor
) return (m
>0)?res
:-res
;
188 r
=asncs
.x
[n
+10]+xx
*asncs
.x
[n
+11];
189 t
=((asncs
.x
[n
+10]-r
)+xx
*asncs
.x
[n
+11])+(p
+xx
*asncs
.x
[n
+12]);
192 if (res
== res
+1.0008*cor
) return (m
>0)?res
:-res
;
197 z
=((hp0
.x
-y
)-res
)+(hp1
.x
-z
);
199 z
=(w
[0]-ABS(x
))+w
[1];
200 if (z
>1.0e-27) return (m
>0)?min(res
,res1
):-min(res
,res1
);
201 else if (z
<-1.0e-27) return (m
>0)?max(res
,res1
):-max(res
,res1
);
204 return (m
>0)?__sin32(y
,res
,res1
):-__sin32(y
,res
,res1
);
208 } /* else if (k < 0x3fed8000) */
209 /*-------------------0.921875 <= |x| < 0.953125 ------------------------*/
211 if (k
< 0x3fee8000) {
212 n
= 884+((k
&0x000fe000)>>13)*14;
213 if (m
>0) xx
= x
- asncs
.x
[n
];
214 else xx
= -x
- asncs
.x
[n
];
216 p
=xx
*xx
*(asncs
.x
[n
+2]+xx
*(asncs
.x
[n
+3]+xx
*(asncs
.x
[n
+4]+
217 xx
*(asncs
.x
[n
+5]+xx
*(asncs
.x
[n
+6]
218 +xx
*(asncs
.x
[n
+7]+xx
*(asncs
.x
[n
+8]+
219 xx
*asncs
.x
[n
+9])))))))+asncs
.x
[n
+10];
221 res
=asncs
.x
[n
+11] +t
;
222 cor
= (asncs
.x
[n
+11]-res
)+t
;
223 if (res
== res
+1.01*cor
) return (m
>0)?res
:-res
;
225 r
=asncs
.x
[n
+11]+xx
*asncs
.x
[n
+12];
226 t
=((asncs
.x
[n
+11]-r
)+xx
*asncs
.x
[n
+12])+(p
+xx
*asncs
.x
[n
+13]);
229 if (res
== res
+1.0007*cor
) return (m
>0)?res
:-res
;
237 z
=(w
[0]-ABS(x
))+w
[1];
238 if (z
>1.0e-27) return (m
>0)?min(res
,res1
):-min(res
,res1
);
239 else if (z
<-1.0e-27) return (m
>0)?max(res
,res1
):-max(res
,res1
);
242 return (m
>0)?__sin32(y
,res
,res1
):-__sin32(y
,res
,res1
);
246 } /* else if (k < 0x3fee8000) */
248 /*--------------------0.953125 <= |x| < 0.96875 ------------------------*/
250 if (k
< 0x3fef0000) {
251 n
= 768+((k
&0x000fe000)>>13)*15;
252 if (m
>0) xx
= x
- asncs
.x
[n
];
253 else xx
= -x
- asncs
.x
[n
];
255 p
=xx
*xx
*(asncs
.x
[n
+2]+xx
*(asncs
.x
[n
+3]+xx
*(asncs
.x
[n
+4]+
256 xx
*(asncs
.x
[n
+5]+xx
*(asncs
.x
[n
+6]
257 +xx
*(asncs
.x
[n
+7]+xx
*(asncs
.x
[n
+8]+
258 xx
*(asncs
.x
[n
+9]+xx
*asncs
.x
[n
+10]))))))))+asncs
.x
[n
+11];
260 res
=asncs
.x
[n
+12] +t
;
261 cor
= (asncs
.x
[n
+12]-res
)+t
;
262 if (res
== res
+1.01*cor
) return (m
>0)?res
:-res
;
264 r
=asncs
.x
[n
+12]+xx
*asncs
.x
[n
+13];
265 t
=((asncs
.x
[n
+12]-r
)+xx
*asncs
.x
[n
+13])+(p
+xx
*asncs
.x
[n
+14]);
268 if (res
== res
+1.0007*cor
) return (m
>0)?res
:-res
;
276 z
=(w
[0]-ABS(x
))+w
[1];
277 if (z
>1.0e-27) return (m
>0)?min(res
,res1
):-min(res
,res1
);
278 else if (z
<-1.0e-27) return (m
>0)?max(res
,res1
):-max(res
,res1
);
281 return (m
>0)?__sin32(y
,res
,res1
):-__sin32(y
,res
,res1
);
285 } /* else if (k < 0x3fef0000) */
286 /*--------------------0.96875 <= |x| < 1 --------------------------------*/
289 z
= 0.5*((m
>0)?(1.0-x
):(1.0+x
));
292 t
=inroot
[(k
&0x001fffff)>>14]*powtwo
[511-(k
>>21)];
294 t
= t
*(rt0
+r
*(rt1
+r
*(rt2
+r
*rt3
)));
299 p
=(((((f6
*z
+f5
)*z
+f4
)*z
+f3
)*z
+f2
)*z
+f1
)*z
;
300 cor
= (hp1
.x
- 2.0*cc
)-2.0*(y
+cc
)*p
;
301 res1
= hp0
.x
- 2.0*y
;
303 if (res
== res
+1.003*((res1
-res
)+cor
)) return (m
>0)?res
:-res
;
309 cor
=((hp0
.x
-res1
)-2.0*w
[0])+(hp1
.x
-2.0*w
[1]);
311 cor
= (res1
-res
)+cor
;
312 if (res
==(res
+1.0000001*cor
)) return (m
>0)?res
:-res
;
316 return (m
>0)?__sin32(y
,res
,res1
):-__sin32(y
,res
,res1
);
319 } /* else if (k < 0x3ff00000) */
320 /*---------------------------- |x|>=1 -------------------------------*/
321 else if (k
==0x3ff00000 && u
.i
[LOW_HALF
]==0) return (m
>0)?hp0
.x
:-hp0
.x
;
323 if (k
>0x7ff00000 || (k
== 0x7ff00000 && u
.i
[LOW_HALF
] != 0)) return x
;
325 u
.i
[HIGH_HALF
]=0x7ff00000;
326 v
.i
[HIGH_HALF
]=0x7ff00000;
329 return u
.x
/v
.x
; /* NaN */
332 #ifndef __ieee754_asin
333 strong_alias (__ieee754_asin
, __asin_finite
)
336 /*******************************************************************/
338 /* End of arcsine, below is arccosine */
340 /*******************************************************************/
344 __ieee754_acos(double x
)
346 double x1
,x2
,xx
,s1
,s2
,res1
,p
,t
,res
,r
,cor
,cc
,y
,c
,z
,w
[2],eps
;
358 /*------------------- |x|<2.77556*10^-17 ----------------------*/
359 if (k
< 0x3c880000) return hp0
.x
;
361 /*----------------- 2.77556*10^-17 <= |x| < 2^-3 --------------*/
363 if (k
< 0x3fc00000) {
365 t
= (((((f6
*x2
+ f5
)*x2
+ f4
)*x2
+ f3
)*x2
+ f2
)*x2
+ f1
)*(x2
*x
);
367 cor
=(((hp0
.x
-r
)-x
)+hp1
.x
)-t
;
370 if (res
== res
+1.004*cor
) return res
;
378 s2
= ((((((c7
*xx
+ c6
)*xx
+ c5
)*xx
+ c4
)*xx
+ c3
)*xx
+ c2
)*xx
*xx
*x
+
379 ((a1
.x
+a2
.x
)*x2
*x2
+ 0.5*x1
*x
)*x2
) + a2
.x
*p
;
381 s2
= ((x
-res1
)+s1
)+s2
;
383 cor
=(((hp0
.x
-r
)-res1
)+hp1
.x
)-s2
;
386 if (res
== res
+1.00004*cor
) return res
;
390 cor
=((hp0
.x
-r
)-w
[0])+(hp1
.x
-w
[1]);
393 if (res
==(res
+1.00000001*cor
)) return res
;
396 return __cos32(x
,res
,res1
);
400 } /* else if (k < 0x3fc00000) */
401 /*---------------------- 0.125 <= |x| < 0.5 --------------------*/
403 if (k
< 0x3fe00000) {
404 if (k
<0x3fd00000) n
= 11*((k
&0x000fffff)>>15);
405 else n
= 11*((k
&0x000fffff)>>14)+352;
406 if (m
>0) xx
= x
- asncs
.x
[n
];
407 else xx
= -x
- asncs
.x
[n
];
409 p
=xx
*xx
*(asncs
.x
[n
+2]+xx
*(asncs
.x
[n
+3]+xx
*(asncs
.x
[n
+4]+
410 xx
*(asncs
.x
[n
+5]+xx
*asncs
.x
[n
+6]))))+asncs
.x
[n
+7];
412 y
= (m
>0)?(hp0
.x
-asncs
.x
[n
+8]):(hp0
.x
+asncs
.x
[n
+8]);
413 t
= (m
>0)?(hp1
.x
-t
):(hp1
.x
+t
);
415 if (res
== res
+1.02*((y
-res
)+t
)) return res
;
417 r
=asncs
.x
[n
+8]+xx
*asncs
.x
[n
+9];
418 t
=((asncs
.x
[n
+8]-r
)+xx
*asncs
.x
[n
+9])+(p
+xx
*asncs
.x
[n
+10]);
420 {p
= hp0
.x
-r
; t
= (((hp0
.x
-p
)-r
)-t
)+hp1
.x
; }
422 {p
= hp0
.x
+r
; t
= ((hp0
.x
-p
)+r
)+(hp1
.x
+t
); }
425 if (res
== (res
+1.0002*cor
)) return res
;
431 if (z
>1.0e-27) return max(res
,res1
);
432 else if (z
<-1.0e-27) return min(res
,res1
);
433 else return __cos32(x
,res
,res1
);
436 } /* else if (k < 0x3fe00000) */
438 /*--------------------------- 0.5 <= |x| < 0.75 ---------------------*/
440 if (k
< 0x3fe80000) {
441 n
= 1056+((k
&0x000fe000)>>11)*3;
442 if (m
>0) {xx
= x
- asncs
.x
[n
]; eps
=1.04; }
443 else {xx
= -x
- asncs
.x
[n
]; eps
=1.02; }
445 p
=xx
*xx
*(asncs
.x
[n
+2]+xx
*(asncs
.x
[n
+3]+xx
*(asncs
.x
[n
+4]+
446 xx
*(asncs
.x
[n
+5]+xx
*(asncs
.x
[n
+6]+
447 xx
*asncs
.x
[n
+7])))))+asncs
.x
[n
+8];
449 y
= (m
>0)?(hp0
.x
-asncs
.x
[n
+9]):(hp0
.x
+asncs
.x
[n
+9]);
450 t
= (m
>0)?(hp1
.x
-t
):(hp1
.x
+t
);
452 if (res
== res
+eps
*((y
-res
)+t
)) return res
;
454 r
=asncs
.x
[n
+9]+xx
*asncs
.x
[n
+10];
455 t
=((asncs
.x
[n
+9]-r
)+xx
*asncs
.x
[n
+10])+(p
+xx
*asncs
.x
[n
+11]);
456 if (m
>0) {p
= hp0
.x
-r
; t
= (((hp0
.x
-p
)-r
)-t
)+hp1
.x
; eps
=1.0004; }
457 else {p
= hp0
.x
+r
; t
= ((hp0
.x
-p
)+r
)+(hp1
.x
+t
); eps
=1.0002; }
460 if (res
== (res
+eps
*cor
)) return res
;
466 if (z
>1.0e-27) return max(res
,res1
);
467 else if (z
<-1.0e-27) return min(res
,res1
);
468 else return __cos32(x
,res
,res1
);
471 } /* else if (k < 0x3fe80000) */
473 /*------------------------- 0.75 <= |x| < 0.921875 -------------*/
475 if (k
< 0x3fed8000) {
476 n
= 992+((k
&0x000fe000)>>13)*13;
477 if (m
>0) {xx
= x
- asncs
.x
[n
]; eps
= 1.04; }
478 else {xx
= -x
- asncs
.x
[n
]; eps
= 1.01; }
480 p
=xx
*xx
*(asncs
.x
[n
+2]+xx
*(asncs
.x
[n
+3]+xx
*(asncs
.x
[n
+4]+
481 xx
*(asncs
.x
[n
+5]+xx
*(asncs
.x
[n
+6]+xx
*(asncs
.x
[n
+7]+
482 xx
*asncs
.x
[n
+8]))))))+asncs
.x
[n
+9];
484 y
= (m
>0)?(hp0
.x
-asncs
.x
[n
+10]):(hp0
.x
+asncs
.x
[n
+10]);
485 t
= (m
>0)?(hp1
.x
-t
):(hp1
.x
+t
);
487 if (res
== res
+eps
*((y
-res
)+t
)) return res
;
489 r
=asncs
.x
[n
+10]+xx
*asncs
.x
[n
+11];
490 t
=((asncs
.x
[n
+10]-r
)+xx
*asncs
.x
[n
+11])+(p
+xx
*asncs
.x
[n
+12]);
491 if (m
>0) {p
= hp0
.x
-r
; t
= (((hp0
.x
-p
)-r
)-t
)+hp1
.x
; eps
=1.0032; }
492 else {p
= hp0
.x
+r
; t
= ((hp0
.x
-p
)+r
)+(hp1
.x
+t
); eps
=1.0008; }
495 if (res
== (res
+eps
*cor
)) return res
;
501 if (z
>1.0e-27) return max(res
,res1
);
502 else if (z
<-1.0e-27) return min(res
,res1
);
503 else return __cos32(x
,res
,res1
);
506 } /* else if (k < 0x3fed8000) */
508 /*-------------------0.921875 <= |x| < 0.953125 ------------------*/
510 if (k
< 0x3fee8000) {
511 n
= 884+((k
&0x000fe000)>>13)*14;
512 if (m
>0) {xx
= x
- asncs
.x
[n
]; eps
=1.04; }
513 else {xx
= -x
- asncs
.x
[n
]; eps
=1.005; }
515 p
=xx
*xx
*(asncs
.x
[n
+2]+xx
*(asncs
.x
[n
+3]+xx
*(asncs
.x
[n
+4]+
516 xx
*(asncs
.x
[n
+5]+xx
*(asncs
.x
[n
+6]
517 +xx
*(asncs
.x
[n
+7]+xx
*(asncs
.x
[n
+8]+
518 xx
*asncs
.x
[n
+9])))))))+asncs
.x
[n
+10];
520 y
= (m
>0)?(hp0
.x
-asncs
.x
[n
+11]):(hp0
.x
+asncs
.x
[n
+11]);
521 t
= (m
>0)?(hp1
.x
-t
):(hp1
.x
+t
);
523 if (res
== res
+eps
*((y
-res
)+t
)) return res
;
525 r
=asncs
.x
[n
+11]+xx
*asncs
.x
[n
+12];
526 t
=((asncs
.x
[n
+11]-r
)+xx
*asncs
.x
[n
+12])+(p
+xx
*asncs
.x
[n
+13]);
527 if (m
>0) {p
= hp0
.x
-r
; t
= (((hp0
.x
-p
)-r
)-t
)+hp1
.x
; eps
=1.0030; }
528 else {p
= hp0
.x
+r
; t
= ((hp0
.x
-p
)+r
)+(hp1
.x
+t
); eps
=1.0005; }
531 if (res
== (res
+eps
*cor
)) return res
;
537 if (z
>1.0e-27) return max(res
,res1
);
538 else if (z
<-1.0e-27) return min(res
,res1
);
539 else return __cos32(x
,res
,res1
);
542 } /* else if (k < 0x3fee8000) */
544 /*--------------------0.953125 <= |x| < 0.96875 ----------------*/
546 if (k
< 0x3fef0000) {
547 n
= 768+((k
&0x000fe000)>>13)*15;
548 if (m
>0) {xx
= x
- asncs
.x
[n
]; eps
=1.04; }
549 else {xx
= -x
- asncs
.x
[n
]; eps
=1.005;}
551 p
=xx
*xx
*(asncs
.x
[n
+2]+xx
*(asncs
.x
[n
+3]+xx
*(asncs
.x
[n
+4]+
552 xx
*(asncs
.x
[n
+5]+xx
*(asncs
.x
[n
+6]
553 +xx
*(asncs
.x
[n
+7]+xx
*(asncs
.x
[n
+8]+xx
*(asncs
.x
[n
+9]+
554 xx
*asncs
.x
[n
+10]))))))))+asncs
.x
[n
+11];
556 y
= (m
>0)?(hp0
.x
-asncs
.x
[n
+12]):(hp0
.x
+asncs
.x
[n
+12]);
557 t
= (m
>0)?(hp1
.x
-t
):(hp1
.x
+t
);
559 if (res
== res
+eps
*((y
-res
)+t
)) return res
;
561 r
=asncs
.x
[n
+12]+xx
*asncs
.x
[n
+13];
562 t
=((asncs
.x
[n
+12]-r
)+xx
*asncs
.x
[n
+13])+(p
+xx
*asncs
.x
[n
+14]);
563 if (m
>0) {p
= hp0
.x
-r
; t
= (((hp0
.x
-p
)-r
)-t
)+hp1
.x
; eps
=1.0030; }
564 else {p
= hp0
.x
+r
; t
= ((hp0
.x
-p
)+r
)+(hp1
.x
+t
); eps
=1.0005; }
567 if (res
== (res
+eps
*cor
)) return res
;
573 if (z
>1.0e-27) return max(res
,res1
);
574 else if (z
<-1.0e-27) return min(res
,res1
);
575 else return __cos32(x
,res
,res1
);
578 } /* else if (k < 0x3fef0000) */
579 /*-----------------0.96875 <= |x| < 1 ---------------------------*/
583 z
= 0.5*((m
>0)?(1.0-x
):(1.0+x
));
586 t
=inroot
[(k
&0x001fffff)>>14]*powtwo
[511-(k
>>21)];
588 t
= t
*(rt0
+r
*(rt1
+r
*(rt2
+r
*rt3
)));
593 p
=(((((f6
*z
+f5
)*z
+f4
)*z
+f3
)*z
+f2
)*z
+f1
)*z
;
595 cor
= (hp1
.x
- cc
)-(y
+cc
)*p
;
598 if (res
== res
+1.002*((res1
-res
)+cor
)) return (res
+res
);
604 cor
=((hp0
.x
-res1
)-w
[0])+(hp1
.x
-w
[1]);
606 cor
= (res1
-res
)+cor
;
607 if (res
==(res
+1.000001*cor
)) return (res
+res
);
611 return __cos32(x
,res
,res1
);
618 if (res
== res
+1.03*((y
-res
)+cor
)) return (res
+res
);
625 if (res
==(res
+1.000001*cor
)) return (res
+res
);
629 return __cos32(x
,res
,res1
);
633 } /* else if (k < 0x3ff00000) */
635 /*---------------------------- |x|>=1 -----------------------*/
637 if (k
==0x3ff00000 && u
.i
[LOW_HALF
]==0) return (m
>0)?0:2.0*hp0
.x
;
639 if (k
>0x7ff00000 || (k
== 0x7ff00000 && u
.i
[LOW_HALF
] != 0)) return x
;
641 u
.i
[HIGH_HALF
]=0x7ff00000;
642 v
.i
[HIGH_HALF
]=0x7ff00000;
648 #ifndef __ieee754_acos
649 strong_alias (__ieee754_acos
, __acos_finite
)