title: Compute pseudoinverse by hand
body: <p>I follow the formula on wiki: </p>
  
  <p><a href="http://en.wikipedia.org/wiki/Pseudo_inverse" rel="nofollow">http://en.wikipedia.org/wiki/Pseudo_inverse</a> </p>
  
  <p>to compute pseudoinverse but i can not receive the right result. for example:
  I want to find <code>theta</code> of the equation: <code>Y=R*theta</code>, i write on matlab:</p>
  
  <pre><code>R = -[1/sqrt(2) 1 1/sqrt(2) 0;0 1/sqrt(2) 1 1/sqrt(2);-1/sqrt(2) 0 1/sqrt(2) 1];
  % R is 3x4 matrix
  
  Y = [0; -1/sqrt(2);-1]; %Y is 3x1 matrix
  
  B1 = pinv(R);
  theta1 = B1*Y;
  result1 = R*theta1 - Y
  
  B2 = R'*inv(R*R');
  theta2 = B2*Y;
  result2 = R*theta2 - Y
  </code></pre>
  
  <p>and this is the result:</p>
  
  <pre><code>   result1 =
     1.0e-15 *
     -0.1110
     -0.2220
     -0.2220
  Warning: Matrix is close to singular or badly scaled.
  Results may be inaccurate. RCOND =  1.904842e-17. 
  &gt; In pseudoinverse at 14 
  result2 =
      0.1036
     -0.1768
     -0.3536
  </code></pre>
  
  <p>Cleary, theta2 is the wrong answer, but i don't know how and why. I read many book and they give me the same formula as wiki.
  Can anybody help me to do pseudo inverse by hand ? thanks !</p>