structural:expansion
Euclidean distance

The distance formula in Cartesian coordinates is derived from the Pythagorean theorem. If (x, y) and (x, y) are points in the plane, then the distance between them, also called the Euclidean distance, is given by

More generally, in Euclidean n -space, the Euclidean distance between two points, A = (a 1, a 2, …, a n) {\displaystyle A\,=\,(a_{1},a_{2},\dots,a_{n})} and B = (b 1, b 2, …, b n) {\displaystyle B\,=\,(b_{1},b_{2},\dots,b_{n})}, is defined, by generalization of the Pythagorean theorem, as:

If instead of Euclidean distance, the square of this value (the squared Euclidean distance, or SED) is used, the resulting equation avoids square roots and is simply a sum of the SED of the coordinates:

The squared form is a smooth, convex function of both points, and is widely used in optimization theory and statistics, forming the basis of least squares.