# Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English verison of the page.

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

# cond

Condition number of matrix

## Syntax

```cond(A) cond(A,P) ```

## Description

`cond(A)` returns the `2`-norm condition number of matrix `A`.

`cond(A,P)` returns the `P`-norm condition number of matrix `A`.

## Input Arguments

 `A` Symbolic matrix. `P` One of these values `1`, `2`, `inf`, or `'fro'`. `cond(A,1)` returns the `1`-norm condition number.`cond(A,2)` or `cond(A)` returns the `2`-norm condition number.`cond(A,inf)` returns the infinity norm condition number.`cond(A,'fro')` returns the Frobenius norm condition number.Default: `2`

## Examples

Compute the `2`-norm condition number of the inverse of the 3-by-3 magic square `A`:

```A = inv(sym(magic(3))); condN2 = cond(A)```
```condN2 = (5*3^(1/2))/2```

Use `vpa` to approximate the result with 20-digit accuracy:

`vpa(condN2, 20)`
```ans = 4.3301270189221932338```

Compute the 1-norm condition number, the Frobenius condition number, and the infinity condition number of the inverse of the 3-by-3 magic square `A`:

```A = inv(sym(magic(3))); condN1 = cond(A, 1) condNf = cond(A, 'fro') condNi = cond(A, inf)```
```condN1 = 16/3 condNf = (285^(1/2)*391^(1/2))/60 condNi = 16/3```

Use `vpa` to approximate these condition numbers with 20-digit accuracy:

```vpa(condN1, 20) vpa(condNf, 20) vpa(condNi, 20)```
```ans = 5.3333333333333333333 ans = 5.5636468855119361059 ans = 5.3333333333333333333```

Compute the condition numbers of the 3-by-3 Hilbert matrix `H` approximating the results with 30-digit accuracy:

```H = sym(hilb(3)); condN2 = vpa(cond(H), 30) condN1 = vpa(cond(H, 1), 30) condNf = vpa(cond(H, 'fro'), 30) condNi = vpa(cond(H, inf), 30)```
```condN2 = 524.056777586060817870782845928 +... 1.42681147881398269481283800423e-38i condN1 = 748.0 condNf = 526.158821079719236517033364845 condNi = 748.0```

Hilbert matrices are classic examples of ill-conditioned matrices.

collapse all

### Condition Number of a Matrix

Condition number of a matrix is the ratio of the largest singular value of that matrix to the smallest singular value. The `P`-norm condition number of the matrix `A` is defined as `norm(A,P)*norm(inv(A),P)`, where `norm` is the norm of the matrix `A`.

## Tips

• Calling `cond` for a numeric matrix that is not a symbolic object invokes the MATLAB® `cond` function.