Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

math/cmplx: TestAtan and friends failing on several platforms #35443

Closed
mknyszek opened this issue Nov 8, 2019 · 3 comments
Closed

math/cmplx: TestAtan and friends failing on several platforms #35443

mknyszek opened this issue Nov 8, 2019 · 3 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@mknyszek
Copy link
Contributor

mknyszek commented Nov 8, 2019

These tests started failing on several platforms as of https://go-review.googlesource.com/c/go/+/169501.

The following platforms are definitely failing:

There may be more, but these are the most visible to me.

@griesemer @bmkessler

@mknyszek mknyszek added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Nov 8, 2019
@mknyszek mknyszek added this to the Go1.14 milestone Nov 8, 2019
@mknyszek mknyszek changed the title math/cmplx: TestAtan, TestLog, TestLog10 failing on several platforms math/cmplx: TestAtan and friends failing on several platforms Nov 8, 2019
@mundaym
Copy link
Member

mundaym commented Nov 8, 2019

/cc @billotosyr for the s390x failures.

I'll try disabling the s390x vector implementations of math.Atan, math.Log and math.Log10 tomorrow. I suspect there could be subtle differences in there that are affecting these new tests (Atan looks like a ~1 ulp difference while the Log/Log10 tests look like zero sign differences).

@gopherbot
Copy link

Change https://golang.org/cl/206037 mentions this issue: Revert "math/cmplx: handle special cases"

@bmkessler
Copy link
Contributor

for s390x

--- FAIL: TestAtan (0.00s)
    cmath_test.go:1018: Atan((1+0i)) = (0.7853981633974484+0i), want (0.7853981633974483+0i)
    cmath_test.go:1026: Atan((1-0i)) = (0.7853981633974484-0i), want (0.7853981633974483-0i)
    cmath_test.go:1030: Atan((-1-0i)) = (-0.7853981633974484-0i), want (-0.7853981633974483-0i)
--- FAIL: TestLog (0.00s)
    cmath_test.go:1163: Log((+Inf-1i)) = (+Inf+0i), want (+Inf-0i)
--- FAIL: TestLog10 (0.00s)
    cmath_test.go:1184: Log10((+Inf-1i)) = (+Inf+0i), want (+Inf-0i)

The first failures are due to the test being too strict for checking the value of math.Atan(re) it should be converted to use cVeryClose instead of cAlike

The failures on Log are actually a discrepancy in s390x handling of math.Atan2(imag(x), real(x))

Log(x) == complex(math.Log(Abs(x)), Phase(x)) == complex(math.Log(Abs(x)), math.Atan2(imag(x), real(x))

so the issue is that math.Atan2(-1, +Inf) should equal -0, but does not on s390x.

Note C99 Annex F. 9.1.4 specifies:

atan2(±y,+∞) returns ± 0 for finite y>0.

But the go documentation for math.Atan2 doesn't actually specify the sign.

// Atan2(y, +Inf) = 0

However, the pure go implementation matches the C99 handling of the sign of zero.

The mips failures

--- FAIL: TestAtan (0.00s)
    cmath_test.go:1030: Atan((-Inf+NaNi)) = (-1.5707963267948966+0i), want (-1.5707963267948966-0i)
--- FAIL: TestCosh (0.00s)
    cmath_test.go:1124: Cosh((-0+NaNi)) = (NaN-0i), want (NaN+0i)
--- FAIL: TestTanh (0.00s)
    cmath_test.go:1357: Tanh((-Inf+NaNi)) = (-1+0i), want (-1-0i)

are due to errors in the test code with respect to NaN sign handling. The tests have cases that check f(x) == f(-x) for appropriate functions, but -x does not necessarily change the sign bit of NaN and math.Copysign should be used instead.

The two issues with the test code are easy fixes, but a decision should be made about the Atan2 special case that disagrees between the Go documentation (s390x implementation) and the C99 standard (pure go implementation).

@golang golang locked and limited conversation to collaborators Nov 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants