uiua-lang / uiua

A stack-based array programming language
https://www.uiua.org
MIT License
1.51k stars 106 forks source link

Bugs with `complex` math #489

Open bkDJ opened 4 months ago

bkDJ commented 4 months ago

Some examples of surprising results. Not sure which should be ignored due to floating point imprecision, and which are actual issues.

ⁿ1/2 ℂ0 ¯1   # NaN
=i √ ℂ0 ¯1   # 0
=ℂ∞ 0 ×i∞    # 0
=ℂ2 0 √ℂ0 ¯4 # 0
kaikalii commented 4 months ago

Lines 2 and 4 were not properly displaying the error bound. I've fixed that in 89f4faf1424875839.

I'm not sure what to do about lines 1 and 3. Line 1 has to do with the fact that for doubles, ⁿ1/2 ¯1 is NaN. Line 3 has to do with the fact that ×0 ∞ is NaN. While these could be fixed with checks in the interpreter, it would slow down complex arithmetic, so I'm not sure it's something I want to do.