# 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.