Skip to content

norm

Norm of a vector or matrix

norm(x)

  • If x is a vector, it returns the 2-norm of x, i.e., $$ ||x||_2=\sqrt{x_1^2+x_2^2+\cdots+x_n^2} $$

norm(x, p)

  • If x is a vector, p should be positive infinity, negative infinity, or a positive scalar.
  • If p is positive infinity, it returns the largest absolute value of x's elements.
  • If p is negative infinity, it returns the smallest absolute value of x's elements.
  • Otherwise, it returns the p-norm of x, i.e., $$ ||x||_p=\left(|x_1|^p+|x_2|^p+\cdots+|x_n|^p\right) $$

  • If x is a matrix, p should be either 1, 2, or infinity.

  • If p is 1, it returns (assuming m rows and n columns) $$ \max_{j\in{1,2,\ldots,n}} \sum^m_{i=1}|x_{ij}|. $$

  • If p is 2, it returns the largest singular value of x.

  • If p is inf, it returns (assuming m rows and n columns) $$ \max_{i\in{1,2,\ldots,m}} \sum^n_{j=1}|x_{ij}|. $$