-
Notifications
You must be signed in to change notification settings - Fork 18k
math/cmplx: Cot(0) loops infinitely #17577
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
Comments
Just a drive by comment here, if I recall from my rusty Maths:
I wonder if the package has a problem with detecting this case and should return infinity asap. |
The issue happens due to floating-point comparison here. In this specific case, |
CL https://golang.org/cl/31952 mentions this issue. |
The condition to determine if any further iterations are needed is evaluated to false in case it encounters a NaN. Instead, flip the condition to keep looping until the factor is greater than the machine roundoff error. Updates #17577 Change-Id: I058abe73fcd49d3ae4e2f7b33020437cc8f290c3 Reviewed-on: https://go-review.googlesource.com/31952 Reviewed-by: Robert Griesemer <gri@golang.org>
@0xmohit and @griesemer, did y'all mean to say "Fixes" instead of "Updates" with the CL https://go-review.googlesource.com/31952 that prevents an infinite loop in tanSeries, or is there more work for this issue? |
I probably specified "Updates" because more tests could be added for |
@odeke-em Thanks for heads-up. Yes, I would consider this fixed. |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go1.7 (I tested on play.golang.org)
What did you do?
cmplx.Cot(0) will loop infinitely
let f be a function in the pakcage, and let g be the inverse function of f if f is invertible. If math/cmplx has no error in its implementation, then f(g(z)) is z for a complex z that is well-defined on f and g, which I tested.
but some function calculates wrongly, and some has poor error.
The text was updated successfully, but these errors were encountered: