2018-06-16 15:39:07 +02:00

58 lines
1.7 KiB
Markdown

---
layout: default
---
<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
<h1 id="function-norm">Function norm <a href="#function-norm" title="Permalink">#</a></h1>
Calculate the norm of a number, vector or matrix.
The second parameter p is optional. If not provided, it defaults to 2.
<h2 id="syntax">Syntax <a href="#syntax" title="Permalink">#</a></h2>
```js
math.norm(x)
math.norm(x, p)
```
<h3 id="parameters">Parameters <a href="#parameters" title="Permalink">#</a></h3>
Parameter | Type | Description
--------- | ---- | -----------
`x` | number &#124; BigNumber &#124; Complex &#124; Array &#124; Matrix | Value for which to calculate the norm
`p` | number &#124; BigNumber &#124; string | Vector space. Supported numbers include Infinity and -Infinity. Supported strings are: 'inf', '-inf', and 'fro' (The Frobenius norm) Default value: 2.
<h3 id="returns">Returns <a href="#returns" title="Permalink">#</a></h3>
Type | Description
---- | -----------
number &#124; BigNumber | the p-norm
<h2 id="examples">Examples <a href="#examples" title="Permalink">#</a></h2>
```js
math.abs(-3.5) // returns 3.5
math.norm(-3.5) // returns 3.5
math.norm(math.complex(3, -4)) // returns 5
math.norm([1, 2, -3], Infinity) // returns 3
math.norm([1, 2, -3], -Infinity) // returns 1
math.norm([3, 4], 2) // returns 5
math.norm([[1, 2], [3, 4]], 1) // returns 6
math.norm([[1, 2], [3, 4]], 'inf') // returns 7
math.norm([[1, 2], [3, 4]], 'fro') // returns 5.477225575051661
```
<h2 id="see-also">See also <a href="#see-also" title="Permalink">#</a></h2>
[abs](abs.html),
[hypot](hypot.html)