[Math] Singular Value Decomposition of this matrix with a zero singular value

linear algebramatrix decomposition

What is the singular value decomposition of $$
\left[ \begin{matrix}
2 & -6\\
1 & -3 \\
0 & 0 \\
\end{matrix}\right]
$$

Singular value decomposition calculators online give the following answer:
$$
\left[\begin{matrix}
2 & -6\\
1 & -3 \\
0 & 0 \\
\end{matrix}\right]
=
\left[\begin{matrix}
-2/\sqrt{5} & -1/\sqrt{5} & 0 \\
-1/\sqrt{5} & 2/\sqrt{5} & 0\\
0 & 0 & 1\\
\end{matrix}\right]
\left[ \begin{matrix}
\sqrt{50} & 0\\
0& 0 \\
0 & 0 \\
\end{matrix}\right]
\left[ \begin{matrix}
-.3162 & .9487\\
.9487 & -.3162 \\
\end{matrix}\right]
$$

I get the same singular values: $\sqrt{50}$ and $0$. However, this is as far as I get. I get the normalized eigenvalues as $\left[\begin{matrix} 2/\sqrt{5}\\1/\sqrt{5} \end{matrix}\right]$ and $\left[\begin{matrix} 1/\sqrt{5}\\-1/\sqrt{5} \end{matrix}\right]$, instead of $\left[\begin{matrix} -.3162\\ .9487 \end{matrix}\right]$ and $\left[\begin{matrix} .9487\\-.3162 \end{matrix}\right]$. What am I doing wrong? I have checked my work multiple times.

Best Answer

In order to get the SVD of the matrix you need to get the eigenvalues of the covariance matrix

$$ A =\begin{bmatrix} 2& -6\\ 1 & -3 \\ 0 & 0 \end{bmatrix} \tag{1}$$

$$ A^{T}A = \begin{bmatrix} 5& -15\\ -15& 45 \end{bmatrix}\tag{2}$$

$$ \det(A^{T}A - \lambda I) = \begin{vmatrix} 5- \lambda& -15\\ -15& 45-\lambda \end{vmatrix} = (5-\lambda)(45-\lambda) -225 \tag{3}$$ $$ \det(A^{T}A - \lambda I) = \lambda(\lambda-50) \implies \lambda_{1} = 50 \lambda_{2} = 0 \tag{4}$$

now $A^{T}A = V \Lambda V^{T} $

we find the right singular vectors

$$ A^{T}A -50I = \begin{bmatrix} 5-50& -15\\ -15& 45 -50 \end{bmatrix} \begin{bmatrix}x_{1} \\ x_{2} \end{bmatrix} \begin{bmatrix} 0 \\ 0 \end{bmatrix} \tag{5}$$

$$ A^{T}A-50I = \begin{bmatrix} -45 &-15\\ -15& -5 \end{bmatrix} \begin{bmatrix}x_{1} \\ x_{2} \end{bmatrix} \begin{bmatrix} 0 \\ 0 \end{bmatrix} \tag{6}$$

$$ -45x_{1} -15x_{2} = 0 \\ -15x_{1} - 5x_{2} = 0 $$ then $x_{2} = \frac{x_{1}}{3}$

$$ x = \begin{bmatrix} 1 \\ 3\end{bmatrix} \tag{7} $$

now normalize

$$ v_{1} = \begin{bmatrix} \frac{1}{\sqrt{3^{2}+1}}\\ \frac{3}{\sqrt{3^{2}+1}} \end{bmatrix} \tag{8} $$ $$ v_{1} = \begin{bmatrix} \frac{1}{\sqrt{10}}\\ \frac{3}{\sqrt{10}} \end{bmatrix} \tag{9} $$

for the next

$$ A^{T}A = \begin{bmatrix} 5& -15\\ -15& 45 \end{bmatrix} \begin{bmatrix}x_{1} \\ x_{2} \end{bmatrix} \begin{bmatrix} 0 \\ 0 \end{bmatrix} \tag{10}$$

you get the opposite

$$ v_{2} = \begin{bmatrix} \frac{-3}{\sqrt{10}}\\ \frac{1}{\sqrt{10}} \end{bmatrix} \tag{11} $$

the singular values are the square roots of the eigenvalues so..you have $\sigma_{1} = \sqrt{50} , \sigma_{2} =0$

if you do it by python ..

import numpy as np

A = np.matrix([[2,-6],[1,-3],[0,0]])
u,s,vt = np.linalg.svd(A)

these aren't unique.. you should note..

matrix([[-0.31622777,  0.9486833 ],
        [ 0.9486833 ,  0.31622777]])

if you do the $AA^{T}$

$$AA^{T} = \begin{bmatrix} 40& 20 & 0 \\ 20 & 10 & 0 \\ 0 & 0 & 0 \end{bmatrix} \tag{12}$$

then take

$$ \det(AA^{T} - \lambda I) = \begin{vmatrix} 40-\lambda& 20 & 0 \\ 20 & 10-\lambda & 0 \\ 0 & 0 & 0 \end{vmatrix} \tag{13}$$

in the end if $U \Sigma V^{T} = A $ you'll be fine..