norm - Norm of symbolic vector or matrix (2025)

Norm of symbolic vector or matrix

collapse all in page

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 or the magnitude of symbolic vector v.

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.

example

n = norm(X,"fro") returns the Frobenius norm of symbolic multidimensional array X.

Examples

collapse all

Magnitude of Symbolic Vector

Open Live Script

Create a symbolic vector and calculate the magnitude.

syms x y zr = [x y z]
r =(xyz)
n = norm(r)
n =|x|2+|y|2+|z|2

Compute 2-Norm of Matrix

Open Live Script

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 =0.28867513459481288225

Effect of Assumptions on Norm

Open Live Script

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 yn = 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 Different Types of Norms of Matrix

Open Live Script

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 Different Types of Norms of Vector

Open Live Script

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

syms Vx Vy VzV = [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

vInput vector
vector of symbolic scalar variables | symbolic matrix variable | symbolic function | symbolic matrix function

Input vector, specified as a vector of symbolic scalar variables, symbolic matrix variable, function, or matrix function that represents a vector.

pInput
2 (default) | 1 | positive integer scalar | Inf | -Inf | "fro"

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

AInput matrix
matrix of symbolic scalar variables | symbolic matrix variable | symbolic function | symbolic matrix function

Input matrix, specified as a matrix of symbolic scalar variables, symbolic matrix variable, function, or matrix function that represents a matrix.

PInput
2 (default) | 1 | Inf | "fro"

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.

XInput array
multidimensional array of symbolic scalar variables

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|),wherej=1n

2-Norm of a Matrix

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

A2=maxeigenvalueofAHA

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|),wherei=1n

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

V=min(|Vi|),wherei=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

The norm function accepts a symbolic multidimensional array as its input argument. Use the syntax norm(X,"fro") to return the Frobenius norm of a symbolic array X.

The norm function accepts an input argument of type symfunmatrix.

The norm function accepts an input argument of type symmatrix.

See Also

cond | equationsToMatrix | inv | linsolve | rank

MATLAB Command

You clicked a link that corresponds to this MATLAB command:

 

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

norm - Norm of symbolic vector or matrix (1)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
  • 日本 (日本語)
  • 한국 (한국어)

Contact your local office

norm - Norm of symbolic vector or matrix (2025)

References

Top Articles
Latest Posts
Recommended Articles
Article information

Author: Aracelis Kilback

Last Updated:

Views: 5990

Rating: 4.3 / 5 (44 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Aracelis Kilback

Birthday: 1994-11-22

Address: Apt. 895 30151 Green Plain, Lake Mariela, RI 98141

Phone: +5992291857476

Job: Legal Officer

Hobby: LARPing, role-playing games, Slacklining, Reading, Inline skating, Brazilian jiu-jitsu, Dance

Introduction: My name is Aracelis Kilback, I am a nice, gentle, agreeable, joyous, attractive, combative, gifted person who loves writing and wants to share my knowledge and understanding with you.