Mathematical Principles for Scientific Computing and Visualization  
http://www.farinhansford.com/books/scv
by Gerald Farin and Dianne Hansford


This notebook looks at the singular value decomposition as described in Section 6.6.


See Chapter 6: Eigen-Problems for details.

Updated July 2008

(* Define the matrix a *)
a = (({{1, 0}, {0, 2}, {0, 1}}));

(* Use Mathematica's SVD function *)
(* It creates three matrices, v, sigma, u^T *)
{v, sigma, ut} = SingularValueDecomposition[a];

Print["SVD: v = ",MatrixForm[v],"  sigma=",MatrixForm[sigma],"  ut=",MatrixForm[ut]]
Print["Check a = v*sigma*ut =? ",MatrixForm[v.sigma.ut]]

(* Form the matrix a^T * a *)
ata = Transpose[a].a;

(* Form the matrix sigma^T * sigma *)
lambda = Transpose[sigma].sigma;

Print["Check a^Ta = u*lambda*u^t "]
Print[MatrixForm[ata]," =? ",MatrixForm[Transpose[ut].lambda.ut]]