1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
8 Floating-point sine and cosine.
10 Coefficients are #5077 from Hart & Cheney. (18.80D)
13 func sinus(x float64, quad int) float64 {
15 P0 = .1357884097877375669092680e8
16 P1 = -.4942908100902844161158627e7
17 P2 = .4401030535375266501944918e6
18 P3 = -.1384727249982452873054457e5
19 P4 = .1459688406665768722226959e3
20 Q0 = .8644558652922534429915149e7
21 Q1 = .4081792252343299749395779e6
22 Q2 = .9463096101538208180571257e4
23 Q3 = .1326534908786136358911494e3
29 x = x * (2 / Pi) /* underflow? */
35 f, _ := Modf(0.25 * e)
40 quad = (quad + int(k)) & 3
51 temp1 := ((((P4*yy+P3)*yy+P2)*yy+P1)*yy + P0) * y
52 temp2 := ((((yy+Q3)*yy+Q2)*yy+Q1)*yy + Q0)
56 // Cos returns the cosine of x.
57 func Cos(x float64) float64 {
64 // Sin returns the sine of x.
65 func Sin(x float64) float64 { return sinus(x, 0) }