2.35 Find the singular value decomposition (SVD) of a matrix

Problem: Find the SVD for the matrix $$\begin {bmatrix} 1 & 2 & 3\\ 4 & 5 & 6 \end {bmatrix}$$ Notice that in Maple, the singular values matrix, normally called S, is returned as a column vector. So need to call DiagonalMatrix() to format it as expected.

 Mathematica mat = {{1,2,3}, {4,5,6}} {u,s,v}=N[SingularValueDecomposition[mat]]  {{0.386318,-0.922366}, {0.922366,0.386318}} {{9.50803,0.,0.}, {0.,0.77287,0.}} {{0.428667,0.805964,0.408248}, {0.566307,0.112382,-0.816497}, {0.703947,-0.581199,0.408248}}  (*Reconstruct A from its components *) u.s.Transpose[v]  {{1.,2.,3.}, {4.,5.,6.}} 

 Matlab A=[1 2 3; 4 5 6]; [u,s,v]=svd(A); u s v  u = -0.3863 -0.9224 -0.9224 0.3863 s = 9.5080 0 0 0 0.7729 0 v = -0.4287 0.8060 0.4082 -0.5663 0.1124 -0.8165 -0.7039 -0.5812 0.4082  u*s*v'  ans = 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 

 Maple restart; with(LinearAlgebra): A:=Matrix([[1,2,3],[4,5,6.]]);   [1 2 3 ] A := [ ] [4 5 6.]  m,n:=Dimensions(A): u,s,v:=SingularValues(A, output=['U', 'S', 'Vt']): u;   [0.386317703118612 -0.922365780077058] [ ] [0.922365780077058 0.386317703118612 ]  s:=DiagonalMatrix(s,m,n); v;   [9.50803200069572 0 0] s := [ ] [ 0 0.772869635673485 0] [0.428667133548626 0.566306918848035 0.703946704147444 ] v:= [0.805963908589298 0.112382414096594 -0.581199080396110] [0.408248290463863 -0.816496580927726 0.408248290463863 ]  > s2:=DiagonalMatrix(SingularValues(A, output=['S']),m,n);   [9.50803200069572 0 0] s2 := [ ] [ 0 0.772869635673485 0]  > evalf(u.s.v);  [1. 2. 3.] [ ] [4. 5. 6.]