A few heuristics

Author

Clayton Cafiero

Published

2026-05-25

A few common heuristics

The Euclidean heuristic

The Euclidean heuristic computes the straight-line distance between two points in Euclidean space, in any number of dimensions. In plane geometry (Euclidean space in two dimensions, the Euclidean distance between two points is straight line distance from some point a to another b, computed using the Pythagorean theorem.

For example, in \mathbb{R}^2, with points a = (x_a, y_a) and b = (x_b, y_b), the Euclidean distance is given by

d_E(a, b) = \sqrt{(x_a - x_b)^2 + (y_a - y_b)^2}\text{.}

This generalizes to higher dimensions.

The Manhattan or “taxicab” heuristic

The Manhattan distance between two points in \mathbb{R}^2 is the sum of the lengths traveled along each orthogonal axis, with respect to some grid, from some point a to another b.

For example, in \mathbb{R}^2, with points a = (x_a, y_a) and b = (x_b, y_b), the Manhattan distance is given by

d_M(a, b) = \lvert x_a - x_b \rvert + \lvert y_a - y_b \rvert\text{.}

The Chebyshev heuristic

The Chebyshev distance between two points in \mathbb{R}^2 is the greater of the lengths traveled along each orthogonal axis, from some point a to another b.

For example, in \mathbb{R}^2, with points a = (x_a, y_a) and b = (x_b, y_b), the Chebyshev distance is given by

d_C(a, b) = \max(\lvert x_a - x_b \rvert, \:\lvert y_a - y_b \rvert)\text{.}

The Hamming heuristic

The Hamming distance between two strings or vectors is given by the number of positions at which the two differ.

For example, the Hamming distance between the strings blue'' andclue’’ is one, because these strings differ in one position. The Hamming distance between the vectors [1, 0, 1, 1] and [1, 1, 1, 0] is two, because these vectors differ in two positions.

Copyright © 2023–2026 Clayton Cafiero

No generative AI was used in producing drafts of this material. This was written the old-fashioned way. AI was used to rewrite existing pseudocode in LaTeX to produce standalone *.tex files for rendering, and for revisions toward satisfying WCAG 2.1 AA-level accessibility standards as required by UVM policy. It may also have been used to proofread selected human-written prose. Claude 2.1.150 with model Sonnet 4.6. Revisions, if any, were performed by the author. AI was not used in generating any code whatsoever. All code samples and starter code are by the author only.