title: Why is the output of inv() and pinv() not equal in Matlab and Octave?
body: <p>I have noticed that if A is a NxN matrix and it has the inverse matrix. But what the inv() and pinv() function output is different.
   - My environment is Win7x64 SP1, Matlab R2012a, Cygwin Octave 3.6.4, FreeMat 4.2</p>
  
  <p>Have a look at the examples from Octave:</p>
  
  <pre><code>A = rand(3,3)
  A =
  0.185987   0.192125   0.046346
  0.140710   0.351007   0.236889
  0.155899   0.107302   0.300623
  
  pinv(A) == inv(A)
  ans =
  0 0 0
  0 0 0
  0 0 0
  </code></pre>
  
  <ul>
  <li>It's all the same <code>ans</code> result by running the same command above in Matlab.</li>
  </ul>
  
  <hr>
  
  <ul>
  <li>And I calculate <code>inv(A)*A</code> or <code>A*inv(A)</code>, the result is identity 3x3 matrix in both Octave and Matlab.</li>
  <li>The result of <code>A*pinv(A)</code> and <code>pinv(A)*A</code> are identity 3x3 matrix in Matlab and FreeMat.</li>
  <li>The result of <code>A*pinv(A)</code> is identity 3x3 matrix in Octave.</li>
  <li>The result of <code>pinv(A)*A</code> is <em>not</em> identity 3x3 matrix in Octave.</li>
  </ul>
  
  <hr>
  
  <p>I don't know the reason why <code>inv(A) != pinv(A)</code>, I have considered the details of the element in the matrix. It seems to be the floating accuracy problem which causes this problem. </p>
  
  <p>The 10+ digits after the dot point may be different like this:</p>
  
  <ul>
  <li><p><code>6.65858991579923298331777914427220821380615200000000</code> element in <code>inv(A)(1,1)</code> against</p></li>
  <li><p><code>6.65858991579923209513935944414697587490081800000000</code> element in <code>pinv(A)(1,1)</code></p></li>
  </ul>