norm()
Compute the L2 (Euclidean) norm of a vector.
Usage
norm(vector)Returns the magnitude of the input vector, computed as the square root of the sum of squared elements.
Parameters
vector: list-
A list of numeric values representing a vector.
Returns
float-
The L2 norm of the vector.
Notes
Computes the L2 norm:
\|x\| = \sqrt{\sum_{i=1}^{n} x_i^2}
For a zero vector, the norm is 0.0. The computation uses floating-point arithmetic, so results may have small rounding errors for very large or very small values.
Examples
>>> norm([3.0, 4.0])5.0
>>> norm([1.0, 0.0, 0.0])1.0