Why does inv() work on a rank deficient matrix?

조회 수: 6 (최근 30일)
Jacob Schaperow
Jacob Schaperow 2022년 1월 6일
댓글: Walter Roberson 2022년 1월 6일
I have an nxn square matrix A with rank n-1. When I call inv(A), MATLAB computes the inverse without complaining. How is this possible? Shouldn't a matrix that is rank deficient be impossible to invert?

채택된 답변

Walter Roberson
Walter Roberson 2022년 1월 6일
If I recall correctly, inv() does not use rank() to detect rank deficiency.
"inv performs an LU decomposition of the input matrix (or an LDL decomposition if the input matrix is Hermitian). It then uses the results to form a linear system whose solution is the matrix inverse inv(X). For sparse inputs, inv(X) creates a sparse identity matrix and uses backslash, X\speye(size(X))."
These algorithms have their own internal settings as to whether they complain about a marginal matrix or not. Depending on the numeric noise in the calculations, sometimes they do not detect a matrix as singular when it is singular.
... You probably should not be using inv() anyhow.
  댓글 수: 2
Jacob Schaperow
Jacob Schaperow 2022년 1월 6일
Thanks, yeah, this answers my question. I switched to using the backslash operator. Of course, now I am wondering if there are cases where the backslash operator will fail and whether I can prevent this somehow by ensuring the matrix is well-conditioned.
Walter Roberson
Walter Roberson 2022년 1월 6일
Yes, and the tolerance of the backslash operator has changed in the not-so-distant past. Changed both ways: mostly to reject more problematic matrices, but it also started accepting some matrices it should probably have rejected.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear Algebra에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by