Skip to content

Normalize ​

v divided by its Euclidean norm -- a unit vector in v's direction.

✓ checked against that system · ! checked, with disagreements (hover a chip)Wolfram LanguageNormalize!
Normalize(v)v / Sqrt(Total(Abs(v)^2))
Normalize(v, f)v / f(v), a custom norm function
Typed signatures
TypePackageApplies
(any, ((any) -> any)?) -> anycombinatoricsalways

Domain: Collections

Details
  • The zero vector is returned unchanged -- there is no direction to normalize it to.

Examples

Basic #

The 3-4-5 triangle's direction vector, normalized to unit length

live ↗
InNormalize([3,4])\mathrm{Normalize}(\bigl\lbrack3, 4\bigr\rbrack)Out[35,45]\bigl\lbrack\frac{3}{5}, \frac{4}{5}\bigr\rbrack

Divides by the Euclidean norm 27=33\sqrt{27} = 3\sqrt3, keeping exact radicals

live ↗
InNormalize([1,5,1])\mathrm{Normalize}(\bigl\lbrack1, 5, 1\bigr\rbrack)Out[39,539,39]\bigl\lbrack\frac{\sqrt{3}}{9}, \frac{5\sqrt{3}}{9}, \frac{\sqrt{3}}{9}\bigr\rbrack
Scope #

The zero vector has no direction, so it is left unchanged

live ↗
InNormalize([0,0])\mathrm{Normalize}(\bigl\lbrack0, 0\bigr\rbrack)Out[0,0]\bigl\lbrack0, 0\bigr\rbrack
live ↗
InNormalize([x,y],f)\mathrm{Normalize}(\bigl\lbrack x, y\bigr\rbrack, f)Out[xf([x,y]),yf([x,y])]\bigl\lbrack\frac{x}{f(\bigl\lbrack x, y\bigr\rbrack)}, \frac{y}{f(\bigl\lbrack x, y\bigr\rbrack)}\bigr\rbrack
live ↗
InNormalize([x,y])\mathrm{Normalize}(\bigl\lbrack x, y\bigr\rbrack)Out[x∣x∣2+∣y∣2,y∣x∣2+∣y∣2]\bigl\lbrack\frac{x}{\sqrt{\vert x\vert^2+\vert y\vert^2}}, \frac{y}{\sqrt{\vert x\vert^2+\vert y\vert^2}}\bigr\rbrack
live ↗
InNormalize(1+x+x2,_1⁡↦∫−11 ⁣_1⁡2 dx)\mathrm{Normalize}(1+x+x^2, \operatorname{\_1}↦\int_{-1}^{1}\!\operatorname{\_1}^2\, \mathrm{d}x)Out122×5(x2+x+1)\frac{1}{22}×5(x^2+x+1)
live ↗
InNormalize([[1,2],[4,5]],Norm)\mathrm{Normalize}(\bigl\lbrack\bigl\lbrack1, 2\bigr\rbrack, \bigl\lbrack4, 5\bigr\rbrack\bigr\rbrack, \mathrm{Norm})Out[[4646,4623],[24623,54646]]\bigl\lbrack\bigl\lbrack\frac{\sqrt{46}}{46}, \frac{\sqrt{46}}{23}\bigr\rbrack, \bigl\lbrack\frac{2\sqrt{46}}{23}, \frac{5\sqrt{46}}{46}\bigr\rbrack\bigr\rbrack
About
Examples7
Checked againstWolfram Language 6 agree1 differ
CrosswalkWolfram Language