Commit 270de1c1 authored by Neven Sajko's avatar Neven Sajko Committed by Robert Griesemer

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/+/169078Reviewed-by: default avatarRobert Griesemer <gri@golang.org>
parent e4ba4003
...@@ -103,15 +103,15 @@ func Jn(n int, x float64) float64 { ...@@ -103,15 +103,15 @@ func Jn(n int, x float64) float64 {
// 3 s+c c-s // 3 s+c c-s
var temp float64 var temp float64
switch n & 3 { switch s, c := Sincos(x); n & 3 {
case 0: case 0:
temp = Cos(x) + Sin(x) temp = c + s
case 1: case 1:
temp = -Cos(x) + Sin(x) temp = -c + s
case 2: case 2:
temp = -Cos(x) - Sin(x) temp = -c - s
case 3: case 3:
temp = Cos(x) - Sin(x) temp = c - s
} }
b = (1 / SqrtPi) * temp / Sqrt(x) b = (1 / SqrtPi) * temp / Sqrt(x)
} else { } else {
...@@ -278,15 +278,15 @@ func Yn(n int, x float64) float64 { ...@@ -278,15 +278,15 @@ func Yn(n int, x float64) float64 {
// 3 s+c c-s // 3 s+c c-s
var temp float64 var temp float64
switch n & 3 { switch s, c := Sincos(x); n & 3 {
case 0: case 0:
temp = Sin(x) - Cos(x) temp = s - c
case 1: case 1:
temp = -Sin(x) - Cos(x) temp = -s - c
case 2: case 2:
temp = -Sin(x) + Cos(x) temp = -s + c
case 3: case 3:
temp = Sin(x) + Cos(x) temp = s + c
} }
b = (1 / SqrtPi) * temp / Sqrt(x) b = (1 / SqrtPi) * temp / Sqrt(x)
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment