Documentation

# cond

Condition number of matrix

## Syntax

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

## Description

example

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

example

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

## Examples

collapse all

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.

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

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```

Approximate these results by using `vpa`.

```vpa(condN1) vpa(condNf) vpa(condNi)```
```ans = 5.3333333333333333333333333333333 ans = 5.5636468855119361058627454652148 ans = 5.3333333333333333333333333333333```

Hilbert matrices are examples of ill-conditioned matrices. Numerically compute the condition numbers of the 3-by-3 Hilbert matrix by using `cond` and `vpa`.

```H = hilb(sym(3)); condN2 = vpa(cond(H)) condN1 = vpa(cond(H,1)) condNf = vpa(cond(H,'fro')) condNi = vpa(cond(H,inf))```
```condN2 = 524.05677758606270799646154046059 condN1 = 748.0 condNf = 526.15882107972220183000899851322 condNi = 748.0```

## Input Arguments

collapse all

Input, specified as a number, vector, matrix, or array, or a symbolic number, variable, array, function, or expression.

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.

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)`.

## Tips

• Calling `cond` for a numeric matrix that is not a symbolic object invokes the MATLAB® `cond` function.
{"ft_lang_label":"__label__en","ft_lang_prob":0.75881046,"math_prob":0.9993841,"size":305,"snap":"2019-43-2019-47","text_gpt3_token_len":71,"char_repetition_ratio":0.13953489,"word_repetition_ratio":0.0,"special_character_ratio":0.20655738,"punctuation_ratio":0.07936508,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99978274,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-11-15T14:57:42Z\",\"WARC-Record-ID\":\"<urn:uuid:17cdbe08-9747-4368-8d2e-a08cfaff9249>\",\"Content-Length\":\"73891\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:25ccf70b-4d1f-4eeb-b2e8-2c7b395cf5eb>\",\"WARC-Concurrent-To\":\"<urn:uuid:4f613dc5-2e01-43af-b72a-20f7d8f53952>\",\"WARC-IP-Address\":\"104.110.193.39\",\"WARC-Target-URI\":\"https://la.mathworks.com/help/symbolic/cond.html\",\"WARC-Payload-Digest\":\"sha1:CCWLIUGWOXZTHFQA2FTQHLYQT7RDJJSF\",\"WARC-Block-Digest\":\"sha1:3RC35NY2TJUUZQGEHJ6RJ5IOMZJYB677\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-47/CC-MAIN-2019-47_segments_1573496668682.16_warc_CC-MAIN-20191115144109-20191115172109-00429.warc.gz\"}"}