I am confused, is the matlab answer better or Julia’s?
6 Comments
What exactly are you asking about?
Both Julia and MATLAB define 0/0 to be NaN. Python natively cannot handle 0/0 and throws an error, as your screenshot shows.
According to the official Julia documentation here:
MIN() uses ISLESS() to determine which value is less than the other. Interestingly ISLESS(0,NaN) returns TRUE, so either Julia's MIN() is buggy or Julia's documentation is incorrect. Even more confusingly, the ISLESS() documentation states "Values that are normally unordered, such as NaN, are ordered after regular values", which seems to directly contradict what MIN() does.
Julia's special logic leads to mathematical confusion very quickly. For example, given the relationship A<B<C and the ISLESS() definition above then I would expect
max(A,B)==min(B,C)
to be TRUE if A and B are finite values and C=NaN. But it isn't.
Note that MATLAB treats NaN as being not equal to, not less than, and not greater than any other values (including other NaNs), which is exactly as required by IEEE 754:
Julia does not follow this specification. Why should NaN be greater than the finite values... why not less than the finite values? That seems very arbitrary. In a sense, Julia has redefined Not-A-Number into A-Number-Greater-Than-What-You-Are-Thinking-Of: select any finite number and Julia will happily tell you that your number ISLESS() than NaN.... but confusingly will then return NaN as being both the MIN() and the MAX() of them. Odd.