The easy solution is to use double-precision floating point numbers (torch.DoubleTensor).
I wasn’t suggesting a different ordering: I’m suggesting that you compare double vs. float in a single implementation. You will see relative errors larger than 1e-4 in the small outputs due to cancellation 25.
The point is that this isn’t a mistake or bug. It’s within the expected error due to floating-point arithmetic.