# How to compare points in multi-dimensional space?

What does it mean for point $p_1$ in $n$ dimensions to be, for example, less than point $p_2$? Say, I have $p_1(4, 1, 7)$ and $p_2(3, 2, 6)$ in $3D$. Is $p_1$ less than $p_2$?

-
Depends. There are various inequivalent ways to do this. Do you have an application in mind? –  Qiaochu Yuan Jul 30 '11 at 20:17
Are you, say, comparing their distances from the origin? –  Guess who it is. Jul 30 '11 at 20:21
@Qiaochu Yuan I'm implementing a point class in Python and C++ for 3D computer graphics. I'm not sure if it makes sense to implement the comparison methods, though. –  Arlen Jul 30 '11 at 20:38
@J. M. Not exactly. In my example, I would be comparing p1 to p2. If there is a rule that says p1 is less than p2, then p1 < p2 would return True. –  Arlen Jul 30 '11 at 20:40
Then as André says, there is no natural ordering of points in two or three dimensions. You probably shouldn't bother defining <, >, and ilk for points; what would one use them for anyway in applications? –  Guess who it is. Jul 30 '11 at 20:44

You can obviously define any number of orderings on an $\mathbf R^n$, but I suspect you are interested in orders somehow induced by the standard order on $\mathbf R$. As another comment has suggested you may, for example, consider what is known as lexographic ordering, that is to say $(x_1, x_2, \dotsc, x_n) \lneq (y_1, y_2, \dotsc, y_n)$ if and only if $x_m \lneq y_m$ where $m$ is the first component for which the tuples are not equal.

Similarly there is a partial order given by saying $(x_1, x_2, \dotsc, x_n) \leq (y_1, y_2, \dotsc, y_n)$ if and only if $x_m \leq y_m$ for all $1 \leq m \leq n$.

Not to mention that the second order is not total, arguably none of these orders interact very satisfactorily with the "usual" structure on $\mathbf R^n$.

Since your question was given in a geometric language one might want to consider the partial order given by the standard metric on $\mathbf R^n$, either by saying that only only colinear points are comparable or saying that $x \leq y$ if and only if $|x| \leq |y|$ (in which points not on a common circle centred at 0 are comparable).

You cannot have a total order which coincides with the usual order of $\mathbf R$ on every component, since as in your example, just take $x = (1, 2, \dotsc)$ and $y = (2, 1, \dotsc)$, you would have $x \leq y$, since the order was assumed to coincide on the first component, and $y \leq x$, again by the assumption the ordering was to coincide with the one on $\mathbf R$, meaning one would have to have $x = y$.

-

There is no "natural" order on $\mathbb{R}^3$, or indeed on any $\mathbb{R}^d$ with $d\ge 2$. At least there is nothing nearly as natural as the usual order on $\mathbb{R}$.

But there are some orderings that are occasionally useful. For example, on $\mathbb{R}^2$, we can define an order as follows.

If $(x_1,y_1)$ and $(x_2,y_2)$ are in $\mathbb{R}^2$, put $(x_1,y_1)<(x_2,y_2)$ if either

(a) $x_1 \lt x_2\:$ or

(b) $x_1=x_2$ and $y_1 \lt y_2$.

This kind of "dictionary" ordering can be defined in $\mathbb{R}^3$, or indeed in $\mathbb{R}^d$ for any $d$.

The kind of ordering described above is certainly simple from a programming point of view, and could be a good way to order a database of points. So in what sense is it unnatural? Here is one way. Consider the two points $(2,0)$ and $(2.0004,0)$. These are informally quite close to each other. However, there are points like $(2.0002, 1000)$ which are between them according to our dictionary order, but are very far from them in the ordinary sense of far.

There are many other similar orders. We could put $(x_1,y_1)\lt (x_2,y_2)\;$ if

(a) $\sqrt{x_1^2+y_1^2} \lt \sqrt{x_2^2+y_2^2}\:$ or

(b) $\sqrt{x_1^2+y_1^2} = \sqrt{x_2^2+y_2^2}\;$ and $x_1<x_2\:$ or

(c) $\sqrt{x_1^2+y_1^2} = \sqrt{x_2^2+y_2^2}\;$ and $x_1=x_2\:$ and $y_1<y_2$.

There could be applications in which an ordering with this kind of flavour is useful.

-