# Revision history [back]

You can easily figure out what any given function or method does by examining its docstring as follws:

sage: v = vector([3,0,9])
sage: v.normalize?

Type:       builtin_function_or_method
Base Class: <type 'builtin_function_or_method'>
String Form:    <built-in method normalize of sage.modules.vector_integer_dense.Vector_integer_dense object at 0x4badd08>
Namespace:  Interactive
Definition: v.normalize(self)
Docstring:

Return this vector divided through by the first nonzero entry of
this vector.

EXAMPLES:

sage: v = vector(QQ,[0,4/3,5,1,2])
sage: v.normalize()
(0, 1, 15/4, 3/4, 3/2)


So there shouldn't be any confusion about what this method does. The operation that is performed by this method is a perfectly reasonable notion of "normalization". It depends on the context, of course. This definition of normalize is probably useful when working with projective spaces or doing Guass-Jordan elimination.

To compute the unit vector in the direction of v, you could do:

sage: v/v.norm()
(1/10*sqrt(10), 0, 3/10*sqrt(10))


You can easily figure out what any given function or method does by examining its docstring as follws:follows:

sage: v = vector([3,0,9])
sage: v.normalize?

Type:       builtin_function_or_method
Base Class: <type 'builtin_function_or_method'>
String Form:    <built-in method normalize of sage.modules.vector_integer_dense.Vector_integer_dense object at 0x4badd08>
Namespace:  Interactive
Definition: v.normalize(self)
Docstring:

Return this vector divided through by the first nonzero entry of
this vector.

EXAMPLES:

sage: v = vector(QQ,[0,4/3,5,1,2])
sage: v.normalize()
(0, 1, 15/4, 3/4, 3/2)


So there shouldn't be any confusion about what this method does. The operation that is performed by this method is a perfectly reasonable notion of "normalization". It depends on the context, of course. This definition of normalize is probably useful when working with projective spaces or doing Guass-Jordan elimination.

To compute the unit vector in the direction of v, you could do:

sage: v/v.norm()
(1/10*sqrt(10), 0, 3/10*sqrt(10))