13a8617a8SJordan K. Hubbard /* k_cosf.c -- float version of k_cos.c
23a8617a8SJordan K. Hubbard * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
311dc2417SBruce Evans * Debugged and optimized by Bruce D. Evans.
43a8617a8SJordan K. Hubbard */
53a8617a8SJordan K. Hubbard
63a8617a8SJordan K. Hubbard /*
73a8617a8SJordan K. Hubbard * ====================================================
83a8617a8SJordan K. Hubbard * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
93a8617a8SJordan K. Hubbard *
103a8617a8SJordan K. Hubbard * Developed at SunPro, a Sun Microsystems, Inc. business.
113a8617a8SJordan K. Hubbard * Permission to use, copy, modify, and distribute this
123a8617a8SJordan K. Hubbard * software is freely granted, provided that this notice
133a8617a8SJordan K. Hubbard * is preserved.
143a8617a8SJordan K. Hubbard * ====================================================
153a8617a8SJordan K. Hubbard */
163a8617a8SJordan K. Hubbard
173a8617a8SJordan K. Hubbard #include "math.h"
183a8617a8SJordan K. Hubbard #include "math_private.h"
193a8617a8SJordan K. Hubbard
2059aad933SBruce Evans /* |cos(x) - c(x)| < 2**-34.1 (~[-5.37e-11, 5.295e-11]). */
2159aad933SBruce Evans static const double
2211dc2417SBruce Evans one = 1.0,
2359aad933SBruce Evans C0 = -0x1ffffffd0c5e81.0p-54, /* -0.499999997251031003120 */
2459aad933SBruce Evans C1 = 0x155553e1053a42.0p-57, /* 0.0416666233237390631894 */
2559aad933SBruce Evans C2 = -0x16c087e80f1e27.0p-62, /* -0.00138867637746099294692 */
2659aad933SBruce Evans C3 = 0x199342e0ee5069.0p-68; /* 0.0000243904487962774090654 */
273a8617a8SJordan K. Hubbard
28*2b795b29SDimitry Andric #ifdef INLINE_KERNEL_COSDF
29*2b795b29SDimitry Andric static __inline
304ce51209SBruce Evans #endif
31*2b795b29SDimitry Andric float
__kernel_cosdf(double x)3259aad933SBruce Evans __kernel_cosdf(double x)
333a8617a8SJordan K. Hubbard {
34f4b01a9eSBruce Evans double r, w, z;
353b46e988SBruce Evans
36f4b01a9eSBruce Evans /* Try to optimize for parallel evaluation as in k_tanf.c. */
373a8617a8SJordan K. Hubbard z = x*x;
38f4b01a9eSBruce Evans w = z*z;
39f4b01a9eSBruce Evans r = C2+z*C3;
40f4b01a9eSBruce Evans return ((one+z*C0) + w*C1) + (w*z)*r;
413a8617a8SJordan K. Hubbard }
42