title: Numerical problems in Matlab: Same input, same code -> different output?
body: <p>I am experiencing problems when I compare results from different runs of my Matlab software with the same input. To narrow the problem, I did the following:</p>
  
  <ul>
  <li>save all relevant variables using Matlab's save() method</li>
  <li>call a method which calculates something</li>
  <li>save all relevant output variables again using save()</li>
  </ul>
  
  <p>Without changing the called method, I did another run with </p>
  
  <ul>
  <li>load the variables saved above and compare with the current input variables using isequal()</li>
  <li>call my method again with the current input variables</li>
  <li>load the out variables saved above and compare.</li>
  </ul>
  
  <p>I can't believe the comparison in the last "line" detects slight differences. The calculations include single and double precision numbers, the error is in the magnitude of 1e-10 (the output is a double number).</p>
  
  <p>The only possible explanation I could imagine is that either Matlab looses some precision when saving the variables (which I consider very unlikely, I use the default binary Matlab format) or that there are calculations included like a=b+c+d, which can be calculated as a=(b+c)+d or a=b+(c+d) which might lead to numerical differences. </p>
  
  <p>Do you know what might be the reason for the observations described above? </p>
  
  <p>Thanks a lot!</p>