normalize(v)

Returns the normalized form of a list of floats

Except for the case of all zeroes, the normalized form corresponds to the unit vector in the direction of v.

Throws an exception if the sum of all squared elements is zero.

Parameters

v: List of floats

Return Value

normalized form of v

Example command:

  • normalize([1, 0, 0]) -> Returns [1, 0, 0]
  • normalize([0, 5, 0]) -> Returns [0, 1, 0]
  • normalize([0, 1, 1]) -> Returns [0, 0.707, 0.707]