Function Repository Resource:

RealEuclideanDistance

Source Notebook

Get the Euclidean distance between two real vectors without using absolute value

Contributed by: Ed Pegg Jr

ResourceFunction["RealEuclideanDistance"][u,v]

gives the Euclidean distance between real vectors u and v without using Abs.

Examples

Basic Examples (3) 

Compute the real Euclidean distance between two points:

In[1]:=
ResourceFunction["RealEuclideanDistance"][{0, 0}, {x, y}]
Out[1]=

Compute in three dimensions:

In[2]:=
ResourceFunction["RealEuclideanDistance"][{0, 0, 0}, {x, y, z}]
Out[2]=

Using numeric values:

In[3]:=
ResourceFunction["RealEuclideanDistance"][{1, 4, -3}, {2, -2, 6}]
Out[3]=

Properties and Relations (2) 

EuclideanDistance adds Abs for variables and complicated expressions, making them more complicated. Often, that extra complication will make Simplify more difficult:

In[4]:=
EuclideanDistance[{0, 0}, {x, y}]
Out[4]=

Compare with RealEuclideanDistance:

In[5]:=
ResourceFunction["RealEuclideanDistance"][{0, 0}, {x, y}]
Out[5]=

Requirements

Wolfram Language 11.3 (March 2018) or above

Version History

  • 1.0.1 – 29 January 2021
  • 1.0.0 – 05 February 2019

License Information