from https://ziglang.org/documentation/master/#setFloatMode:
FloatMode.Optimized - Floating point operations may do all of the following:
The idea behind these transformations is to remove the possibility of things that are "not a number" and pretend that we are actually talking about real numbers only. So better to call it something that reflects that rather than call it "fast" or "optimized".
This seems misleading; I'd expect a "mathematical" mode to act predictably and follow mathematical laws, or maybe improve numerical accuracy, but that's not what the fast math flags do. They instead break more laws (you can't even rely on x + y == x + y to be true, for example) and can sometimes worsen numerical accuracy in search of performance.
Perhaps this would make sense if @setFloatMode was renamed to @setFloatAssumptions?
The last three points seem like they can be important even if you don't have any NaNs.
Hm. Having worked extensively on IEEE floating point and alternatives, I don't particularly like calling it "mathematical" (even as much as I hate the non-mathey choices of IEEE 754), because +/- inf are certainly mathematical concepts that 754 tried to incorporate.
At best you might have a claim to "arithmetic", but optimizable, I would think is okay. Is there a distinction here from "fastmath"?
Also with the "insignificant sign on zero", be sure to double check what your impls are doing with sqrt(-0) because some might throw nan, some might return -0.
I find the term mathematical unhelpful, I read it and don't know what it actually means. It doesn't convey anything to me. Something like fast, optimised, fast-math, etc conveys to me that things may be slightly approximate and non-standard for the sake of speed. Sure that isn't the whole story, but I think the current name is more telling.
I agree with others that calling it Mathematical is at best misleading. Basically what FloatMode.Optimized does is relax the well-defined behavior of IEEE floats right? How about FloatMode.Relaxed, which pairs nicely with FloatMode.Strict?
Most helpful comment
I find the term mathematical unhelpful, I read it and don't know what it actually means. It doesn't convey anything to me. Something like fast, optimised, fast-math, etc conveys to me that things may be slightly approximate and non-standard for the sake of speed. Sure that isn't the whole story, but I think the current name is more telling.