Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

norm

Vector Norm


Description

The Norm function calculates several different types of vector norms for x, depending on the argument p.

Usage

Norm(x, p = 2)

Arguments

x

Numeric vector; matrices not allowed.

p

Numeric scalar or Inf, -Inf; default is 2

Details

Norm returns a scalar that gives some measure of the magnitude of the elements of x. It is called the p-norm for values -Inf ≤ p ≤ Inf, defining Hilbert spaces on R^n.

Norm(x) is the Euclidean length of a vecor x; same as Norm(x, 2).
Norm(x, p) for finite p is defined as sum(abs(A)^p)^(1/p).
Norm(x, Inf) returns max(abs(x)), while Norm(x, -Inf) returns min(abs(x)).

Value

Numeric scalar (or Inf), or NA if an element of x is NA.

Note

In Matlab/Octave this is called norm; R's norm function norm(x, "F") (‘Frobenius Norm’) is the same as Norm(x).

See Also

norm of a matrix

Examples

Norm(c(3, 4))          #=> 5  Pythagoras triple
Norm(c(1, 1, 1), p=2)  #   sqrt(3)
Norm(1:10, p = 1)      #   sum(1:10)
Norm(1:10, p = 0)      #   Inf
Norm(1:10, p = Inf)    #   max(1:10)
Norm(1:10, p = -Inf)   #   min(1:10)

pracma

Practical Numerical Math Functions

v2.3.3
GPL (>= 3)
Authors
Hans W. Borchers [aut, cre]
Initial release
2021-01-22

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.