On Saturday, 15 April 2023 at 16:25:27 UTC-7 Michael Orlitzky wrote: sage: A = matrix([[-3, 2, 1 ], ....: [ 2,-4, 4 ], ....: [ 1, 2,-5 ]]) sage: B = (2 * 0.5 * A) sage: B == A True sage: B.rank() == A.rank() False
I promise you that I know what a floating point number is, and that they aren't the problem. The problem is that reasonable expectations are not met by the Sage user interface. I fail to see what the reasonable expectations are here. As soon as you multiply by "0.5" you now have an "imprecise" result. When people learn to use a scientific calculator properly they are very quickly confronted with the reality that "dots in numbers" lead to arithmetic that isn't quite what we learn in the lower grades of primary school. Do you think we should have "B == A" return false? Indeed, any time equality comparisons are performed between floats, it's almost surely a bug, but if we were to break away from IEEE on this, we'd be failing to meet a whole different array of "reasonable" expectations. Indeed, in Magma "A ==B" would lead to an error rather than a True/False, but unfortunately, Python blows up rather horribly if equality tests don't work (look up the problems for float('nan') in python that also spawn from IEEE conventions that python does implement for floats and then breaks it own expectations). A more reasonably solution might be to have B.rank() return an error, since no useful information will be obtained from computing the rank of a float matrix; particularly because it actually doesn't even try to do the row reduction in a vaguely numerically stable way. The only reason why B.rank() works is because there's a generic algorithm on the matrix class that isn't actively intercepted when the base ring is floaty. A reason to *not* block it is that on interval rings (and p-adics and power series etc. that keep track of their error), the computation may still have some meaning. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/26df7bb9-dbc9-413e-99de-0c867546189fn%40googlegroups.com.