norm

Norm of matrix or vector

Description

example

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

example

norm(A,p) returns the p-norm of matrix A.

norm(V) returns the 2-norm of vector V.

example

norm(V,P) returns the P-norm of vector V.

Examples

collapse all

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

A = inv(sym(magic(3)))
norm2 = norm(A)
A =
[  53/360, -13/90,  23/360]
[ -11/180,   1/45,  19/180]
[  -7/360,  17/90, -37/360]
 
norm2 =
3^(1/2)/6

Use vpa to approximate the result with 20-digit accuracy:

vpa(norm2, 20)
ans =
0.28867513459481288225

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

syms x y
simplify(norm([x y]))
ans =
(abs(x)^2 + abs(y)^2)^(1/2)

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

assume([x y],'real')
simplify(norm([x y]))
ans =
(x^2 + y^2)^(1/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)))
norm1 = norm(A, 1)
normf = norm(A, 'fro')
normi = norm(A, inf)
A =
[  53/360, -13/90,  23/360]
[ -11/180,   1/45,  19/180]
[  -7/360,  17/90, -37/360]
 
norm1 =
16/45
 
normf =
391^(1/2)/60
 
normi =
16/45

Use vpa to approximate these results to 20-digit accuracy:

vpa(norm1, 20)
vpa(normf, 20)
vpa(normi, 20)
ans =
0.35555555555555555556
 
ans =
0.32956199888808647519
 
ans =
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)
norm2 = norm(V)
norm3 = norm(V, 3)
norm1 =
abs(Vx) + abs(Vy) + abs(Vz)
 
norm2 =
(abs(Vx)^2 + abs(Vy)^2 + abs(Vz)^2)^(1/2)
 
norm3 =
(abs(Vx)^3 + abs(Vy)^3 + abs(Vz)^3)^(1/3)

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

normi = norm(V, inf)
normni = norm(V, -inf)
normf = norm(V, 'fro')
normi =
max(abs(Vx), abs(Vy), abs(Vz))
 
normni =
min(abs(Vx), abs(Vy), abs(Vz))
 
normf =
(abs(Vx)^2 + abs(Vy)^2 + abs(Vz)^2)^(1/2)

Input Arguments

collapse all

Input, specified as a symbolic 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, specified as a symbolic 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(A,inf) is computed as max(abs(V)).

  • norm(A,-inf) is computed as min(abs(V)).

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.

Frobenius Norm of a Matrix

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

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

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

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.

Introduced in R2012b