From: Neven Sajko Date: Mon, 25 Mar 2019 22:40:27 +0000 (+0000) Subject: math: use Sincos instead of Sin and Cos in Jn and Yn X-Git-Tag: go1.13beta1~903 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=270de1c110221c309c832b526012f3e21b35f581;p=gostls13.git math: use Sincos instead of Sin and Cos in Jn and Yn Change-Id: I0da3857013f1d4e90820fb043314d78924113a27 GitHub-Last-Rev: 7c3d813c6e188a4afda54b736db14370e52b6f94 GitHub-Pull-Request: golang/go#31019 Reviewed-on: https://go-review.googlesource.com/c/go/+/169078 Reviewed-by: Robert Griesemer --- diff --git a/src/math/jn.go b/src/math/jn.go index 4a8ddfad9b..b1aca8ff6b 100644 --- a/src/math/jn.go +++ b/src/math/jn.go @@ -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 {