5.57.8 Singular value decomposition: svd
svd (singular value decomposition) takes as argument a numeric
square matrix of size n.
svd(A) returns an orthogonal matrix U, the diagonal s of a diagonal
matrix S and an orthogonal matrix Q (tQ*Q=I) such that:
Input:
svd([[1,2],[3,4]])
Output:
[[-0.404553584834,-0.914514295677],[-0.914514295677, 0.404553584834]], [5.46498570422,0.365966190626], [[-0.576048436766,0.81741556047],[-0.81741556047, -0.576048436766]]
Input:
(U,s,Q):=svd([[3,5],[4,5]])
Output:
[[-0.672988041811,-0.739653361771],[-0.739653361771, 0.672988041811]],[8.6409011028,0.578643354497], [[-0.576048436766,0.81741556047],[-0.81741556047, -0.576048436766]]
Verification:
Input:
U*diag(s)*tran(Q)
Output:
[[3.0,5.0],[4.0,5.0]]