]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - lib/msun/ld128/k_cosl.c
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / lib / msun / ld128 / k_cosl.c
1 /* From: @(#)k_cos.c 1.3 95/01/18 */
2 /*
3  * ====================================================
4  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
5  * Copyright (c) 2008 Steven G. Kargl, David Schultz, Bruce D. Evans.
6  *
7  * Developed at SunSoft, a Sun Microsystems, Inc. business.
8  * Permission to use, copy, modify, and distribute this
9  * software is freely granted, provided that this notice 
10  * is preserved.
11  * ====================================================
12  */
13
14 #include <sys/cdefs.h>
15 __FBSDID("$FreeBSD$");
16
17 /*
18  * ld128 version of k_cos.c.  See ../src/k_cos.c for most comments.
19  */
20
21 #include "math_private.h"
22
23 /*
24  * Domain [-0.7854, 0.7854], range ~[-1.80e-37, 1.79e-37]:
25  * |cos(x) - c(x))| < 2**-122.0
26  *
27  * 113-bit precision requires more care than 64-bit precision, since
28  * simple methods give a minimax polynomial with coefficient for x^2
29  * that is 1 ulp below 0.5, but we want it to be precisely 0.5.  See
30  * ../ld80/k_cosl.c for more details.
31  */
32 static const double
33 one = 1.0;
34
35 static const long double
36 C1 =  0.04166666666666666666666666666666658424671L,
37 C2 = -0.001388888888888888888888888888863490893732L,
38 C3 =  0.00002480158730158730158730158600795304914210L,
39 C4 = -0.2755731922398589065255474947078934284324e-6L,
40 C5 =  0.2087675698786809897659225313136400793948e-8L,
41 C6 = -0.1147074559772972315817149986812031204775e-10L,
42 C7 =  0.4779477332386808976875457937252120293400e-13L;
43
44 static const double
45 C8 = -0.1561920696721507929516718307820958119868e-15,
46 C9 =  0.4110317413744594971475941557607804508039e-18,
47 C10 = -0.8896592467191938803288521958313920156409e-21,
48 C11 =  0.1601061435794535138244346256065192782581e-23;
49
50 long double
51 __kernel_cosl(long double x, long double y)
52 {
53         long double hz,z,r,w;
54
55         z  = x*x;
56         r  = z*(C1+z*(C2+z*(C3+z*(C4+z*(C5+z*(C6+z*(C7+
57             z*(C8+z*(C9+z*(C10+z*C11))))))))));
58         hz = 0.5*z;
59         w  = one-hz;
60         return w + (((one-w)-hz) + (z*r-x*y));
61 }