TITLE: Calculate the pseudo inverse of the matrix
QUESTION [6 upvotes]: The subject is to calculate the pseudo inverse if matrix $\begin{equation*}
  \mathbf{A} = \left(
    \begin{array}{ccc}
      1 & 0  \\
      2 & 1  \\
      0 & 1  \\
    \end{array}
  \right)
\end{equation*}$
My answer is as follows: (SVD decomposition)
First, $\begin{equation*}
  \mathbf{A^TA} = \left(
    \begin{array}{ccc}
      5 & 2  \\
      2 & 2  \\
    \end{array}
  \right)
\end{equation*}$, with eigenvalues $\lambda_1 = 6, \lambda_2 = 1$, and eigenvectors $\begin{equation*}
  \mathbf{x_1} = \frac{1}{\sqrt{5}}\left( 
    \begin{array}{ccc}
      2   \\
      1   \\
    \end{array}
  \right)
\end{equation*}$,
$\begin{equation*}
  \mathbf{x_2} = \frac{1}{\sqrt{5}}\left( 
    \begin{array}{ccc}
      -1   \\
      2   \\
    \end{array}
  \right)
\end{equation*}$, so the matrix $\begin{equation*}
  \mathbf{V} = \frac{1}{\sqrt{5}}\left( 
    \begin{array}{ccc}
      2 & -1  \\
      1 & 2  \\
    \end{array}
  \right)
\end{equation*}$.
Second, $\begin{equation*}
  \mathbf{AA^T} = \left(
    \begin{array}{ccc}
      1 & 2 & 0 \\
      2 & 5 & 1 \\
      0 & 1 & 1 \\
    \end{array}
  \right)
\end{equation*}$, with eigenvalues $\lambda_1 = 6, \lambda_2 = 1,\lambda_3 = 0$, and eigenvectors $\begin{equation*}
  \mathbf{x_1} = \frac{1}{\sqrt{30}}\left( 
    \begin{array}{ccc}
      2   \\
      5   \\
      1   \\
    \end{array}
  \right)
\end{equation*}$,
$\begin{equation*}
  \mathbf{x_2} = \frac{1}{\sqrt{5}}\left( 
    \begin{array}{ccc}
      -1   \\
      0    \\
      2   \\
    \end{array}
  \right)
\end{equation*}$,
$\begin{equation*}
  \mathbf{x_3} = \frac{1}{\sqrt{6}}\left( 
    \begin{array}{ccc}
      2   \\
      -1    \\
      1  \\
    \end{array}
  \right)
\end{equation*}$
, so the matrix $\begin{equation*}
  \mathbf{U} = \left( 
    \begin{array}{ccc}
      \frac{2}{\sqrt{30}} & - \frac{1}{\sqrt{5}} & \frac{2}{\sqrt{6}} \\
      \frac{5}{\sqrt{30}} & 0 & - \frac{1}{\sqrt{6}} \\
      \frac{1}{\sqrt{30}} &  \frac{2}{\sqrt{5}} & \frac{1}{\sqrt{6}} \\
    \end{array}
  \right)
\end{equation*}$, and 
$\begin{equation*}
  \mathbf{\Sigma} = \left( 
    \begin{array}{ccc}
      6 & 0  \\
      0 & 1  \\
      0 & 0  \\
    \end{array}
  \right)
\end{equation*}$.
Then, the pseudo inverse becomes: $A^+ = V \Sigma^+U^T$.
The problem comes to: when I was checking the SVD decomposition, I found $A\ne U\Sigma V^T$. However, I find nothing odds in the calculation. Please help me to point out the error.

REPLY [4 votes]: Recall, for $\mathbf{\Sigma}$ we take the square roots of the non-zero eigenvalues and populate the diagonal with them, putting the largest in $\mathbf{\Sigma}_{11}$, the next largest in $\mathbf{\Sigma}_{22}$ and so on until the smallest value
ends up in $\mathbf{\Sigma}_{mm}$. 
$$\begin{equation*}
  \mathbf{\Sigma} = \left( 
    \begin{array}{ccc}
      \sqrt{6} & 0  \\
      0 & 1  \\
      0 & 0  \\
    \end{array}
  \right)
\end{equation*}$$
Everything else is correct (great job), although you can simplify some of the items in $\mathbf{U}$. For example, $\dfrac{2}{\sqrt{6}} = \sqrt{\dfrac{2}{3}}$.