cond

Condition number of a matrix with respect to inversion.

Category: Mathematics > Linear Algebra

Syntax

c = cond(A)

Returns the 2-norm condition number, the ratio of the largest to the smallest singular value.

c = cond(A, p)

Uses the norm p: 1, 2, Inf or 'fro'.

Description

The condition number measures how much a relative error in the data of a linear system A*x = b can be amplified in the solution. As a rule of thumb, you lose about log10(cond(A)) decimal digits of accuracy. Orthogonal matrices have condition 1; a singular matrix has an infinite one.

The condition number is a property of the matrix, not of the algorithm, and it is not the same as the size of the determinant. For large sparse matrices use condest, which estimates it cheaply.

Input arguments

A
Matrix. For p other than 2 it must be square.
p
Norm type, default 2.

Output arguments

c
The condition number, at least 1. It is Inf for a singular matrix.

Example

Different norms

A = [1 2; 3 4];
cond(A)
cond(A, 1)
cond(A, 'fro')
cond([1 2; 2 4])
Output
ans = 14.9330
ans = 21.0000
ans = 15.0000
ans = Inf

See also

condest rcond norm svd inv