| // Copyright 2009 The Go Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| func sinus(x float64, quad int) float64 { |
| // Coefficients are #3370 from Hart & Cheney (18.80D). |
| P0 = .1357884097877375669092680e8; |
| P1 = -.4942908100902844161158627e7; |
| P2 = .4401030535375266501944918e6; |
| P3 = -.1384727249982452873054457e5; |
| P4 = .1459688406665768722226959e3; |
| Q0 = .8644558652922534429915149e7; |
| Q1 = .4081792252343299749395779e6; |
| Q2 = .9463096101538208180571257e4; |
| Q3 = .1326534908786136358911494e3; |
| x = x * (2 / Pi); /* underflow? */ |
| quad = (quad + int(k)) & 3; |
| temp1 := ((((P4*yy+P3)*yy+P2)*yy+P1)*yy + P0) * y; |
| temp2 := ((((yy+Q3)*yy+Q2)*yy+Q1)*yy + Q0); |
| // Cos returns the cosine of x. |
| func Cos(x float64) float64 { |
| // Sin returns the sine of x. |
| func Sin(x float64) float64 { return sinus(x, 0) } |