norm
Norm of symbolic vector or matrix
Description
returns the
n
= norm(v
)2
-norm or the magnitude of symbolic vector
v
.
returns the
n
= norm(A
)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
.
returns the Frobenius norm of symbolic multidimensional array
n
= norm(X
,"fro")X
.
Examples
Magnitude of Symbolic Vector
Create a symbolic vector and calculate the magnitude.
syms x y z r = [x y z]
r =
n = norm(r)
n =
Compute 2-Norm of Matrix
Compute the 2-norm of the inverse of the 3-by-3 magic square A
.
A = inv(sym(magic(3)))
A =
norm2 = norm(A)
norm2 =
Use vpa
to approximate the result with 20-digit accuracy.
norm2_vpa = vpa(norm2,20)
norm2_vpa =
Effect of Assumptions on Norm
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 =
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 =
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
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 =
norm1 = norm(A,1)
norm1 =
normf = norm(A,"fro")
normf =
normi = norm(A,Inf)
normi =
Use vpa
to approximate these results to 20-digit accuracy.
norm1_vpa = vpa(norm1,20)
norm1_vpa =
normf_vpa = vpa(normf,20)
normf_vpa =
normi_vpa = vpa(normi,20)
normi_vpa =
Compute Different Types of Norms of Vector
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 =
norm2 = norm(V)
norm2 =
norm3 = norm(V,3)
norm3 =
Compute the infinity norm, negative infinity norm, and Frobenius norm of V
.
normi = norm(V,Inf)
normi =
normni = norm(V,-Inf)
normni =
normf = norm(V,"fro")
normf =
Input Arguments
v
— Input 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.
p
— Input
2
(default) | 1
| positive integer scalar | Inf
| -Inf
| "fro"
norm(v,p)
is computed assum(abs(v).^p)^(1/p)
for1<=p<Inf
.norm(v)
computes the2
-norm ofV
.norm(v,Inf)
is computed asmax(abs(V))
.norm(v,-Inf)
is computed asmin(abs(V))
.
A
— Input 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.
P
— Input
2
(default) | 1
| Inf
| "fro"
One of these values 1
, 2
,
Inf
, or "fro"
.
norm(A,1)
returns the1
-norm ofA
.norm(A,2)
ornorm(A)
returns the2
-norm ofA
.norm(A,Inf)
returns the infinity norm ofA
.norm(A,"fro")
returns the Frobenius norm ofA
.
X
— Input array
multidimensional array of symbolic scalar variables
Input array, specified as a multidimensional array of symbolic scalar variables.
More About
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:
Frobenius Norm of a Matrix and Multidimensional Array
The Frobenius norm of an m-by-n matrix A is defined as follows:
The Frobenius norm of an l-by-m-by-n multidimensional array X is defined as follows:
P-Norm of a Vector
The P
-norm of a 1-by-n or
n-by-1 vector V is defined as follows:
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:
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 R2012bR2022a: Compute Frobenius norm of symbolic array
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
.
R2022a: Compute norm of symbolic matrix functions
The norm
function accepts an input argument of type
symfunmatrix
.
R2021a: Compute norm of symbolic matrix variables
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.
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
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
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
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)