In mathematics a set is said to have a metric if there is a notion of distance on the set that fits our intuition about how distance should behave. More formally, an operation d(x,y) on a set A to the real numbers is said to be a metric if for all x,y and z, we have the following four properties.
- d(x, y) ≥ 0 (non-negativity)
- d(x, y) = 0 if and only if x = y (identity)
- d(x, y) = d(y, x) (symmetry)
- d(x, z) ≤ d(x, y) + d(y, z) (triangle inequality).
Intuitively, property 1 says that distance cannot be negative and two elements of the set are zero distance away from each other if and only if they are the same element. Property 2 says that the distance from x to y is the same as the distance from y to x. Property three says that the distance going from x to y to z is at least the distance to go from x to z. This third property is known as the "triangle inequality."