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

Cmplx division by 0 and NaN #5

Open
cuviper opened this issue Dec 19, 2017 · 4 comments
Open

Cmplx division by 0 and NaN #5

cuviper opened this issue Dec 19, 2017 · 4 comments

Comments

@cuviper
Copy link
Member

cuviper commented Dec 19, 2017

From @rust-highfive on November 2, 2014 21:42

Issue by huonw
Friday Apr 05, 2013 at 08:26 GMT

For earlier discussion, see rust-lang/rust#5736

This issue was labelled with: A-libs, B-RFC, I-wrong in the Rust repository


Should 1/(0+0i) be NaN+NaN i or fail, or something else.

see also #1284

Copied from original issue: rust-num/num#20

@cuviper
Copy link
Member Author

cuviper commented Dec 19, 2017

From @stygstra on June 19, 2015 19:1

There isn't much consensus among other languages:

  • C++ and Racket agree when dividing by ±0.0±0.0i, but they differ when dividing by ±inf±infi.
  • Python rejects division by ±0.0±0.0i, gives NaN+NaNi when dividing by a complex number where both components are infinite, and gives ±0.0±0.0i when dividing by a complex number with exactly one infinite component.
  • Julia gives NaN+NaNi when dividing by ±0.0±0.0i and gives ±0.0±0.0i when dividing by a complex number where one or both of the components is infinite.

@shingtaklam1324
Copy link
Contributor

Wolfram Alpha gives the answer of Complex infinity, which I think is more mathematically accurate, but not sure of the actual implementation.

In Golang's cmplx package, Complex infinity is represented as inf + inf i, and I can't find other implementations that specifically mention complex infinity.

@thyrgle
Copy link

thyrgle commented Nov 19, 2018

I think that either an error or NaN is the best choice. From what I understand infinity is often introduced to compactify the space. In this case, adding infinity to the usual complex plane gives the Riemann Sphere. However, maybe some utility should be included to differentiate between standard and compacted spaces?

@sourcefrog
Copy link

I see that f64::recip gives inf (run) so it seems like it would be nice to be consistent with that, or at least to have one method that is consistent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants