↑Go to Month

Chebyshev Distance Optimization

###
Description
This post explores the optimization of Chebyshev Distance with N points.
Publish Date
Calculating Date
Tags
[[cpp], [competitive programming], [optimization]]
###

To begin, Chebyshev Distance is defined as d(ax,ay,bx,by)=max(axay,bxby)d(a_x, a_y, b_x, b_y) = \max\left(| a_x - a_y |, | b_x - b_y | \right) in R2\mathbb{R}^2. This is the equivalent of the LL^\infty norm. The question is: given NN points in R2\mathbb{R}^2, how do we find the point(s) in R2\mathbb{R}^2 that minimize the maximum Chebyshev distance to these points?

Formalization

Given NN points (xi,yi)(x_i, y_i) for i=1,2,,Ni = 1, 2, \ldots, N, we want to minimize function ff defined as f(x,y)=maxi=1Nmax(xxi,yyi)f(x, y) = \max_{i=1}^N \max\left( |x - x_i|, |y - y_i| \right). Simple enough, the solution is to find the minimum axis-aligned bounding box that contains all the points, which is a rectangle with the left top corner as (xmin,ymin)(x_{min}, y_{min}) and the right bottom corner as (xmax,ymax)(x_{max}, y_{max}). The minimum Chebyshev distance is then

dmin=max(xmaxxmin2,ymaxymin2)d_{min} = \max\left( \frac{|x_{max} - x_{min}|}{2}, \frac{|y_{max} - y_{min}|}{2} \right)

achieved at the center of the bounding box.

Trivia

Chebyshev distance was introduced in an example involving chess.