# norm

Norm of symbolic vector or matrix

## Syntax

``n = norm(v)``
``n = norm(v,p)``
``n = norm(A)``
``n = norm(A,P)``
``n = norm(X,"fro")``

## Description

````n = norm(v)` returns the `2`-norm of symbolic vector `v`.```

example

````n = norm(v,p)` returns the `p`-norm of symbolic vector `v`.```

example

````n = norm(A)` returns the `2`-norm of symbolic matrix `A`. Because symbolic variables are assumed to be complex by default, the norm can contain unresolved calls to `conj` and `abs`.```

example

````n = norm(A,P)` returns the `P`-norm of symbolic matrix `A`.```
````n = norm(X,"fro")` returns the Frobenius norm of symbolic multidimensional array `X`.```

## Examples

collapse all

Compute the 2-norm of the inverse of the 3-by-3 magic square `A`.

`A = inv(sym(magic(3)))`
```A =  $\left(\begin{array}{ccc}\frac{53}{360}& -\frac{13}{90}& \frac{23}{360}\\ -\frac{11}{180}& \frac{1}{45}& \frac{19}{180}\\ -\frac{7}{360}& \frac{17}{90}& -\frac{37}{360}\end{array}\right)$```
`norm2 = norm(A)`
```norm2 =  $\frac{\sqrt{3}}{6}$```

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

`norm2_vpa = vpa(norm2,20)`
`norm2_vpa = $0.28867513459481288225$`

Compute the norm of `[x y]` and simplify the result. Because symbolic scalar variables are assumed to be complex by default, the calls to `abs` do not simplify.

```syms x y n = simplify(norm([x y]))```
`n = $\sqrt{{|x|}^{2}+{|y|}^{2}}$`

Assume `x` and `y` are real, and repeat the calculation. Now, the result is simplified.

```assume([x y],"real") n = simplify(norm([x y]))```
`n = $\sqrt{{x}^{2}+{y}^{2}}$`

Remove assumptions on `x` for further calculations. For details, see Use Assumptions on Symbolic Variables.

`assume(x,"clear")`

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

`A = inv(sym(magic(3)))`
```A =  $\left(\begin{array}{ccc}\frac{53}{360}& -\frac{13}{90}& \frac{23}{360}\\ -\frac{11}{180}& \frac{1}{45}& \frac{19}{180}\\ -\frac{7}{360}& \frac{17}{90}& -\frac{37}{360}\end{array}\right)$```
`norm1 = norm(A,1)`
```norm1 =  $\frac{16}{45}$```
`normf = norm(A,"fro")`
```normf =  $\frac{\sqrt{391}}{60}$```
`normi = norm(A,Inf)`
```normi =  $\frac{16}{45}$```

Use `vpa` to approximate these results to 20-digit accuracy.

`norm1_vpa = vpa(norm1,20)`
`norm1_vpa = $0.35555555555555555556$`
`normf_vpa = vpa(normf,20)`
`normf_vpa = $0.32956199888808647519$`
`normi_vpa = vpa(normi,20)`
`normi_vpa = $0.35555555555555555556$`

Compute the 1-norm, 2-norm, and 3-norm of the column vector `V = [Vx; Vy; Vz]`.

```syms Vx Vy Vz V = [Vx; Vy; Vz]; norm1 = norm(V,1)```
`norm1 = $|\mathrm{Vx}|+|\mathrm{Vy}|+|\mathrm{Vz}|$`
`norm2 = norm(V)`
`norm2 = $\sqrt{{|\mathrm{Vx}|}^{2}+{|\mathrm{Vy}|}^{2}+{|\mathrm{Vz}|}^{2}}$`
`norm3 = norm(V,3)`
`norm3 = ${\left({|\mathrm{Vx}|}^{3}+{|\mathrm{Vy}|}^{3}+{|\mathrm{Vz}|}^{3}\right)}^{1/3}$`

Compute the infinity norm, negative infinity norm, and Frobenius norm of `V`.

`normi = norm(V,Inf)`
`normi = $\mathrm{max}\left(|\mathrm{Vx}|,|\mathrm{Vy}|,|\mathrm{Vz}|\right)$`
`normni = norm(V,-Inf)`
`normni = $\mathrm{min}\left(|\mathrm{Vx}|,|\mathrm{Vy}|,|\mathrm{Vz}|\right)$`
`normf = norm(V,"fro")`
`normf = $\sqrt{{|\mathrm{Vx}|}^{2}+{|\mathrm{Vy}|}^{2}+{|\mathrm{Vz}|}^{2}}$`

## Input Arguments

collapse all

Input vector, specified as a vector of symbolic scalar variables, or a symbolic matrix variable (since R2021a) that represents a vector.

• `norm(v,p)` is computed as `sum(abs(v).^p)^(1/p)` for `1<=p<Inf`.

• `norm(v)` computes the `2`-norm of `V`.

• `norm(v,Inf)` is computed as `max(abs(V))`.

• `norm(v,-Inf)` is computed as `min(abs(V))`.

Input matrix, specified as a matrix of symbolic scalar variables, or a symbolic matrix variable (since R2021a) that represents a matrix.

One of these values `1`, `2`, `Inf`, or `"fro"`.

• `norm(A,1)` returns the `1`-norm of `A`.

• `norm(A,2)` or `norm(A)` returns the `2`-norm of `A`.

• `norm(A,Inf)` returns the infinity norm of `A`.

• `norm(A,"fro")` returns the Frobenius norm of `A`.

Input array, specified as a multidimensional array of symbolic scalar variables.

collapse all

### 1-Norm of a Matrix

The `1`-norm of an m-by-n matrix A is defined as follows:

### 2-Norm of a Matrix

The `2`-norm of an m-by-n matrix A is defined as follows:

The `2`-norm is also called the spectral norm of a matrix.

### Infinity Norm of a Matrix

The infinity norm of an m-by-n matrix A is defined as follows:

`${‖A‖}_{\infty }=\mathrm{max}\left(\sum _{j=1}^{n}|{A}_{1j}|,\text{\hspace{0.17em}}\sum _{j=1}^{n}|{A}_{2j}|,\dots ,\sum _{j=1}^{n}|{A}_{mj}|\right)$`

### Frobenius Norm of a Matrix and Multidimensional Array

The Frobenius norm of an m-by-n matrix A is defined as follows:

`${‖A‖}_{F}=\sqrt{\sum _{i=1}^{m}\left(\sum _{j=1}^{n}{|{A}_{ij}|}^{2}\right)}$`

The Frobenius norm of an l-by-m-by-n multidimensional array X is defined as follows:

`${‖X‖}_{F}=\sqrt{\sum _{i=1}^{l}\left(\sum _{j=1}^{m}\left(\sum _{k=1}^{n}{|{X}_{ijk}|}^{2}\right)\right)}$`

### P-Norm of a Vector

The `P`-norm of a 1-by-n or n-by-1 vector V is defined as follows:

`${‖V‖}_{P}={\left(\sum _{i=1}^{n}{|{V}_{i}|}^{P}\right)}^{1}{P}}$`

Here n must be an integer greater than 1.

### Frobenius Norm of a Vector

The Frobenius norm of a 1-by-n or n-by-1 vector V is defined as follows:

`${‖V‖}_{F}=\sqrt{\sum _{i=1}^{n}{|{V}_{i}|}^{2}}$`

The Frobenius norm of a vector coincides with its `2`-norm.

### Infinity and Negative Infinity Norm of a Vector

The infinity norm of a 1-by-n or n-by-1 vector V is defined as follows:

The negative infinity norm of a 1-by-n or n-by-1 vector V is defined as follows:

## Tips

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

## Version History

Introduced in R2012b