2 * IBM Accurate Mathematical Library
3 * written by International Business Machines Corp.
4 * Copyright (C) 2001-2014 Free Software Foundation, Inc.
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];
68 k
= 0x7fffffff&m
; /* no sign */
70 if (k
< 0x3e500000) return x
; /* for x->0 => sin(x)=x */
71 /*----------------------2^-26 <= |x| < 2^ -3 -----------------*/
75 t
= (((((f6
*x2
+ f5
)*x2
+ f4
)*x2
+ f3
)*x2
+ f2
)*x2
+ f1
)*(x2
*x
);
76 res
= x
+t
; /* res=arcsin(x) according to Taylor series */
78 if (res
== res
+1.025*cor
) return res
;
86 s2
= ((((((c7
*xx
+ c6
)*xx
+ c5
)*xx
+ c4
)*xx
+ c3
)*xx
+ c2
)*xx
*xx
*x
+
87 ((a1
.x
+a2
.x
)*x2
*x2
+ 0.5*x1
*x
)*x2
) + a2
.x
*p
;
89 s2
= ((x
-res1
)+s1
)+s2
;
92 if (res
== res
+1.00014*cor
) return res
;
95 if (w
[0]==(w
[0]+1.00000001*w
[1])) return w
[0];
99 res1
=ABS(w
[0]+1.1*w
[1]);
100 return (m
>0)?__sin32(y
,res
,res1
):-__sin32(y
,res
,res1
);
105 /*---------------------0.125 <= |x| < 0.5 -----------------------------*/
106 else if (k
< 0x3fe00000) {
107 if (k
<0x3fd00000) n
= 11*((k
&0x000fffff)>>15);
108 else n
= 11*((k
&0x000fffff)>>14)+352;
109 if (m
>0) xx
= x
- asncs
.x
[n
];
110 else xx
= -x
- asncs
.x
[n
];
112 p
=xx
*xx
*(asncs
.x
[n
+2]+xx
*(asncs
.x
[n
+3]+xx
*(asncs
.x
[n
+4]+xx
*(asncs
.x
[n
+5]
113 +xx
*asncs
.x
[n
+6]))))+asncs
.x
[n
+7];
115 res
=asncs
.x
[n
+8] +t
;
116 cor
= (asncs
.x
[n
+8]-res
)+t
;
117 if (res
== res
+1.05*cor
) return (m
>0)?res
:-res
;
119 r
=asncs
.x
[n
+8]+xx
*asncs
.x
[n
+9];
120 t
=((asncs
.x
[n
+8]-r
)+xx
*asncs
.x
[n
+9])+(p
+xx
*asncs
.x
[n
+10]);
123 if (res
== res
+1.0005*cor
) return (m
>0)?res
:-res
;
128 z
=(w
[0]-ABS(x
))+w
[1];
129 if (z
>1.0e-27) return (m
>0)?min(res
,res1
):-min(res
,res1
);
130 else if (z
<-1.0e-27) return (m
>0)?max(res
,res1
):-max(res
,res1
);
133 return (m
>0)?__sin32(y
,res
,res1
):-__sin32(y
,res
,res1
);
137 } /* else if (k < 0x3fe00000) */
138 /*-------------------- 0.5 <= |x| < 0.75 -----------------------------*/
140 if (k
< 0x3fe80000) {
141 n
= 1056+((k
&0x000fe000)>>11)*3;
142 if (m
>0) xx
= x
- asncs
.x
[n
];
143 else xx
= -x
- asncs
.x
[n
];
145 p
=xx
*xx
*(asncs
.x
[n
+2]+xx
*(asncs
.x
[n
+3]+xx
*(asncs
.x
[n
+4]+xx
*(asncs
.x
[n
+5]
146 +xx
*(asncs
.x
[n
+6]+xx
*asncs
.x
[n
+7])))))+asncs
.x
[n
+8];
148 res
=asncs
.x
[n
+9] +t
;
149 cor
= (asncs
.x
[n
+9]-res
)+t
;
150 if (res
== res
+1.01*cor
) return (m
>0)?res
:-res
;
152 r
=asncs
.x
[n
+9]+xx
*asncs
.x
[n
+10];
153 t
=((asncs
.x
[n
+9]-r
)+xx
*asncs
.x
[n
+10])+(p
+xx
*asncs
.x
[n
+11]);
156 if (res
== res
+1.0005*cor
) return (m
>0)?res
:-res
;
161 z
=(w
[0]-ABS(x
))+w
[1];
162 if (z
>1.0e-27) return (m
>0)?min(res
,res1
):-min(res
,res1
);
163 else if (z
<-1.0e-27) return (m
>0)?max(res
,res1
):-max(res
,res1
);
166 return (m
>0)?__sin32(y
,res
,res1
):-__sin32(y
,res
,res1
);
170 } /* else if (k < 0x3fe80000) */
171 /*--------------------- 0.75 <= |x|< 0.921875 ----------------------*/
173 if (k
< 0x3fed8000) {
174 n
= 992+((k
&0x000fe000)>>13)*13;
175 if (m
>0) xx
= x
- asncs
.x
[n
];
176 else xx
= -x
- asncs
.x
[n
];
178 p
=xx
*xx
*(asncs
.x
[n
+2]+xx
*(asncs
.x
[n
+3]+xx
*(asncs
.x
[n
+4]+xx
*(asncs
.x
[n
+5]
179 +xx
*(asncs
.x
[n
+6]+xx
*(asncs
.x
[n
+7]+xx
*asncs
.x
[n
+8]))))))+asncs
.x
[n
+9];
181 res
=asncs
.x
[n
+10] +t
;
182 cor
= (asncs
.x
[n
+10]-res
)+t
;
183 if (res
== res
+1.01*cor
) return (m
>0)?res
:-res
;
185 r
=asncs
.x
[n
+10]+xx
*asncs
.x
[n
+11];
186 t
=((asncs
.x
[n
+10]-r
)+xx
*asncs
.x
[n
+11])+(p
+xx
*asncs
.x
[n
+12]);
189 if (res
== res
+1.0008*cor
) return (m
>0)?res
:-res
;
194 z
=((hp0
.x
-y
)-res
)+(hp1
.x
-z
);
196 z
=(w
[0]-ABS(x
))+w
[1];
197 if (z
>1.0e-27) return (m
>0)?min(res
,res1
):-min(res
,res1
);
198 else if (z
<-1.0e-27) return (m
>0)?max(res
,res1
):-max(res
,res1
);
201 return (m
>0)?__sin32(y
,res
,res1
):-__sin32(y
,res
,res1
);
205 } /* else if (k < 0x3fed8000) */
206 /*-------------------0.921875 <= |x| < 0.953125 ------------------------*/
208 if (k
< 0x3fee8000) {
209 n
= 884+((k
&0x000fe000)>>13)*14;
210 if (m
>0) xx
= x
- asncs
.x
[n
];
211 else xx
= -x
- asncs
.x
[n
];
213 p
=xx
*xx
*(asncs
.x
[n
+2]+xx
*(asncs
.x
[n
+3]+xx
*(asncs
.x
[n
+4]+
214 xx
*(asncs
.x
[n
+5]+xx
*(asncs
.x
[n
+6]
215 +xx
*(asncs
.x
[n
+7]+xx
*(asncs
.x
[n
+8]+
216 xx
*asncs
.x
[n
+9])))))))+asncs
.x
[n
+10];
218 res
=asncs
.x
[n
+11] +t
;
219 cor
= (asncs
.x
[n
+11]-res
)+t
;
220 if (res
== res
+1.01*cor
) return (m
>0)?res
:-res
;
222 r
=asncs
.x
[n
+11]+xx
*asncs
.x
[n
+12];
223 t
=((asncs
.x
[n
+11]-r
)+xx
*asncs
.x
[n
+12])+(p
+xx
*asncs
.x
[n
+13]);
226 if (res
== res
+1.0007*cor
) return (m
>0)?res
:-res
;
234 z
=(w
[0]-ABS(x
))+w
[1];
235 if (z
>1.0e-27) return (m
>0)?min(res
,res1
):-min(res
,res1
);
236 else if (z
<-1.0e-27) return (m
>0)?max(res
,res1
):-max(res
,res1
);
239 return (m
>0)?__sin32(y
,res
,res1
):-__sin32(y
,res
,res1
);
243 } /* else if (k < 0x3fee8000) */
245 /*--------------------0.953125 <= |x| < 0.96875 ------------------------*/
247 if (k
< 0x3fef0000) {
248 n
= 768+((k
&0x000fe000)>>13)*15;
249 if (m
>0) xx
= x
- asncs
.x
[n
];
250 else xx
= -x
- asncs
.x
[n
];
252 p
=xx
*xx
*(asncs
.x
[n
+2]+xx
*(asncs
.x
[n
+3]+xx
*(asncs
.x
[n
+4]+
253 xx
*(asncs
.x
[n
+5]+xx
*(asncs
.x
[n
+6]
254 +xx
*(asncs
.x
[n
+7]+xx
*(asncs
.x
[n
+8]+
255 xx
*(asncs
.x
[n
+9]+xx
*asncs
.x
[n
+10]))))))))+asncs
.x
[n
+11];
257 res
=asncs
.x
[n
+12] +t
;
258 cor
= (asncs
.x
[n
+12]-res
)+t
;
259 if (res
== res
+1.01*cor
) return (m
>0)?res
:-res
;
261 r
=asncs
.x
[n
+12]+xx
*asncs
.x
[n
+13];
262 t
=((asncs
.x
[n
+12]-r
)+xx
*asncs
.x
[n
+13])+(p
+xx
*asncs
.x
[n
+14]);
265 if (res
== res
+1.0007*cor
) return (m
>0)?res
:-res
;
273 z
=(w
[0]-ABS(x
))+w
[1];
274 if (z
>1.0e-27) return (m
>0)?min(res
,res1
):-min(res
,res1
);
275 else if (z
<-1.0e-27) return (m
>0)?max(res
,res1
):-max(res
,res1
);
278 return (m
>0)?__sin32(y
,res
,res1
):-__sin32(y
,res
,res1
);
282 } /* else if (k < 0x3fef0000) */
283 /*--------------------0.96875 <= |x| < 1 --------------------------------*/
286 z
= 0.5*((m
>0)?(1.0-x
):(1.0+x
));
289 t
=inroot
[(k
&0x001fffff)>>14]*powtwo
[511-(k
>>21)];
291 t
= t
*(rt0
+r
*(rt1
+r
*(rt2
+r
*rt3
)));
296 p
=(((((f6
*z
+f5
)*z
+f4
)*z
+f3
)*z
+f2
)*z
+f1
)*z
;
297 cor
= (hp1
.x
- 2.0*cc
)-2.0*(y
+cc
)*p
;
298 res1
= hp0
.x
- 2.0*y
;
300 if (res
== res
+1.003*((res1
-res
)+cor
)) return (m
>0)?res
:-res
;
306 cor
=((hp0
.x
-res1
)-2.0*w
[0])+(hp1
.x
-2.0*w
[1]);
308 cor
= (res1
-res
)+cor
;
309 if (res
==(res
+1.0000001*cor
)) return (m
>0)?res
:-res
;
313 return (m
>0)?__sin32(y
,res
,res1
):-__sin32(y
,res
,res1
);
316 } /* else if (k < 0x3ff00000) */
317 /*---------------------------- |x|>=1 -------------------------------*/
318 else if (k
==0x3ff00000 && u
.i
[LOW_HALF
]==0) return (m
>0)?hp0
.x
:-hp0
.x
;
320 if (k
>0x7ff00000 || (k
== 0x7ff00000 && u
.i
[LOW_HALF
] != 0)) return x
;
322 u
.i
[HIGH_HALF
]=0x7ff00000;
323 v
.i
[HIGH_HALF
]=0x7ff00000;
326 return u
.x
/v
.x
; /* NaN */
329 #ifndef __ieee754_asin
330 strong_alias (__ieee754_asin
, __asin_finite
)
333 /*******************************************************************/
335 /* End of arcsine, below is arccosine */
337 /*******************************************************************/
341 __ieee754_acos(double x
)
343 double x1
,x2
,xx
,s1
,s2
,res1
,p
,t
,res
,r
,cor
,cc
,y
,c
,z
,w
[2],eps
;
349 /*------------------- |x|<2.77556*10^-17 ----------------------*/
350 if (k
< 0x3c880000) return hp0
.x
;
352 /*----------------- 2.77556*10^-17 <= |x| < 2^-3 --------------*/
354 if (k
< 0x3fc00000) {
356 t
= (((((f6
*x2
+ f5
)*x2
+ f4
)*x2
+ f3
)*x2
+ f2
)*x2
+ f1
)*(x2
*x
);
358 cor
=(((hp0
.x
-r
)-x
)+hp1
.x
)-t
;
361 if (res
== res
+1.004*cor
) return res
;
369 s2
= ((((((c7
*xx
+ c6
)*xx
+ c5
)*xx
+ c4
)*xx
+ c3
)*xx
+ c2
)*xx
*xx
*x
+
370 ((a1
.x
+a2
.x
)*x2
*x2
+ 0.5*x1
*x
)*x2
) + a2
.x
*p
;
372 s2
= ((x
-res1
)+s1
)+s2
;
374 cor
=(((hp0
.x
-r
)-res1
)+hp1
.x
)-s2
;
377 if (res
== res
+1.00004*cor
) return res
;
381 cor
=((hp0
.x
-r
)-w
[0])+(hp1
.x
-w
[1]);
384 if (res
==(res
+1.00000001*cor
)) return res
;
387 return __cos32(x
,res
,res1
);
391 } /* else if (k < 0x3fc00000) */
392 /*---------------------- 0.125 <= |x| < 0.5 --------------------*/
394 if (k
< 0x3fe00000) {
395 if (k
<0x3fd00000) n
= 11*((k
&0x000fffff)>>15);
396 else n
= 11*((k
&0x000fffff)>>14)+352;
397 if (m
>0) xx
= x
- asncs
.x
[n
];
398 else xx
= -x
- asncs
.x
[n
];
400 p
=xx
*xx
*(asncs
.x
[n
+2]+xx
*(asncs
.x
[n
+3]+xx
*(asncs
.x
[n
+4]+
401 xx
*(asncs
.x
[n
+5]+xx
*asncs
.x
[n
+6]))))+asncs
.x
[n
+7];
403 y
= (m
>0)?(hp0
.x
-asncs
.x
[n
+8]):(hp0
.x
+asncs
.x
[n
+8]);
404 t
= (m
>0)?(hp1
.x
-t
):(hp1
.x
+t
);
406 if (res
== res
+1.02*((y
-res
)+t
)) return res
;
408 r
=asncs
.x
[n
+8]+xx
*asncs
.x
[n
+9];
409 t
=((asncs
.x
[n
+8]-r
)+xx
*asncs
.x
[n
+9])+(p
+xx
*asncs
.x
[n
+10]);
411 {p
= hp0
.x
-r
; t
= (((hp0
.x
-p
)-r
)-t
)+hp1
.x
; }
413 {p
= hp0
.x
+r
; t
= ((hp0
.x
-p
)+r
)+(hp1
.x
+t
); }
416 if (res
== (res
+1.0002*cor
)) return res
;
422 if (z
>1.0e-27) return max(res
,res1
);
423 else if (z
<-1.0e-27) return min(res
,res1
);
424 else return __cos32(x
,res
,res1
);
427 } /* else if (k < 0x3fe00000) */
429 /*--------------------------- 0.5 <= |x| < 0.75 ---------------------*/
431 if (k
< 0x3fe80000) {
432 n
= 1056+((k
&0x000fe000)>>11)*3;
433 if (m
>0) {xx
= x
- asncs
.x
[n
]; eps
=1.04; }
434 else {xx
= -x
- asncs
.x
[n
]; eps
=1.02; }
436 p
=xx
*xx
*(asncs
.x
[n
+2]+xx
*(asncs
.x
[n
+3]+xx
*(asncs
.x
[n
+4]+
437 xx
*(asncs
.x
[n
+5]+xx
*(asncs
.x
[n
+6]+
438 xx
*asncs
.x
[n
+7])))))+asncs
.x
[n
+8];
440 y
= (m
>0)?(hp0
.x
-asncs
.x
[n
+9]):(hp0
.x
+asncs
.x
[n
+9]);
441 t
= (m
>0)?(hp1
.x
-t
):(hp1
.x
+t
);
443 if (res
== res
+eps
*((y
-res
)+t
)) return res
;
445 r
=asncs
.x
[n
+9]+xx
*asncs
.x
[n
+10];
446 t
=((asncs
.x
[n
+9]-r
)+xx
*asncs
.x
[n
+10])+(p
+xx
*asncs
.x
[n
+11]);
447 if (m
>0) {p
= hp0
.x
-r
; t
= (((hp0
.x
-p
)-r
)-t
)+hp1
.x
; eps
=1.0004; }
448 else {p
= hp0
.x
+r
; t
= ((hp0
.x
-p
)+r
)+(hp1
.x
+t
); eps
=1.0002; }
451 if (res
== (res
+eps
*cor
)) return res
;
457 if (z
>1.0e-27) return max(res
,res1
);
458 else if (z
<-1.0e-27) return min(res
,res1
);
459 else return __cos32(x
,res
,res1
);
462 } /* else if (k < 0x3fe80000) */
464 /*------------------------- 0.75 <= |x| < 0.921875 -------------*/
466 if (k
< 0x3fed8000) {
467 n
= 992+((k
&0x000fe000)>>13)*13;
468 if (m
>0) {xx
= x
- asncs
.x
[n
]; eps
= 1.04; }
469 else {xx
= -x
- asncs
.x
[n
]; eps
= 1.01; }
471 p
=xx
*xx
*(asncs
.x
[n
+2]+xx
*(asncs
.x
[n
+3]+xx
*(asncs
.x
[n
+4]+
472 xx
*(asncs
.x
[n
+5]+xx
*(asncs
.x
[n
+6]+xx
*(asncs
.x
[n
+7]+
473 xx
*asncs
.x
[n
+8]))))))+asncs
.x
[n
+9];
475 y
= (m
>0)?(hp0
.x
-asncs
.x
[n
+10]):(hp0
.x
+asncs
.x
[n
+10]);
476 t
= (m
>0)?(hp1
.x
-t
):(hp1
.x
+t
);
478 if (res
== res
+eps
*((y
-res
)+t
)) return res
;
480 r
=asncs
.x
[n
+10]+xx
*asncs
.x
[n
+11];
481 t
=((asncs
.x
[n
+10]-r
)+xx
*asncs
.x
[n
+11])+(p
+xx
*asncs
.x
[n
+12]);
482 if (m
>0) {p
= hp0
.x
-r
; t
= (((hp0
.x
-p
)-r
)-t
)+hp1
.x
; eps
=1.0032; }
483 else {p
= hp0
.x
+r
; t
= ((hp0
.x
-p
)+r
)+(hp1
.x
+t
); eps
=1.0008; }
486 if (res
== (res
+eps
*cor
)) return res
;
492 if (z
>1.0e-27) return max(res
,res1
);
493 else if (z
<-1.0e-27) return min(res
,res1
);
494 else return __cos32(x
,res
,res1
);
497 } /* else if (k < 0x3fed8000) */
499 /*-------------------0.921875 <= |x| < 0.953125 ------------------*/
501 if (k
< 0x3fee8000) {
502 n
= 884+((k
&0x000fe000)>>13)*14;
503 if (m
>0) {xx
= x
- asncs
.x
[n
]; eps
=1.04; }
504 else {xx
= -x
- asncs
.x
[n
]; eps
=1.005; }
506 p
=xx
*xx
*(asncs
.x
[n
+2]+xx
*(asncs
.x
[n
+3]+xx
*(asncs
.x
[n
+4]+
507 xx
*(asncs
.x
[n
+5]+xx
*(asncs
.x
[n
+6]
508 +xx
*(asncs
.x
[n
+7]+xx
*(asncs
.x
[n
+8]+
509 xx
*asncs
.x
[n
+9])))))))+asncs
.x
[n
+10];
511 y
= (m
>0)?(hp0
.x
-asncs
.x
[n
+11]):(hp0
.x
+asncs
.x
[n
+11]);
512 t
= (m
>0)?(hp1
.x
-t
):(hp1
.x
+t
);
514 if (res
== res
+eps
*((y
-res
)+t
)) return res
;
516 r
=asncs
.x
[n
+11]+xx
*asncs
.x
[n
+12];
517 t
=((asncs
.x
[n
+11]-r
)+xx
*asncs
.x
[n
+12])+(p
+xx
*asncs
.x
[n
+13]);
518 if (m
>0) {p
= hp0
.x
-r
; t
= (((hp0
.x
-p
)-r
)-t
)+hp1
.x
; eps
=1.0030; }
519 else {p
= hp0
.x
+r
; t
= ((hp0
.x
-p
)+r
)+(hp1
.x
+t
); eps
=1.0005; }
522 if (res
== (res
+eps
*cor
)) return res
;
528 if (z
>1.0e-27) return max(res
,res1
);
529 else if (z
<-1.0e-27) return min(res
,res1
);
530 else return __cos32(x
,res
,res1
);
533 } /* else if (k < 0x3fee8000) */
535 /*--------------------0.953125 <= |x| < 0.96875 ----------------*/
537 if (k
< 0x3fef0000) {
538 n
= 768+((k
&0x000fe000)>>13)*15;
539 if (m
>0) {xx
= x
- asncs
.x
[n
]; eps
=1.04; }
540 else {xx
= -x
- asncs
.x
[n
]; eps
=1.005;}
542 p
=xx
*xx
*(asncs
.x
[n
+2]+xx
*(asncs
.x
[n
+3]+xx
*(asncs
.x
[n
+4]+
543 xx
*(asncs
.x
[n
+5]+xx
*(asncs
.x
[n
+6]
544 +xx
*(asncs
.x
[n
+7]+xx
*(asncs
.x
[n
+8]+xx
*(asncs
.x
[n
+9]+
545 xx
*asncs
.x
[n
+10]))))))))+asncs
.x
[n
+11];
547 y
= (m
>0)?(hp0
.x
-asncs
.x
[n
+12]):(hp0
.x
+asncs
.x
[n
+12]);
548 t
= (m
>0)?(hp1
.x
-t
):(hp1
.x
+t
);
550 if (res
== res
+eps
*((y
-res
)+t
)) return res
;
552 r
=asncs
.x
[n
+12]+xx
*asncs
.x
[n
+13];
553 t
=((asncs
.x
[n
+12]-r
)+xx
*asncs
.x
[n
+13])+(p
+xx
*asncs
.x
[n
+14]);
554 if (m
>0) {p
= hp0
.x
-r
; t
= (((hp0
.x
-p
)-r
)-t
)+hp1
.x
; eps
=1.0030; }
555 else {p
= hp0
.x
+r
; t
= ((hp0
.x
-p
)+r
)+(hp1
.x
+t
); eps
=1.0005; }
558 if (res
== (res
+eps
*cor
)) return res
;
564 if (z
>1.0e-27) return max(res
,res1
);
565 else if (z
<-1.0e-27) return min(res
,res1
);
566 else return __cos32(x
,res
,res1
);
569 } /* else if (k < 0x3fef0000) */
570 /*-----------------0.96875 <= |x| < 1 ---------------------------*/
574 z
= 0.5*((m
>0)?(1.0-x
):(1.0+x
));
577 t
=inroot
[(k
&0x001fffff)>>14]*powtwo
[511-(k
>>21)];
579 t
= t
*(rt0
+r
*(rt1
+r
*(rt2
+r
*rt3
)));
584 p
=(((((f6
*z
+f5
)*z
+f4
)*z
+f3
)*z
+f2
)*z
+f1
)*z
;
586 cor
= (hp1
.x
- cc
)-(y
+cc
)*p
;
589 if (res
== res
+1.002*((res1
-res
)+cor
)) return (res
+res
);
595 cor
=((hp0
.x
-res1
)-w
[0])+(hp1
.x
-w
[1]);
597 cor
= (res1
-res
)+cor
;
598 if (res
==(res
+1.000001*cor
)) return (res
+res
);
602 return __cos32(x
,res
,res1
);
609 if (res
== res
+1.03*((y
-res
)+cor
)) return (res
+res
);
616 if (res
==(res
+1.000001*cor
)) return (res
+res
);
620 return __cos32(x
,res
,res1
);
624 } /* else if (k < 0x3ff00000) */
626 /*---------------------------- |x|>=1 -----------------------*/
628 if (k
==0x3ff00000 && u
.i
[LOW_HALF
]==0) return (m
>0)?0:2.0*hp0
.x
;
630 if (k
>0x7ff00000 || (k
== 0x7ff00000 && u
.i
[LOW_HALF
] != 0)) return x
;
632 u
.i
[HIGH_HALF
]=0x7ff00000;
633 v
.i
[HIGH_HALF
]=0x7ff00000;
639 #ifndef __ieee754_acos
640 strong_alias (__ieee754_acos
, __acos_finite
)