Condition number for inversion
C = cond(A)
C = cond(A,p)
Calculate the condition number of a matrix and examine the sensitivity to the inverse calculation.
Create a 2-by-2 matrix.
A = [4.1 2.8; 9.7 6.6];
Calculate the 2-norm condition number of
C = cond(A)
C = 1.6230e+03
Since the condition number of
A is much larger than 1, the matrix is sensitive to the inverse calculation. Calculate the inverse of
A, and then make a small change in the second row of
A and calculate the inverse again.
invA = inv(A)
invA = 2×2 -66.0000 28.0000 97.0000 -41.0000
A2 = [4.1 2.8; 9.671 6.608]
A2 = 2×2 4.1000 2.8000 9.6710 6.6080
invA2 = inv(A2)
invA2 = 2×2 472.0000 -200.0000 -690.7857 292.8571
The results indicate that making a small change in
A can completely change the result of the inverse calculation.
Calculate the 1-norm condition number of a matrix.
Create a 3-by-3 matrix.
A = [1 0 -2; 3 4 6; -1 5 7];
Calculate the 1-norm condition number of
A. The value of the 1-norm condition number for an m-by-n matrix is
where the 1-norm is the maximum absolute column sum of the matrix given by
C = cond(A,1)
C = 18.0000
For this matrix the condition number is not too large, so the matrix is not particularly sensitive to the inverse calculation.
A— Input matrix
A can be either square or rectangular in
Complex Number Support: Yes
p— Norm type
Norm type, specified as one of the values shown in this table.
cond computes the condition number using
norm(A,p) * norm(inv(A),p) for values of
p other than 2. See the
norm page for additional
information about these norm types.
Value of p
1-norm condition number
2-norm condition number
Frobenius norm condition number
Infinity norm condition number
cond(A,1) calculates the 1-norm condition
C— Condition number
Condition number, returned as a scalar. Values of
near 1 indicate a well-conditioned matrix, and large values of
C indicate an ill-conditioned matrix. Singular
matrices have a condition number of
A condition number for a matrix and computational task measures how sensitive the answer is to changes in the input data and roundoff errors in the solution process.
The condition number for inversion of a matrix measures the sensitivity of the solution of a system of linear equations to errors in the data. It gives an indication of the accuracy of the results from matrix inversion and the linear equation solution. For example, the 2-norm condition number of a matrix is
In this context, a large condition number indicates that a small change in the
A can lead to larger changes in the output
b in the linear equations Ax =
b and xA =
b. The extreme case is when
A is so poorly
conditioned that it is singular (an infinite condition number), in which case it has
no inverse and the linear equation has no unique solution.
rcond is a more efficient, but less reliable, method of
estimating the condition of a matrix compared to
The algorithm for
cond has three pieces:
p = 2, then
cond uses the
singular value decomposition provided by
svd to find the
ratio of the largest and smallest singular values.
p = 1,
cond calculates the
condition number using the appropriate norm of the input matrix and its
norm(A,p) * norm(inv(A),p).
If the input matrix is sparse, then
cond ignores any
p value and calls