Upgraded Matlab from 2022b to 2023b and I've noticed a floating point error
18 views (last 30 days)
Show older comments
I have recently upgraded my Matlab version from 2022b to 2023b and I have noticed a floating point error when running my code in windows, but not when I run it in linux. I'm sure my code hasn't changed at all so its unclear what's happened. Any ideas why this change has happened?
8 Comments
John D'Errico
on 13 Dec 2023
Note that a difference of 1e-12 MAY be just floating point trash. It completely depends on the size of the other numbers involved. That is, a difference of one bit in the least sigificant bit of different size numbers may easily be as large as 1e-12. eps will tell you that.
eps(1)
eps(10000)
eps(1000000)
So a one bit difference in the least significant bits of the number 10000 is roughly 1e-12. If that is what you are seeing, if the numbers involved in your computation were of that magnitude, then you are probably just seeing floating point trash. The difference may be due to a subtly different version of the BLAS usd by the two different systems, so some numbers may have been added in a different order, getting a subtly different result.
Answers (1)
Steven Lord
on 13 Dec 2023
As others have said it's impossible to give a firm answer with the limited amount of information you provided. Some possibilities:
- We fixed a bug in one of the functions you were using that results in a different answer on Windows. You could check the Release Notes and/or the Bug Reports to see if any major changes affected one or more of the functions you used. [However, note that not all changes and not all bugs are reported in those two sections of the website.]
- We upgraded one of the numeric libraries (to enable new functionality, to improve accuracy, to improve performance, and/or to fix bugs) and the new library version gives an answer that is still correct but is not bit-for-bit identical to the answer in the previous release, perhaps due to a different amount of optimization performed in the library.
- We introduced a new bug in one of the functions you're using.
- The data on which you're operating could have changed.
Just because the answer is different doesn't necessarily mean it's wrong. So is the difference large enough that the answer is wrong or is it different but right? As an example, if the theoretical answer a function (let's say something like the integral function) should return using exact arithmetic was 0.5, the older version gave an answer of 0.49999999, and the newer version gives 0.50000001, is that necessarily wrong or a problem? Impossible to say without more information.
2 Comments
Steven Lord
on 13 Dec 2023
Can you send a MAT-file containing those two variables and that line of code to Technical Support using this link? Please also include information about your computer (if you open the System Information app the OS Name, Version, and Processor are likely the most important pieces of information)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!