Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can anyone please tell me whether the following function $d:\mathbb{R}^2 \times \mathbb{R}^2 \to \mathbb{R}$ is really a metric or not on $\mathbb{R}^2$.

$$ d((x_1,x_2),(y_1,y_2))= \begin{cases} |x_1-y_1|, &\text{ if } x_2=y_2\\ |x_1|+|y_1|+|x_2-y_2|, &\text{ if } x_2 \neq y_2. \end{cases} $$

If it really is indeed a metric, please give the proof of triangle inequality.(I'm OK with the other two conditions).

share|cite|improve this question
Have you tried thinking about the metric geometrically? the distance between two points in the plane is the length of the shortest path that links them allowing only horizontal motion and vertical motion only along the $x=0$ line... For better readability you could rename your coordinates $(x,y)$ and $(x',y')$ which is much easier to read. – Olivier Bégassat Jul 21 '11 at 5:18
If you pick three random points for the triangle inequality, there are only $2^3=8$ possibilities to check. But it collapses to four, as each point can be on the line $x=y$ or not, so the important question is how many are on that line. – Ross Millikan Jul 21 '11 at 5:25
up vote 18 down vote accepted

It is. Your indexing is confusing me, so I'm going to rename the points $p = (x_1, y_1)$ and $q = (x_2, y_2)$. Then your metric is

$$d(p, q) = \begin{cases} |x_1 - x_2|, &\text{ if } y_1=y_2\\ |x_1|+|x_2|+|y_1-y_2|, &\text{ if } y_1 \neq y_2. \end{cases}.$$

This metric describes the length of the shortest path between $p$ and $q$ which cannot move vertically except on the $y$-axis. (Imagine that $\mathbb{R}^2$ has been separated into horizontal rows, and the only way to move vertically is to go to a central column given by the $y$-axis.)

That this is indeed a metric is a special case of the following general result, which is probably implicitly known to many people, but I have never seen it written down.

Proposition: Any function of the form "length of the shortest path between two points which satisfies condition $P$" on a metric space $M$ with an intrinsic metric is another metric provided that

  • the shortest path between two points satisfying condition $P$ exists,
  • the trivial path satisfies condition $P$,
  • the reverse of a path satisfying condition $P$ also satisfies condition $P$, and
  • the composition of two paths satisfying condition $P$ also satisfies condition $P$.

(In other words, the collection of all paths satisfying condition $P$ is a connected groupoid.)

Proof. The first condition implies that the function $d$ is well-defined. The second condition implies that $d(p, p) = 0$. The third condition implies that $d(p, q) = d(q, p)$. Since $M$ has an intrinsic metric, $d$ is automatically positive-definite, so it remains to prove the triangle inequality.

Let $p, q, r$ be three points. The composition of the shortest path from $p$ to $q$ satisfying $P$ and the shortest path from $q$ to $r$ satisfying $P$ is, by the fourth condition, a path from $p$ to $r$ satisfying $P$, hence has length at least the length of the shortest path from $p$ to $r$ satisfying $P$. Thus

$$d(p, r) \le d(p, q) + d(q, r)$$

as desired.

This optimization argument is in some sense a fundamental reason to consider the triangle inequality a reasonable axiom. In fact it is arguably the most important axiom; there are good reasons to drop any of the other axioms of a metric space (some of which correspond to dropping conditions above) to get various generalizations of metric spaces, which are described on the nLab among other places.

share|cite|improve this answer
Another answer I wish I could give +more to. He gets to the heart of the matter. – Ross Millikan Jul 21 '11 at 5:40
I'm sorry for my unusual indexing. But thanks a lot for the answer. – Sayantan Jul 21 '11 at 6:29
The way this is usually phrased in metric geometry: A length function is a function ℓ defined on a groupoid of paths based on X (think piecewise approximate geodesics) which assigns zero to the constant paths, is constant unter time-reversal and subadditive under concatenation (then you get a pseudo-metric). If in addition the length of a path connecting two points is bounded below by the distance between the points then you get an honest metric. If this metric is the same as the one you started with (using $\ell$ as the usual length), the metric is called intrinsic. (I didn't downvote BTW) – t.b. Jul 21 '11 at 8:28
The point of an intrinsic length metric is that you don't want to assume that shortest paths exist, only approximately shortest paths. If shortest paths existed, the whole construction would be a bit pointless. Think for example of $\mathbb{R}^2 \smallsetminus \mathbb{Z}^2$ with the usual Euclidean metric. This is an intrinsic length metric in the ordinary definition but shortest paths don't exist. Another example would be the graph with two vertices and countably many edges of length $1 + \frac{1}{n}$. In order to get shortest paths for free you need completeness and local compactness. – t.b. Jul 21 '11 at 12:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.