Increase precision of calculation
Show older comments
Hi everyone, I'm experiencing the following wierd situation. I'm executing the same piece of Matlab code in two different PCs (in fact one is my Desktop and the other is the Cluster of our university). In my program I'm saving at some point a variable K. Then if I type in my desktop the command "num2str(K(1,1),'%.20f'') to display the elements of K calculated from the desktop I'm getting the following 33857.67157806616200000000 the same command for the variable K calculated from the Cluster and transfered to my desktop gives 33857.67157806647400000000. In the Cluster I have the option to launch octave (unfortunatelly I cannot do with Matlab in the CLuster) and type the same command and I get 33857.67157806647446705028 which seems to be most accurate. Since both both systems (my desktop and the Cluster) run Matlab whats going on with the Matlab on my desktop is there any way to increase the precision.
Thank you
Giorgos
(Just in case you might wonder why it is so important, K is nearly singular and these very insigificant differences become very large at operations like x=K\b. )
Answers (2)
Walter Roberson
on 1 Jun 2012
0 votes
Giorgos Kourakos
on 4 Jun 2012
0 votes
1 Comment
Walter Roberson
on 4 Jun 2012
The math libraries are not going to be exactly the same for the two operating systems, partly because the compilers optimize differently.
The standard output libraries for Windows apparently do not print long floating point numbers correctly. The libraries for Linux should be able to print in full precision with a %.40f format
Categories
Find more on Quadratic Programming and Cone Programming 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!