Complex.js icon indicating copy to clipboard operation
Complex.js copied to clipboard

Should infinite values be considered equal?

Open harrysarson opened this issue 8 years ago • 1 comments

Currently: new Complex(Infinity).equals(Infinity) === false.

For reference:

In JavaScript: Infinity === Infinity is true In Matlab both Inf == Inf and (Inf + Inf*i) == (Inf + Inf*i) aretrue In Wolfram 'Infinity == Infinityistrueand it refuses to answerComplexInfinity == ComplexInfinity` The c++ standard complex library compares the real and imaginary parts of the number.

harrysarson avatar Oct 18 '17 15:10 harrysarson

Comparing re and im is done here as well, but not in a == manner but comparing against a rounding-error ignoring small epsilon. And since Inf-Inf =Inf > eps it is currently false. We could either add a special infinity check here or we keep it like this. I mean it's a philosophical question and totally depends on how you see infinity. When you say there are infinitely many infinites, then the current behavior is right. If you see it as a symbol comparision then we should follow other implementations

infusion avatar Jan 28 '18 22:01 infusion