math: use Sincos instead of Sin and Cos in Jn and Yn

Change-Id: I0da3857013f1d4e90820fb043314d78924113a27
GitHub-Last-Rev: 7c3d813c6e
GitHub-Pull-Request: golang/go#31019
Reviewed-on: https://go-review.googlesource.com/c/go/+/169078
Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
Neven Sajko 2019-03-25 22:40:27 +00:00 committed by Robert Griesemer
parent e4ba40030f
commit 270de1c110
1 changed files with 10 additions and 10 deletions

View File

@ -103,15 +103,15 @@ func Jn(n int, x float64) float64 {
// 3 s+c c-s
var temp float64
switch n & 3 {
switch s, c := Sincos(x); n & 3 {
case 0:
temp = Cos(x) + Sin(x)
temp = c + s
case 1:
temp = -Cos(x) + Sin(x)
temp = -c + s
case 2:
temp = -Cos(x) - Sin(x)
temp = -c - s
case 3:
temp = Cos(x) - Sin(x)
temp = c - s
}
b = (1 / SqrtPi) * temp / Sqrt(x)
} else {
@ -278,15 +278,15 @@ func Yn(n int, x float64) float64 {
// 3 s+c c-s
var temp float64
switch n & 3 {
switch s, c := Sincos(x); n & 3 {
case 0:
temp = Sin(x) - Cos(x)
temp = s - c
case 1:
temp = -Sin(x) - Cos(x)
temp = -s - c
case 2:
temp = -Sin(x) + Cos(x)
temp = -s + c
case 3:
temp = Sin(x) + Cos(x)
temp = s + c
}
b = (1 / SqrtPi) * temp / Sqrt(x)
} else {