norm -- compute the norm of a
matrix, a vector, or a polynomial
Introductionnorm(M, kM) computes the norm of index
kM of the matrix M.
norm(v, kv) computes the norm of index
kv of the vector v.
norm(p, kp) computes the norm of index
kp of the polynomial p.
Call(s)norm(M <, kM>)
norm(v <, kv>)
norm(p <, kp>)
norm(f <, vars> <, kp>)
ParametersM |
- | a matrix of domain type
Dom::Matrix(...) |
kM |
- | the index of the matrix norm: either 1, or Frobenius or Infinity. The default value is Infinity. |
v |
- | a vector (a 1-dimensional matrix) |
kv |
- | the index of the vector norm: either a positive integer, or Frobenius, or Infinity. The default value is Infinity. |
p |
- | a polynomial generated by
poly |
f |
- | a polynomial expression |
vars |
- | a list of identifiers or indexed identifiers,
interpreted as the indeterminates of f |
kp |
- | the index of the norm of the polynomial: a real number >= 1. If no index is specified, the maximum norm (of index infinity) is computed. |
Returnsan arithmetical expression.
p, f
Related
Functions
DetailsM = (M[i,j])
with min(m, n) > 1, only the 1-norm (maximum
column sum)
norm(M, 1) = max(sum(|M[i,j]|, i=1..m), j=1..n),the Frobenius norm
norm(M, Frobenius) = sqrt(sum(sum(|M[i,j]|^2, i=1..m), j=1..n)),and the ∞-norm (maximum row sum)
norm(M) = norm(M, Infinity) = max(sum(|M[i,j]|, i=1..m), j=1..n),can be computed. The 1-norm and the Infinity-norm are operator norms with respect to the corresponding norms on the vector spaces the matrix is acting upon.
For numerical matrices, the spectral norm (the operator norm with
respect to the Euclidean norm (index 2)) is the largest singular value.
It can be computed via numeric::singularvalues.
v = (v[i]), represented by
matrices of dimension 1 x n or n x 1, norms with
arbitrary positive integer indices k as well as Infinity can be computed. For integers k >
1, the vector norms are given by
norm(v, k) = sum(|v[i]|^k, k = 1..n)^(1/k)for column vectors as well as for row vectors.
For indices 1, Infinity, and Frobenius, the vector norms are given by the corresponding matrix norms. For column vectors, the 1-norm is the sum norm
norm(v, 1) = sum(|v[i]|, i = 1..n),the Infinity-norm is the maximum norm
norm(v) = norm(v, Infinity) = max(|v[1]|,.., |v[n]|)(this is the limit of the k-norms as k tends to infinity).
For row vectors, the 1-norm is the maximum norm, whilst the Infinity-norm is the sum norm.
The Frobenius norm coincides with norm(v, 2) for both
column and row vectors.
Cf. example 2.
Dom::Matrix (note that the
function matrix
generates matrices of type Dom::Matrix()).p with coefficients c[i],
the norms are given by
norm(p) = max(|c[i]|, i), norm(p, k) = sum(|c[i]|^n, k)^(1/k).Also multivariate polynomials are accepted by
norm. The
coefficients with respect to all indeterminates are taken into
account.PI+1,
sqrt(2) etc. are accepted. Internally, they are converted
to floating point numbers. Cf. example 3.k> 1, norm(p,
k) always returns a floating point number. The
1-norm produces an exact result if all coefficients are
integers or rational numbers. The Infinity-norm
norm(p) produces an exact result, if the coefficient of
largest magnitude is an integer or a rational number. In all other
cases, also the 1-norm and the Infinity-norm
produce floating point numbers. Cf. example 3.norm produces an error."norm". This method must return the norm of the
coefficients as a number or as a numerical expression that can be
converted to a floating point number via float. With the coefficient norms
||c[i]||, norm(p) computes the
maximum norm max(norm(c[i])); norm(p,
k) computes sum(norm(c[i])^k)^(1/k).f is internally converted to
the polynomial poly(f).
If a list of indeterminates is specified, the norm of the polynomial
poly(f, vars) is
computed.
Example
1We compute various norms of a 2 x 3 matrix:
>> M := matrix([[2, 5, 8], [-2, 3, 5]]): norm(M) = norm(M, Infinity), norm(M, 1), norm(M, Frobenius)
1/2
15 = 15, 13, 131
For matrices, norm produces exact symbolic
results:
>> M := matrix([[2/3, 63, PI],[x, y, z]]): norm(M)
max(PI + 191/3, abs(x) + abs(y) + abs(z))
>> norm(M, 1)
max(abs(x) + 2/3, abs(y) + 63, PI + abs(z))
>> norm(M, Frobenius)
2 2 2 2 1/2
(PI + abs(x) + abs(y) + abs(z) + 35725/9)
>> delete M:
Example
2A column vector col and a row vector
row are considered:
>> col := matrix([x1, PI]): row := matrix([[x1, PI]]): col, row
+- -+
| x1 | +- -+
| |, | x1, PI |
| PI | +- -+
+- -+
>> norm(col, 2) = norm(row, 2)
2 1/2 2 1/2
(x1 conjugate(x1) + PI ) = (x1 conjugate(x1) + PI )
>> norm(col, 3) = norm(row, 3)
3 3 1/3 3 3 1/3
(PI + abs(x1) ) = (PI + abs(x1) )
Note that the norms of index 1 and Infinity have exchanged meanings for column and row vectors:
>> norm(col, 1) = norm(row, Infinity)
PI + abs(x1) = PI + abs(x1)
>> norm(col, Infinity) = norm(row, 1)
max(abs(x1), PI) = max(abs(x1), PI)
>> delete col, row:
Example
3The norms of some polynomials are computed:
>> p := poly(3*x^3 + 4*x, [x]): norm(p), norm(p, 1)
4, 7
If the coefficients are not integers or rational numbers, automatic conversion to floating point numbers occurs:
>> p := poly(3*x^3 + sqrt(2)*x + PI, [x]): norm(p), norm(p, 1)
3.141592654, 7.555806216
Floating point numbers are always produced for indices > 1:
>> p := poly(3*x^3 + 4*x + 1, [x]): norm(p, 1), norm(p, 2), norm(p, 5), norm(p, 10), norm(p)
8, 5.099019514, 4.174686339, 4.021974513, 4
>> delete p:
Example
4The norms of some polynomial expressions are computed:
>> norm(x^3 + 1, 1), norm(x^3 + 1, 2), norm(x^3 + PI)
2, 1.414213562, 1
The following call yields an error, because the
expression is regarded as a polynomial in x. Consequently,
symbolic coefficients 6*y and 9*y^2 are found
which are not accepted:
>> f := 6*x*y + 9*y^2 + 2: norm(f, [x])
Error: Illegal argument [norm]
As a bivariate polynomial with the indeterminates
x and y, the coefficients are 6,
9, and 2. Now, norms can be computed:
>> norm(f, [x, y], 1), norm(f, [x, y], 2), norm(f, [x, y])
17, 11.0, 9
>> delete f: