Message Boards Message Boards

0
|
508 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

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

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

POSTED BY: Gianluca Gorni

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

I’d not use SVD for that task unless working with approximate numbers.

POSTED BY: Daniel Lichtblau

Why not?

However, the point is moot, since on my computer with version 14, it has stopped working for 4x4 (and presumably larger) matrices.
I tried SingularValueDecomposition because Weisberg seems to mention it here (Weisberg, Sanford. Applied Linear Regression (Wiley Series in Probability and Statistics) (p. 309). Wiley. Kindle Edition), although I cannot immediately find where he actually recommends its use.

POSTED BY: Charles Elliott
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