Skip to main content
15 votes

Practical example of why it is not good to invert a matrix

Here is a quick example which is very practical related to memory usage in PDEs. When one discretizes the Laplace operator, $\Delta u$, for example, in the Heat Equation $$ u_t = \Delta u + f(t,u) .$$...
Chris Rackauckas's user avatar
13 votes
Accepted

Practical example of why it is not good to invert a matrix

Normally there are some principal reasons to prefer solve a linear system respect to use the inverse. Briefly: problem with the conditional number (@GoHokies comment) problem in the sparse case (@...
Mauro Vanzetto's user avatar
13 votes
Accepted

How to directly compute the inverse of an ill-conditioned dense matrix

Though it is a relatively rare situation when you actually have to calculate an inverse of the matrix, not all techniques were created equally. I would use the term badly-conditioned instead of ill-...
Anton Menshov's user avatar
  • 8,742
11 votes
Accepted

Why is matrix inversion unstable when svd is stable?

The big issue is the condition number, which is defined as the ratio of the largest and smallest singular values. Suppose we expect: $$ S = \begin{bmatrix} 10^{-15}\\ &1 \end{bmatrix} $$ If we ...
helloworld922's user avatar
11 votes

What algorithm(s) do numpy and scipy use to calculate matrix inverses?

Documentation to numpy.linalg.inv and scipy.linalg.inv does not mention the algorithm used. Judging from the source, ...
Vladimir Lysikov's user avatar
11 votes
Accepted

Do I really need to invert this matrix

Since $$ A = B(I-B)^{-1} = (I-B)^{-1}(I-B)B(I-B)^{-1} = (I-B)^{-1}B(I-B)(I-B)^{-1} =(I-B)^{-1}B $$ So you want to solve $$ (I-B)A=B $$ You seem to need only the first three columns of $A$. Solve the ...
cfdlab's user avatar
  • 3,078
7 votes
Accepted

Fast algorithm for computing cofactor matrix

So, a cofactor matrix is a transpose of an adjugate matrix. I know of the following paper: G. W. Stewart, "On the adjugate matrix," Lin. Alg. Appl., vol. 283, no. 1–3, pp. 151–164, Nov. ...
Anton Menshov's user avatar
  • 8,742
6 votes

Approximately, at any given time, what proportion of the world's total HPC resources are dedicated towards inverting matrices?

The number is almost certainly unverifiable because every HPC system's overall user community is different and because there are so many systems around. I think that the number is vastly smaller than ...
Wolfgang Bangerth's user avatar
6 votes

Inverting big symmetric and singular matrices

Think of your matrix as block-diagonal with blocks $$ C_\ell = \begin{pmatrix} 0 & & \\ & D_\ell & \\ & & 0\end{pmatrix}. $$ Then it is clear that $$ C_\ell^{-1} = \begin{...
Wolfgang Bangerth's user avatar
6 votes

Accurate way of getting the square root inverse of a positive definite symmetric matrix

As suggested in the comments, the eigendecomposition $\mathbf J = \mathbf Q \mathbf D \mathbf Q^{T}$ can be used to generate the matrix $\mathbf J^{-1/2}$, just take the eigenvectors from $\mathbf J$ (...
rchilton1980's user avatar
  • 5,076
6 votes
Accepted

Which pseudo-inverse to compute when Inverse is not possible? (No linear solve)

Pseudoinverses typically will be computed via some truncation procedure to determine the rank, so they are not close to the original inverse. Example: $$A = Q \begin{bmatrix} 1\\ & 10^{-12} \\ &...
Federico Poloni's user avatar
6 votes
Accepted

Computing the Inverse of a matrix, using the Cholesky decomposition

The Cholesky decomposition [the function dpotrf() in LAPACK] factors $\mathbf A = \mathbf L \mathbf L^{\mathrm T}$, or alternatively $\mathbf A^{-1} = \left(\mathbf L \mathbf L^\mathrm T \right)^{-1} =...
rchilton1980's user avatar
  • 5,076
5 votes

approximate function such that the inverse of the approximation is "simple"

I think this is a really cool question, which might have a really cool answer, if someone was willing to think about it hard enough to publish on. But when we're talking smooth functions which need ...
user14717's user avatar
  • 2,165
5 votes

How to Invert a Poorly Conditioned Matrix

There is no simple fix. For an ill-conditioned matrix $A$, the harm (loss of precision) is already done the moment you wrote those numbers in a numpy array, because that tiny $10^{-16}$ perturbation ...
Federico Poloni's user avatar
5 votes

The fast, and The Backward-Stable (left) $3\times 3$ matrix inverse

I will try to give my thought on the first question regarding fast $3\times 3$ inverse. Consider $$ A=\left[ \begin{array}{ccc} a & d & g\\ b & e & h\\ c & f & i \end{array}\...
Anton Menshov's user avatar
  • 8,742
5 votes
Accepted

The error propagation in calculating the inverse using a matrix decomposition

Irrespective of how you compute an approximate inverse $K\approx M^{-1}$, there is a limit to the (normwise) accuracy up to which $KM \approx I$ can hold: just because of the fact that $K$ and $M$ are ...
Federico Poloni's user avatar
4 votes
Accepted

Is there an efficient way to compute the inverse of several symmetric matrices that share the same structure?

You don't need to compute the inverse, you just need to compute a factorization of the matrices, Cholesky factorization in this case since they are positive (semi-)definite. You can then reuse the ...
filikat's user avatar
  • 86
3 votes
Accepted

Inverse of ill-conditioned symmetric matrix

You don't need the inverse even with the goal of finding $K^{-1} h h^{T} K^{-1} - K^{-1}$. If you are interested to have this expression, I would explain how you can convert it to a matrix equation ...
Mithridates the Great's user avatar
3 votes

Inverting big symmetric and singular matrices

You might be better served by either the LDL' decomposition or the Cholesky decomposition (in the event that C's are positive definite in addition to symmetric, they probably are). Though all of the ...
rchilton1980's user avatar
  • 5,076
2 votes

closed form approximation of matrix inverse with special properties

Unfortunately, the listed set of matrix properties does not give any hope on a closed-form of the matrix inverse or its reasonable approximation (for this specific case). It is too general, and ...
Anton Menshov's user avatar
  • 8,742
2 votes

Inverting small matrices: canned factorization versus explicit formula

Cramer's rule using a more stable determinant: https://hal.archives-ouvertes.fr/hal-01500199/document Implementation of the algorithm is consistently 2.5 times slower than LU factorization of matlab ...
R zu's user avatar
  • 163
2 votes
Accepted

optimize this python code that involves matrix inversion

Since S is SPD, you can (and should) use np.linalg.cholesky to get a cholesky factorization which will be ~2x faster than the LU ...
Oscar Smith's user avatar
2 votes

What algorithm(s) do numpy and scipy use to calculate matrix inverses?

First of all, they don't take matrix inverses. They perform linear solves. Typically this is done via LU factorization.
Oscar Smith's user avatar
1 vote
Accepted

MATLAB : find an algorithm to inverse quickly a large matrix of symbolic variables

The inverse of the (1,1) block of $$ \begin{bmatrix} A & B\\ C & D \end{bmatrix}^{-1} $$ is $A-BD^{-1}C$ (Schur complement). This is what you are trying to compute, if I understand correctly ...
Federico Poloni's user avatar
1 vote

Inverse of ill-conditioned symmetric matrix

Based on Federico's suggestions and ideas, more straight forward formulation of extracting $K^{-1}hh^{T}K^{-1}-K^{-1}$ would be: $$X = K^{-1}hh^{T}K^{-1}-K^{-1}$$ $$KXK = hh^{T}-K$$ $$Z = XK$$ ...
Mithridates the Great's user avatar
1 vote
Accepted

What is the fastest method to invert millions of matrices?

I known that this is not a definitive answer, but it can give an idea how to move with CUDA. At this stage is difficult to give advice because for this is necessary a detailed know about the actually ...
Mauro Vanzetto's user avatar
1 vote

Sparse matrix inverse with reduced bandwidth

Three things immediately come to mind: R might not take advantage of sparsity when using the solve command to compute the inverse of a matrix. Usually, the inverse ...
Daniel Shapero's user avatar
1 vote

closed form approximation of matrix inverse with special properties

Truncated Neumann series: let $D$ be the diagonal of your matrix, and $-N$ be the non-diagonal part. Then, $M=D-N=D(I-D^{-1}N)$, and $$M^{-1}=(I-D^{-1}N)D^{-1}=(I+D^{-1}N + D^{-1}ND^{-1}N + D^{-1}ND^{-...
Federico Poloni's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible