cond

cond(M, [p])

Condition number of the matrix M, computed using the operator p-norm. Valid values for p are 1, 2 (default), or Inf.

Examples

julia> A = [1 2 3; 4 5 6; 7 8 9]
3×3 Array{Int64,2}:
 1  2  3
 4  5  6
 7  8  9

julia> cond(A)
16.84810335261421

julia> cond(A, 1)
18.0

julia> cond(A, 2)
16.84810335261421

julia> cond(A, Inf)
26.0

Examples:

  1. Compute the condition number of a matrix using the default 2-norm:

    julia> A = [1 2; 3 4];
    julia> cond(A)
    14.933034373659268

    This example calculates the condition number of matrix A using the default 2-norm.

  2. Compute the condition number of a matrix using the 1-norm:

    julia> B = [1 2 3; 4 5 6; 7 8 9];
    julia> cond(B, 1)
    18.0

    Here, the condition number of matrix B is computed using the 1-norm.

  3. Compute the condition number of a matrix using the Inf-norm:
    julia> C = [1 2 3; 4 5 6; 7 8 9];
    julia> cond(C, Inf)
    26.0

    This example calculates the condition number of matrix C using the Inf-norm.

Common mistake example:

julia> D = [0 0; 0 0];
julia> cond(D)
ERROR: LinearAlgebra.SingularException(0)

In this example, the matrix D is singular, causing a SingularException to be thrown. The cond function expects a non-singular matrix to calculate the condition number.

See Also

Ac_ldiv_B, Ac_ldiv_Bc, Ac_mul_B, Ac_mul_Bc, Ac_rdiv_B, Ac_rdiv_Bc, At_ldiv_B, At_ldiv_Bt, At_mul_B, At_mul_Bt, At_rdiv_B, At_rdiv_Bt, A_ldiv_Bc, A_ldiv_Bt, A_mul_B!, A_mul_Bc, A_mul_Bt, A_rdiv_Bc, A_rdiv_Bt, Bidiagonal, cond, conv2, det, diag, diagind, diagm, diff, eig, eigvals, eigvecs, expm, eye, full, inv, isdiag, ishermitian, isposdef, isposdef!, issym, istril, istriu, logabsdet, logdet, lyap, norm, qrfact, rank, repmat, rot180, rotl90, rotr90, sortrows, sqrtm, SymTridiagonal, trace, Tridiagonal, tril, tril!, triu, triu!, writedlm,

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field
Details

Checking you are not a robot: