Main Content

norm

Norm of symbolic vector or matrix

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 = 

(53360-139023360-1118014519180-73601790-37360)

norm2 = norm(A)
norm2 = 

36

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 = |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 = x2+y2

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 = 

(53360-139023360-1118014519180-73601790-37360)

norm1 = norm(A,1)
norm1 = 

1645

normf = norm(A,"fro")
normf = 

39160

normi = norm(A,Inf)
normi = 

1645

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 = |Vx|+|Vy|+|Vz|
norm2 = norm(V)
norm2 = |Vx|2+|Vy|2+|Vz|2
norm3 = norm(V,3)
norm3 = |Vx|3+|Vy|3+|Vz|31/3

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

normi = norm(V,Inf)
normi = max(|Vx|,|Vy|,|Vz|)
normni = norm(V,-Inf)
normni = min(|Vx|,|Vy|,|Vz|)
normf = norm(V,"fro")
normf = |Vx|2+|Vy|2+|Vz|2

Input Arguments

collapse all

Input vector, specified as a vector of symbolic scalar variables, symbolic matrix variable, function, or matrix function 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, symbolic matrix variable, function, or matrix function 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.

More About

collapse all

1-Norm of a Matrix

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

A1=maxj(i=1m|Aij|),  where j=1n

2-Norm of a Matrix

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

A2=max eigenvalue of AHA

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=max(j=1n|A1j|,j=1n|A2j|,,j=1n|Amj|)

Frobenius Norm of a Matrix and Multidimensional Array

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

AF=i=1m(j=1n|Aij|2)

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

XF=i=1l(j=1m(k=1n|Xijk|2))

P-Norm of a Vector

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

VP=(i=1n|Vi|P)1P

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:

VF=i=1n|Vi|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:

V=max(|Vi|), where i=1n

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

V=min(|Vi|), where i=1n

Tips

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

Version History

Introduced in R2012b

expand all