A met­ric, some­times referred to as a dis­tance func­tion, is a func­tion that defines a real non­nega­tive dis­tance be­tween ev­ery two el­e­ments of a set. It is com­monly de­noted by the vari­able \(d\). In colon-to no­ta­tion, a met­ric \(d\) that defines dis­tances be­tween el­e­ments of the set \(S\) is writ­ten:

$$d: S \times S \to [0, \infty)$$

In this case we say \(d\) is a met­ric on \(S\).

That is, a met­ric \(d\) on a set \(S\) takes as in­put any two el­e­ments \(a\) and \(b\) from \(S\) and out­puts a num­ber that is taken to define their dis­tance in \(S\) un­der \(d\). Apart from be­ing non­nega­tive real num­bers, the dis­tances a met­ric out­puts must fol­low three other rules in or­der for the func­tion to meet the defi­ni­tion of a met­ric. A func­tion that matches the above colon-to no­ta­tion is called a met­ric if and only if it satis­fies these re­quire­ments. The fol­low­ing must hold for any choice of \(a\), \(b\), and \(c\) in \(S\):

  1. \(d(a, b) = 0 \iff a = b\)

  2. \(d(a, b) = d(b, a)\)

  3. \(d(a, b) + d(b, c) \geq d(a, c)\)

(1) effec­tively states both that the dis­tance from an el­e­ment to it­self is 0, and that the dis­tance be­tween non-iden­ti­cal el­e­ments must be greater than 0. (2) as­serts that a met­ric must be com­mu­ta­tive; in­for­mally the dis­tance from \(a\) to \(b\) must be the same as the dis­tance from \(b\) to \(a\). Fi­nally, (3) is known as the tri­an­gle in­equal­ity and as­serts that the dis­tance from \(a\) to \(c\) is at most as large as the sum of the dis­tances from \(a\) to \(b\) and from \(b\) to \(c\). It is named as such be­cause in eu­clidean space, the points \(a\), \(b\), and \(c\) form a tri­an­gle, and the in­equal­ity re­quires that the length of one side of the tri­an­gle is not longer than the sum of the lengths of the other two sides; vi­o­lat­ing this would mean that the short­est path be­tween two points is no longer the straight line be­tween them.

It is pos­si­ble (and rel­a­tively com­mon!) to deal with mul­ti­ple differ­ent met­rics on the same set. This means we are us­ing the same set el­e­ments as la­bels, but treat­ing the dis­tances be­tween el­e­ments differ­ently; in this case the differ­ent met­ric spaces we are defin­ing may have very differ­ent prop­er­ties. If mul­ti­ple met­rics are be­ing con­sid­ered, we must be care­ful when speak­ing of dis­tances be­tween el­e­ments of the set to spec­ify which met­ric we are us­ing. For ex­am­ple, if \(d\) and \(e\) are both met­rics on \(S\), we can­not just say “the dis­tance be­tween \(a\) and \(b\) in \(S\)” be­cause it is am­bigu­ous whether we are refer­ring to \(d(a, b)\) or to \(e(a, b)\). We could in­stead say some­thing like “the dis­tance be­tween \(a\) and \(b\) un­der \(e\)” to re­move the am­bi­guity.

The most com­monly-used met­ric on Carte­sian space is the Eu­clidean met­ric, defined in two di­men­sions as \(d(a, b) = \sqrt{(a_1-b_1)^2 + (a_2-b_2)^2}\), and more gen­er­ally in \(n\) di­men­sions as \(d(a, b) = \sqrt{\sum_{i=1}^n (a_i-b_i)^2}\).

A less-com­mon met­ric on Carte­sian space is the Man­hat­tan met­ric, defined gen­er­ally as \(d(a, b) = \sum_{i=1}^n |a_i-b_i|\); the dis­tance is analo­gous to the dis­tance taken be­tween two points on a rec­t­an­gu­lar grid when mo­tion is con­strained to be purely ver­ti­cal or hori­zon­tal, but not di­ag­o­nal.

A met­ric in­duces a topol­ogy add in­tu­itive/​non­alge­braic ex­pla­na­tion lens proof that Eu­clidean and Man­hat­tan dis­tances are metrics


  • Mathematics

    Math­e­mat­ics is the study of num­bers and other ideal ob­jects that can be de­scribed by ax­ioms.