# Ticket #8825: trac_8825-more-norm-doc.patch

File trac_8825-more-norm-doc.patch, 8.9 KB (added by mvngu, 12 years ago)
• ## sage/matrix/matrix2.pyx

# HG changeset patch
# User Minh Van Nguyen <nguyenminh2@gmail.com>
# Date 1272656283 25200
# Node ID d18a4dd6434c5c08316149189094ca59d2b47983
# Parent  d2f2f1bd8c082a20c3b35a4625ca3942b420d205
#8825: improve documentation for function norm and cross reference various norm functions

diff --git a/sage/matrix/matrix2.pyx b/sage/matrix/matrix2.pyx
 a OUTPUT: RDF number .. SEEALSO:: - :func:sage.misc.functional.norm EXAMPLES::
• ## sage/misc/functional.py

diff --git a/sage/misc/functional.py b/sage/misc/functional.py
 a return x.ngens() def norm(x): """ Returns the norm of x. r""" Returns the norm of x. For matrices and vectors, this returns the L2-norm. For complex numbers, it returns the field norm. For matrices and vectors, this returns the L2-norm. The L2-norm of a vector \textbf{v} = (v_1, v_2, \dots, v_n), also called the Euclidean norm, is defined as .. MATH:: |\textbf{v}| = \sqrt{\sum_{i=1}^n |v_i|^2} where |v_i| is the complex modulus of v_i. The Euclidean norm is often used for determining the distance between two points in two- or three-dimensional space. For complex numbers, the function returns the field norm. If c = a + bi is a complex number, then the norm of c is defined as the product of c and its complex conjugate .. MATH:: \text{norm}(c) = \text{norm}(a + bi) = c \cdot \overline{c} = a^2 + b^2. The norm of a complex number is different from its absolute value. The absolute value of a complex number is defined to be the square root of its norm. A typical use of the complex norm is in the integral domain \ZZ[i] of Gaussian integers, where the norm of each Gaussian integer c = a + bi is defined as its complex norm. .. SEEALSO:: - :meth:sage.matrix.matrix2.Matrix.norm - :meth:sage.modules.free_module_element.FreeModuleElement.norm - :meth:sage.rings.complex_double.ComplexDoubleElement.norm - :meth:sage.rings.complex_number.ComplexNumber.norm - :meth:sage.symbolic.expression.Expression.norm EXAMPLES:: sage: z = 1+2*I sage: norm(z) 5 EXAMPLES: The norm of vectors:: sage: z = 1 + 2*I sage: norm(vector([z])) sqrt(5) sage: v = vector([-1,2,3]) sage: norm(v) sqrt(14) sage: _ = var("a b c d") sage: v = vector([a, b, c, d]) sage: norm(v) sqrt(abs(a)^2 + abs(b)^2 + abs(c)^2 + abs(d)^2) The norm of matrices:: sage: z = 1 + 2*I sage: norm(matrix([[z]])) 2.2360679775 sage: M = matrix(ZZ, [[1,2,4,3], [-1,0,3,-10]]) sage: norm(M) 10.6903311292 sage: norm(CDF(z)) 5.0 sage: norm(CC(z)) 5.00000000000000 The norm of complex numbers:: sage: z = 2 - 3*I sage: norm(z) 13 sage: a = randint(-10^10, 100^10) sage: b = randint(-10^10, 100^10) sage: z = a + b*I sage: bool(norm(z) == a^2 + b^2) True The complex norm of symbolic expressions:: sage: a, b, c = var("a, b, c") sage: z = a + b*I sage: bool(norm(z).simplify() == a^2 + b^2) True sage: norm(a + b).simplify() a^2 + 2*a*b + b^2 sage: v = vector([a, b, c]) sage: bool(norm(v).simplify_full() == sqrt(a^2 + b^2 + c^2)) True """ return x.norm()
• ## sage/modules/free_module_element.pyx

diff --git a/sage/modules/free_module_element.pyx b/sage/modules/free_module_element.pyx
 a \geq 1, Infinity, or a symbolic expression. If p=2 (default), this is the usual Euclidean norm; if p=Infinity, this is the maximum norm; if p=1, this is the taxicab (Manhattan) norm. .. SEEALSO:: - :func:sage.misc.functional.norm EXAMPLES::
• ## sage/rings/complex_double.pyx

diff --git a/sage/rings/complex_double.pyx b/sage/rings/complex_double.pyx
 a def abs(self): """ This function returns the magnitude of the complex number z, |z|. This function returns the magnitude |z| of the complex number z. .. SEEALSO:: - :meth:norm EXAMPLES:: def abs2(self): """ This function returns the squared magnitude of the complex number z, |z|^2. This function returns the squared magnitude |z|^2 of the complex number z, otherwise known as the complex norm. .. SEEALSO:: - :meth:norm EXAMPLES:: sage: CDF(2,3).abs2() return RealDoubleElement(gsl_complex_abs2(self._complex)) def norm(self): """ This function returns the squared magnitude of the complex number z, |z|^2. r""" This function returns the squared magnitude |z|^2 of the complex number z, otherwise known as the complex norm. If c = a + bi is a complex number, then the norm of c is defined as the product of c and its complex conjugate .. MATH:: \text{norm}(c) = \text{norm}(a + bi) = c \cdot \overline{c} = a^2 + b^2. The norm of a complex number is different from its absolute value. The absolute value of a complex number is defined to be the square root of its norm. A typical use of the complex norm is in the integral domain \ZZ[i] of Gaussian integers, where the norm of each Gaussian integer c = a + bi is defined as its complex norm. .. SEEALSO:: - :meth:abs - :meth:abs2 - :func:sage.misc.functional.norm - :meth:sage.rings.complex_number.ComplexNumber.norm EXAMPLES::
• ## sage/rings/complex_number.pyx

diff --git a/sage/rings/complex_number.pyx b/sage/rings/complex_number.pyx
 a def norm(self): r""" Returns the norm of this complex number. If c = a + bi is a complex number, then the norm of c is defined as complex number, then the norm of c is defined as the product of c and its complex conjugate .. MATH:: \text{norm}(c) = \text{norm}(a + bi) = a^2 + b^2 \text{norm}(c) = \text{norm}(a + bi) = c \cdot \overline{c} = a^2 + b^2. The norm of a complex number is different from its absolute value. The absolute value of a complex number is defined to be the square root of its norm. A typical use of the complex norm is in the integral domain \ZZ[i] of Gaussian integers, where the norm of each Gaussian integer c = a + bi is defined as its complex norm. .. SEEALSO:: - :func:sage.misc.functional.norm - :meth:sage.rings.complex_double.ComplexDoubleElement.norm EXAMPLES:
• ## sage/symbolic/expression.pyx

diff --git a/sage/symbolic/expression.pyx b/sage/symbolic/expression.pyx
 a def norm(self): r""" The complex norm of this symbolic expression, i.e., the expression times its complex conjugate. the expression times its complex conjugate. If c = a + bi is a complex number, then the norm of c is defined as the product of c and its complex conjugate .. MATH:: \text{norm}(c) = \text{norm}(a + bi) = c \cdot \overline{c} = a^2 + b^2. The norm of a complex number is different from its absolute value. The absolute value of a complex number is defined to be the square root of its norm. A typical use of the complex norm is in the integral domain \ZZ[i] of Gaussian integers, where the norm of each Gaussian integer c = a + bi is defined as its complex norm. .. SEEALSO:: - :func:sage.misc.functional.norm EXAMPLES::