]> Cypherpunks repositories - gostls13.git/commit
math/cmplx: implement Payne-Hanek range reduction
authorBrian Kessler <brian.m.kessler@gmail.com>
Fri, 12 Apr 2019 04:54:18 +0000 (22:54 -0600)
committerRob Pike <r@golang.org>
Sat, 14 Mar 2020 04:12:41 +0000 (04:12 +0000)
commit70dc28f766194a2b3b050b9c8fab83523164bfbb
treecca7637fc60d24fdda81e35f8441700e48a37223
parente8ecda8a38a1705d2ead985743f287acad34b542
math/cmplx: implement Payne-Hanek range reduction

Tan has poles along the real axis. In order to accurately calculate
the value near these poles, a range reduction by Pi is performed and
the result calculated via a Taylor series.  The prior implementation
of range reduction used Cody-Waite range reduction in three parts.
This fails when x is too large to accurately calculate the partial
products in the summation accurately.  Above this threshold, Payne-Hanek
range reduction using a multiple precision value of 1/Pi is required.

Additionally, the threshold used in math/trig_reduce.go for Payne-Hanek
range reduction was not set conservatively enough. The prior threshold
ensured that catastrophic failure did not occur where the argument x
would not actually be reduced below Pi/4. However, errors in reduction
begin to occur at values much lower when z = ((x - y*PI4A) - y*PI4B) - y*PI4C
is not exact because y*PI4A cannot be exactly represented as a float64.
reduceThreshold is lowered to the proper value.

Fixes #31566

Change-Id: I0f39a4171a5be44f64305f18dc57f6c29f19dba7
Reviewed-on: https://go-review.googlesource.com/c/go/+/172838
Reviewed-by: Rob Pike <r@golang.org>
src/go/build/deps_test.go
src/math/cmplx/cmath_test.go
src/math/cmplx/tan.go
src/math/huge_test.go
src/math/trig_reduce.go