# norm

norms of a vector or a matrix

### Syntax

```y = norm(x)
y = norm(x, normType)```

### Arguments

x

vector or matrix of real or complex numbers (full or sparse storage)

normType

• For a matrix `x`: a number among `1, 2, %inf, -%inf`, or a word among `"inf"` (or `"i"`) or `"fro"` (or `"f"`).
• For a vector `x`: any number or `%inf`, `-%inf`; or a word `"inf"` (`"i"`), `"fro"` (`"f"`).

Default value = 2.
y

norm: single positive real number.

### Description

For matrices

norm(x)

or `norm(x,2)` is the largest singular value of `x` (`max(svd(x))`).

norm(x,1)

The l_1 norm `x` (the largest column sum : `max(sum(abs(x),'r'))` ).

norm(x,'inf'),norm(x,%inf)

The infinity norm of `x` (the largest row sum : `max(sum(abs(x),'c'))` ).

norm(x,'fro')

Frobenius norm i.e. `sqrt(sum(diag(x'*x)))`.

For vectors

norm(v,p)

The l_p norm `sum(abs(v(i))^p)^(1/p)` .

norm(v), norm(v,2)

The l_2 norm

norm(v,'inf')

`max(abs(v(i)))`.

### Remark

`norm([])` and `norm([],p)` return 0.

`norm(x)` and `norm(x,p)` return NaN if x contains NaNs.

### Examples

```A = [1,2,3];
norm(A,1)
norm(A,'inf')
A = [1,2;3,4]
max(svd(A)) - norm(A)

A = sparse([1 0 0 33 -1])
norm(A)```

### See also

• h_norm — H-infinity norm
• dhnorm — discrete H-infinity norm
• h2norm — H2 norm of a continuous time proper dynamical system
• abs — absolute value, magnitude
• svd — singular value decomposition
 Report an issue << min Matrix operations or >>

 Copyright (c) 2022-2024 (Dassault Systèmes)Copyright (c) 2017-2022 (ESI Group)Copyright (c) 2011-2017 (Scilab Enterprises)Copyright (c) 1989-2012 (INRIA)Copyright (c) 1989-2007 (ENPC)with contributors Last updated:Mon Mar 27 11:52:43 GMT 2023