Open cuviper opened 6 years ago
From @stygstra on June 19, 2015 19:1
There isn't much consensus among other languages:
±0.0±0.0i
, but they differ when dividing by ±inf±infi
.±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.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.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.
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?
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.
From @rust-highfive on November 2, 2014 21:42
Issue by huonw Friday Apr 05, 2013 at 08:26 GMT
For earlier discussion, see https://github.com/rust-lang/rust/issues/5736
This issue was labelled with: A-libs, B-RFC, I-wrong in the Rust repository
Should
1/(0+0i)
beNaN+NaN i
or fail, or something else.see also #1284
Copied from original issue: rust-num/num#20