Message Boards Message Boards

0
|
521 Views
|
6 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Matrix inverse using singular value decomposition

Posted 1 month ago

How does one compute the inverse of a square matrix using SingularValueDecomposition?

A = {{1, 1, 1}, {0, 2, 3}, {5, 5, 1}};

Inverse[A] = {{13/8, -(1/2), -(1/8)}, {-(15/8), 1/2, 3/8}, {5/4, 0, -(1/4)}}

svdInverse[a_?MatrixQ] := Module[{u, s, v},
   {u, s, v} = SingularValueDecomposition[a];
   Return[v . Inverse[s] . ConjugateTranspose[u]]];

svdInverse[A] = Over 100 lines of indecipherable garbage.

svdInverse[a_?MatrixQ] := Module[{u, s, v},
   {u, s, v} = SingularValueDecomposition[a];
   Return[v . Inverse[s] .Transpose[u]]];
svdInverse[A] = Over 100 lines of indecipherable garbage.

 svdInverse[a_?MatrixQ] := Module[{u, s, v},
   {u, s, v} = SingularValueDecomposition[a];
   Return[v . Inverse[s] .u]];
svdInverse[A] = Over 100 lines of indecipherable garbage.
POSTED BY: Charles Elliott
6 Replies
POSTED BY: Daniel Lichtblau

How about

svdInverse[a_?MatrixQ] :=
  Module[{u, s, v},
   {u, s, v} = SingularValueDecomposition[a]; 
   v . Inverse[s] . ConjugateTranspose[u]];
svdInverse[{{1, 1, 1}, {0, 2, 3}, {5, 5, 1}}] // FullSimplify

By the way, your use of Return is redundant.

POSTED BY: Gianluca Gorni

Thanks for your reply. Your solution works for 3x3 matrices, but hangs on 4x4 matrices. It aborts on TimeConstrained[ svdInverse[m] ], 180]; in any case it is slower than Inverse and qrInverse.

POSTED BY: Charles Elliott

For exact matrices, singular value decomposition is awfully more complicated than inversion, as it involves solving nonlinear algebraic equations.

POSTED BY: Gianluca Gorni
POSTED BY: Charles Elliott

The singular value decomposition is useful and effective for floating-point matrices. It is hardly surprising that it bogs down already for 4x4 matrices in the exact case. Try this with a 20x20 matrix:

svdInverse[a_?MatrixQ] :=
 Module[{u, s, v},
  {u, s, v} = SingularValueDecomposition[N[a]]; 
  v . Inverse[s] . ConjugateTranspose[u]]
MatrixForm[mat = RandomInteger[10, {20, 20}]]
svdInverse[mat] // MatrixForm
svdInverse[mat] - Inverse[mat] // Chop // MatrixForm
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract