ForHosting KIT · Math

Chebyshev distance calculator

Measure the chessboard distance between two points, the larger of the horizontal and vertical gaps: from (0, 0) to (3, 4) it is 4, not the 5 a ruler would show. The signed and absolute gaps come with it. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
X1
0
Y1
0
X2
3
Y2
4
You get
Distance
4
Dx
3
Dy
4
Abs dx
3

Chebyshev distance, also known as chessboard distance or the L-infinity metric, measures how far two points are when movement is free in any of the eight compass directions at the same cost. On an infinite chessboard the distance equals the minimum number of king moves between two squares; in continuous coordinates it is simply the maximum of the absolute differences of the coordinates. This calculator accepts four finite numbers x1, y1, x2, and y2, validates every field, and returns the non-negative Chebyshev distance together with the signed deltas, their absolute values, a method tag of chebyshev, and the closed formula string.

How Chebyshev distance works on the plane

Label the first point as (x1, y1) and the second as (x2, y2). Form the coordinate differences dx equals x2 minus x1 and dy equals y2 minus y1, take absolute values, and keep the larger of the two: distance equals max of abs(dx) and abs(dy). That single maximum is the Chebyshev, chessboard, or L-infinity distance.

Unlike Euclidean length, which is the hypotenuse of the same two deltas, Chebyshev treats diagonal motion as costing the same as a pure horizontal or vertical step of equal extent, so a three-by-four separation yields distance four rather than five. Unlike Manhattan (L1) distance, which sums the absolute deltas and forbids free diagonal, Chebyshev never adds both axes when one dominates. Classic checks include (0, 0) to (3, 4) giving four, (1, 1) to (4, 5) giving four, and (2, 7) to (2, 7) giving zero.

Because the formula uses only subtraction, absolute value, and a maximum, it is deterministic, O(1), and free of square roots, trigonometric libraries, or iterative solvers. Integer coordinates recover the king-move count on a chessboard; real coordinates recover the continuous L-infinity metric used in approximation theory and uniform-norm geometry.

Where Chebyshev and chessboard distance show up in real work

Secondary-school discrete math and college metric-space courses often ask students to compute L-infinity distance alongside Euclidean and Manhattan distances so learners see how the unit ball changes from a diamond to a square; a trusted calculator with a strict numeric check speeds homework grading and removes spreadsheet mistakes where someone takes a hypotenuse by habit. Game, grid, and board-game engines store pieces, tiles, and agents on integer lattices; king-move range, vision circles under Chebyshev, and attack radii all reduce to max of absolute deltas without a full pathfinder.

Robotics and warehouse automation that allow diagonal travel at the same speed as axis-aligned travel use Chebyshev as a lower bound on travel time before detailed planning. Computer vision and image processing sometimes use L-infinity neighborhoods for morphological structuring elements and max-norm error checks between pixel coordinates. If you later need Euclidean straight-line length, Manhattan city-block distance, or great-circle distance on a globe, treat those as separate search intents rather than overloading this Chebyshev chessboard landing—each metric answers a different question and ranks for different keywords.

Homework and metric comparison

Compute chessboard L∞ distance between two plotted points and reject non-numeric coordinates with a clear error.

Grid pathfinding and game ranges

Turn two 2D lattice coordinates into a king-move Chebyshev length for vision, attack radius, and heuristic estimates.

What formula does this calculator use?

The Chebyshev (chessboard / L∞) formula: distance = max(|x2 − x1|, |y2 − y1|). The response includes method: "chebyshev" and the formula string.

How is this different from Euclidean distance?

Euclidean distance is √(dx² + dy²), the straight-line length. Chebyshev is the maximum absolute coordinate difference and matches king moves on a chessboard.

What happens if a coordinate is not a number?

Missing fields, empty strings, non-numeric text, NaN, and Infinity are all rejected and are not charged.

What does it cost?

The browser tool is free and runs locally.

How does Chebyshev distance relate to king moves in chess?

With whole-number coordinates it equals the fewest king moves between two squares, because a king covers a diagonal step in one move, just like a straight one. Real coordinates give the same measure on a continuous plane.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/geom/chebyshev-distance

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/geom/chebyshev-distance \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"x1":0,"y1":0,"x2":3,"y2":4}'
{
  "x1": 0,
  "y1": 0,
  "x2": 3,
  "y2": 4
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "geom.chebyshev_distance",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Students comparing metrics, game developers building grid pathfinding and vision ranges, robotics teams planning diagonal-capable motion, and test authors who need a deterministic geometry oracle all get the same pure result in the free browser tool and the paid API. Missing fields, empty strings, non-numeric text, NaN, and Infinity raise invalid_input instead of a silent NaN that looks like success.

How Chebyshev distance works on the plane

The result is always non-negative, zero exactly when the points coincide, and symmetric under swapping the endpoints. Large coordinates can still overflow IEEE-754 double range when differenced; when the intermediate result is non-finite the request fails with a clear overflow message instead of returning Infinity in JSON. That closed path matches how discrete mathematics courses, grid pathfinding primers, and metric-space notes present the chessboard distance problem, and it keeps automated graders and pipelines aligned with hand computation without unit conversion or map projections mixed into the same call.

What you send and what you get back

Provide four required finite numbers: x1 and y1 for the first point, x2 and y2 for the second. Wire the free browser tool for quick sanity checks, then call the identical contract from scripts when you need bulk evaluation of Chebyshev distances without reimplementing the numeric gate in every language. Short aliases ax, ay, bx, by and x_a through y_b are accepted so form labels can stay compact without diverging handlers. Missing fields, empty strings, non-numeric text, NaN, and Infinity are rejected with invalid_input and are not charged. After parsing, the service computes dx and dy, takes abs_dx and abs_dy, and sets distance to the maximum of those absolute deltas, then checks that the distance is a finite number. On success the JSON response returns distance rounded for stable serialization, echoes the four normalized coordinates, includes dx, dy, abs_dx, and abs_dy, sets method to the string chebyshev, and includes formula as d equals max of absolute coordinate differences so logs and teaching UIs can document the metric without reverse-engineering the code. Example checks: zero, zero, three, four yields distance four with abs_dx three and abs_dy four; one, one, four, five yields distance four; a non-numeric y2 fails naming that field. API pricing is the published base of $0.002 per successful item; validation failures do not consume prepaid balance.

Where Chebyshev and chessboard distance show up in real work

Because this capability is a pure parse engine, failed validation does not consume balance and successful runs stay at $0.002 per item.

Uniform-norm geometry fixtures

Generate deterministic max-norm distances for tests, docs, and synthetic benchmarks that echo deltas and method.

Does point order matter?

No. Distance is symmetric: swapping the two points yields the same non-negative length (dx and dy flip sign; abs_dx and abs_dy stay the same).

Read the full KIT documentation →