ShanZhengYang - 11 months ago 112

Python Question

(Before you tell me, yes, I know you should *never* invert the matrix. Unfortunately for my calculations, I have a matrix which I have constructed, and it must be inverted somehow.)

I have a large matrix

`M`

`numpy.linalg.cond(M)`

`e+22`

`M`

`(1000,1000)`

Naturally,

`numpy.linalg.inv()`

`numpy.linalg.solve()`

Consider that the matrix inverse

`A^{-1}`

`A * A^{-1} = Identity`

`numpy.linalg.solve()`

So, I define the identity matrix:

`import numpy as np`

iddmatrix = np.identity(100)

and solve:

`inverse = np.linalg.solve(M, iddmatrix)`

However, because my matrix is

`np.linalg.solve()`

- What is the standard way to implement such an inverse with SVD?
- How could I make this ill-conditioned matrix....well-defined?

Any recommendations are appreciated. Thanks!

Answer Source

Consider what taking the SVD of a matrix actually means. It means that for some matrix `M`

, then we can express it as `M=UDV*`

(here let's let * represent transpose, because I don't see a good way to do that in stack overflow).

```
if M=UDV*:
then: M^-1 = (UDV*)^-1 = (V*^-1)(D^-1)(U^-1)
```

But thanks to the fact that `U`

's columns are the eigenvalues of `MM*`

and `V`

's columns are the eigenvalues of `M\*M`

, the inverses of these matrices are their own transposes (since eigenvectors are orthogonal). So we get: `M^-1 = V(D^-1)U*`

. Taking the inverse of a diagonal matrix is as easy as taking the multiplicative inverse of each of these elements.

Better typesetting (kind of) here: http://adrianboeing.blogspot.com/2010/05/inverting-matrix-svd-singular-value.html