Learning Scientific Programming with Python (2nd edition)
P6.5.3: Singular value decomposition
Question P6.5.3
The NumPy method numpy.linalg.svd
returns the singular value decomposition (SVD) of a matrix, $\mathbf{M}$, as the arrays $\mathbf{U}$, $\mathbf{\Sigma}$ and $\mathbf{V}$ satisfying the factorization: $\mathbf{M} = \mathbf{U}\mathbf{\Sigma}\mathbf{V}^\dagger$ where $\dagger$ denotes the Hermitian conjugate (the conjugate transpose).
The SVD and the eigendecomposition are related in that the left-singular row vectors, $\mathbf{U}$ are the eigenvectors of $\mathbf{MM^*}$ and the right-singular column vectors, $\mathbf{V}$, are the eigenvectors of $\mathbf{M^*M}$. Furthermore, the diagonal entries of $\mathbf{\Sigma}$ are the square roots of the non-zero eigenvalues of both $\mathbf{MM^*}$ and $\mathbf{M^*M}$.
Show that this is the case for the special case of $\mathbf{M}$ a $3 \times 3$ matrix with random real entries by comparing the output of numpy.linalg.svd
with that of numpy.linalg.eig
.
Hints: The singular values of $\mathbf{M}$ are sorted in descending order but the eigenvalues returned by numpy.linalg.eig
are in no particular order. Both methods produce normalized eigenvectors, but may differ by sign (ignore the possibility that any of the eigenvalues could have an eigenspace with dimension greater than 1).