Minkowski Distance Calculator
- The Minkowski distance generalises the familiar grid distances: d = (|x2 - x1|^p + |y2 - y1|^p)^(1/p), where the order p chooses the geometry - p = 1 gives the Manhattan distance, p = 2 the straight-line Euclidean distance, and as p grows it approaches the Chebyshev distance.
- The gaps are |dx| = 3.00 and |dy| = 4.00, and the order is p = 2.
- Minkowski distance = (3.00^2 + 4.00^2)^(1/2) = (9.00 + 16.00)^(1/2) = 5.00.
- Raising p puts more weight on the larger gap: the answer always sits between the Chebyshev distance (the larger gap alone) and the Manhattan distance (both gaps added).
This Minkowski distance calculator takes two points and an order p, then applies (|dx|^p + |dy|^p)^(1/p) to return the distance between them. The order p is what selects the geometry, so one tool covers a whole family of grid distances. At p = 2 you get the Euclidean distance: legs of 3 and 4 give exactly 5.00. At p = 1 you get the Manhattan distance, and the same legs give 7.00. At p = 3, legs of 2 and 3 give 3.27 — already closing on the Chebyshev limit of 3. As p grows without bound, the Minkowski distance approaches the Chebyshev distance, which is the larger gap alone.
The method is the accepted standard because the formula itself defines the Minkowski family: the order p chooses the geometry, and the familiar distances fall out as special cases rather than as separate rules. That is why p = 1 reproduces the Manhattan result and p = 2 the Euclidean result, with the Chebyshev distance emerging as the limit for large p. This page shows the formula, step-by-step workings, worked examples and sources, so you can check every number the calculator returns instead of taking it on trust.
Worked examples
Euclidean (p = 2)
At p = 2 the classic 3-4-5 triangle gives the Euclidean distance 5.00. (0 · 0 · 3 · 4 · 2)
| Minkowski distance | 5.00 |
| Horizontal gap | 3.00 |
| Vertical gap | 4.00 |
| Order p | 2 |
Manhattan (p = 1)
At p = 1 the same legs add up Manhattan-style to 7.00. (1 · 1 · 4 · 5 · 1)
| Minkowski distance | 7.00 |
| Horizontal gap | 3.00 |
| Vertical gap | 4.00 |
| Order p | 1 |
Between worlds (p = 3)
At p = 3 the distance tightens to 3.27, moving toward the Chebyshev limit. (0 · 0 · 2 · 3 · 3)
| Minkowski distance | 3.27 |
| Horizontal gap | 2.00 |
| Vertical gap | 3.00 |
| Order p | 3 |
One family of distances
The Minkowski distance is best understood as a single formula with a dial on it. For two points whose gaps along the axes are dx and dy, the distance is (|dx|^p + |dy|^p)^(1/p), where the order p chooses the geometry. Turn the dial to a different value and you get a different way of measuring the same two points. That is why a Minkowski distance calculator can cover several familiar distances without needing a separate rule for each one.
At p = 1 the formula becomes the Manhattan distance, the distance you would walk along a grid of city blocks. Take legs of 3 and 4: the result is 7.00, because the two gaps are simply added together. At p = 2 it becomes the Euclidean distance, the straight-line distance. The same legs of 3 and 4 give exactly 5.00, the classic right-triangle result. Two very different answers, 7.00 and 5.00, come from the same pair of points and the same formula, with only the value of p changed.
Values of p between 1 and 2, or above 2, produce intermediate geometries. At p = 3, legs of 2 and 3 give 3.27. Notice how close that is to the Chebyshev limit of 3, which is just the larger of the two gaps. Raising p rewards the bigger gap and shrinks the influence of the smaller one, so the answer climbs toward the larger leg rather than the sum.
That climb continues as p grows without bound. As p increases, the Minkowski distance approaches the Chebyshev distance, which is the larger gap alone. In the limit, only the longest axis gap matters; the shorter one drops out entirely. This is the king's move on a chessboard, where a diagonal step and a straight step both count as one, and the distance between squares is set by whichever direction is farther.
So the dial runs from city blocks at p = 1, through straight lines at p = 2, and on toward the king's move as p goes to infinity. The examples above trace the same trend: legs of 3 and 4 give 7.00 at p = 1 and 5.00 at p = 2, while legs of 2 and 3 give 3.27 at p = 3, already closing on the Chebyshev limit of 3. A Minkowski distance calculator lets you set p and see which geometry your data is actually being measured in.
- p = 1: Manhattan distance, city blocks — legs of 3 and 4 give 7.00.
- p = 2: Euclidean distance, straight lines — legs of 3 and 4 give exactly 5.00.
- p = 3: an intermediate case — legs of 2 and 3 give 3.27, already closing on the Chebyshev limit of 3.
- p → infinity: Chebyshev distance, the king's move — the larger gap alone.
How to calculate Minkowski distance
To calculate Minkowski distance, you raise each absolute gap between the coordinates to the power p, add those results together, and then take the p-th root of the total. The formula is (|dx|^p + |dy|^p)^(1/p), where the order p chooses the geometry. A Minkowski distance calculator simply runs this same two-step routine for whichever p you select, which is why the order matters more than the arithmetic: the same pair of points can sit at different distances depending on what p you pick.
Walk through p = 2 first, the most familiar case. Take two points with legs of 3 and 4, meaning the gaps along each axis are 3 and 4. Raise each to the power 2: 3 squared is 9 and 4 squared is 16. Add them to get 25, then take the square root, since 1/p is 1/2. The result is exactly 5.00 — the Euclidean distance. This is the straight-line distance most people picture when they hear the word distance.
Now keep the same points and switch to p = 1. Each absolute gap is raised to the first power, which leaves it unchanged, so you add 3 and 4 to get 7. Taking the first root of 7 leaves it as 7.00. That is the Manhattan distance, the path length you would travel moving only along grid lines. Same points, same gaps, different order, different answer — the geometry changed because p changed.
For p = 3, use legs of 2 and 3. Cube each gap: 2 cubed is 8 and 3 cubed is 27. Add them to get 35, then take the cube root, since 1/p is 1/3. The result is 3.27. Notice how close that is to 3, the larger of the two gaps. That is not a coincidence. As p grows without bound, the Minkowski distance approaches the Chebyshev distance, which is simply the larger gap alone. At p = 3 you are already closing on that limit of 3.
The pattern across these examples is the whole idea behind the measure. Small orders let both gaps contribute generously, while large orders let the bigger gap dominate. When you use a Minkowski distance calculator, check the p value before trusting the output, because p = 1, p = 2 and p = 3 all describe the same kind of calculation but answer a slightly different question about how far apart the points are.
- p = 2: gaps 3 and 4 → 9 + 16 = 25 → √25 = 5.00 (Euclidean)
- p = 1: gaps 3 and 4 → 3 + 4 = 7 → 7.00 (Manhattan)
- p = 3: gaps 2 and 3 → 8 + 27 = 35 → cube root = 3.27, nearing the Chebyshev limit of 3
Choosing p
The order p is the single setting that decides which geometry a Minkowski distance measures, so it is the first thing to settle before you type any coordinates into a minkowski distance calculator. The general form is (|dx|^p + |dy|^p)^(1/p), where the gaps between points are raised to the power p, added, and then pulled back by the p-th root. Change p and you change the shape of the space around your points. Practitioners therefore treat p as a modeling choice, not a formatting detail, and they tend to pick from a small set of familiar values.
At p = 2 you get the Euclidean distance, the straight-line gap most people picture by default. Legs of 3 and 4 give exactly 5.00. This is the standard choice for continuous features, because it treats every unit of difference on the same footing and matches the squared-error thinking behind much of machine learning. If your features are measured on comparable continuous scales and you have no strong reason to do otherwise, p = 2 is the default practitioners reach for.
At p = 1 you get the Manhattan distance, the sum of the absolute gaps along each axis. The same legs of 3 and 4 give 7.00. Because each difference enters at full strength rather than being squared, large single deviations are not amplified the way they are under p = 2, which is why p = 1 is described as robust to outliers. When a few extreme values would otherwise dominate the comparison, switching to p = 1 keeps the distance anchored to the typical differences.
Between and beyond these anchors the behavior is smooth. At p = 3, legs of 2 and 3 give 3.27, already closing on the Chebyshev limit of 3. That limit is the endpoint of the whole family: as p grows without bound the Minkowski distance approaches the Chebyshev distance, the larger gap alone. In practice, raising p above 2 shifts attention steadily onto whichever single dimension differs most, which suits problems where one dominant mismatch should decide the outcome. Fractional p below 1 sits outside this well-behaved picture. Values in that range are not a true metric, so the triangle inequality can fail and distance-based reasoning loses the guarantees it normally relies on. Practitioners generally avoid fractional p below 1 for that reason.
- p = 1: Manhattan distance, robust to outliers; legs of 3 and 4 give 7.00.
- p = 2: Euclidean distance, the default for continuous features; legs of 3 and 4 give exactly 5.00.
- p = 3: legs of 2 and 3 give 3.27, already closing on the Chebyshev limit of 3.
- p → ∞: the distance approaches the Chebyshev distance, the larger gap alone.
- Fractional p below 1: not a true metric, so avoid it for distance-based work.
Minkowski in higher dimensions
A Minkowski distance calculator is not limited to two coordinates. The formula you saw for a pair of points extends directly to any number of dimensions: for each coordinate, take the absolute difference between the two points, raise it to the power p, add all those terms together, and take the p-th root of the total. In two dimensions the sum has two terms, in three it has three, and in ten it has ten. Nothing about the structure changes — only the length of the list you feed in. The order p still chooses the geometry, so the same data measured at p = 1, p = 2, or p = 3 will give different answers, and each answer is the correct distance for that choice of p.
The triangle inequality is the reason the calculator requires p of at least 1. This rule states that the distance from one point to a third can never exceed the distance from the first to the second plus the distance from the second to the third — going by way of a middle point is never a shortcut. For Minkowski distance the triangle inequality holds whenever p is 1 or greater. Below that threshold the rule can break, and a quantity that breaks it does not behave like a distance at all. Restricting p to 1 or more keeps every result a genuine distance in every dimension, not just in the two-dimensional examples.
The familiar cases carry over unchanged as you add coordinates. At p = 2 the formula is the Euclidean distance; with legs of 3 and 4 it gives exactly 5.00. At p = 1 it is the Manhattan distance, and the same legs give 7.00. Increasing p pulls the result toward the Chebyshev distance, the larger gap alone. At p = 3, legs of 2 and 3 give 3.27 — already closing on the Chebyshev limit of 3. In higher dimensions the same progression appears: each coordinate contributes its own gap, and raising p shifts the balance toward whichever coordinate has the largest gap.
That shift is worth watching when you work in many dimensions. A single large coordinate difference dominates the sum more and more as p rises, while many small differences matter most at p = 1. Because the sum runs over every coordinate, adding dimensions adds terms rather than changing the rule, so you can compare the same pair of points at several values of p and see the geometry move from grid-like to straight-line to largest-gap. Enter all coordinates for both points, choose p as 1 or more, and the result follows the same formula regardless of how long the coordinate list is.
FAQs
What is Minkowski distance?
Minkowski distance is a family of distances parameterised by the order p: (|dx|^p + |dy|^p)^(1/p). By changing p you get different distances from the same formula. Manhattan distance is the special case at p = 1, and Euclidean distance is the special case at p = 2.
How do you calculate Minkowski distance?
Raise the absolute coordinate gaps to the power p, add them, and take the p-th root. For example, legs of 3 and 4 at p = 2 give 5.00. The same three steps apply to any p value of 1 or greater, so the calculation stays consistent across the family.
What p gives the Euclidean distance?
p = 2 gives the Euclidean distance. p = 1 gives Manhattan distance, and p approaching infinity gives Chebyshev distance. So a single p setting selects which member of the family you are using, and the familiar straight-line distance is simply the p = 2 case.
Why must p be at least 1?
Below 1 the formula breaks the triangle inequality, so it no longer behaves as a distance. The triangle inequality is a basic requirement for a measure to count as a distance, so p values under 1 fall outside the valid range. Use p of 1 or greater.
Where is Minkowski distance used?
Minkowski distance is used in machine learning, including k-nearest neighbours, in clustering, and anywhere a tunable distance between feature vectors is needed. Because p can be adjusted, the same formula can be tuned to suit different data and comparison needs.
Is Minkowski distance the same as Minkowski spacetime?
No. This is the Lp distance between points in ordinary space, not the spacetime interval of relativity, despite the shared name. The two concepts are distinct: one measures separation between points in ordinary space, while the other belongs to relativity.