When computing the inverse for some square matrix A in MATLAB, using
Ai = inv(A)
% should be the same as:
Ai = A^-1
MATLAB usually notifies me that this is not the most efficient way of inverting. So what's more efficient? If I have an equation system, using the /,\ operators probably is. But sometimes I need the inverse for other computations.
What's the most efficient way to invert?
I would recommend to use
svd(unless you are really absolute sure that your matrix is not ill-conditioned). Then, based on singular values you make your decisions on further actions to take. This may sound like a 'overkill' approach, but in long run it will pay back.Now if your matrix
Ais actually invertible, then thepseudo inverseofAcoincidence withinv(A), however if you are close to 'singularity' you'll easily make appropriate decision how to proceed to actually make thepseudo inverse. Naturally these decisions will depend on your application.Added a straightforward example: