Shapes & spaces

Closest pair of points calculator from coordinates

Find the minimum Euclidean distance among unordered planar points and list original-row pairs at that computed minimum.

Your numbers

One x,y pair per row, in a common Cartesian length unit. Coordinates are finite and within ±10⁹. Use 2–200 rows; duplicate coordinates remain distinct observations.

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

The closest-pair problem compares all distinct input-row pairs and finds the smallest Euclidean separation. The points are a cloud, not an ordered polygon boundary. This page preserves original row identities, calculates every unordered pair within the bounded input size and returns all pairs whose computed floating distance equals the minimum. Duplicate coordinates are valid: two distinct observations at the same position have distance zero.

THE FORMULAd_min=min_(i<j) √[(x_i−x_j)²+(y_i−y_j)²].

A worked example

The four square corners (0,0), (1,0), (1,1), (0,1) have minimum distance one. Four pairs attain it: the adjacent corners. The two diagonals have distance √2 and are excluded. If the first coordinate is entered again as a fifth observation, the original and repeated rows form a zero-distance pair even though their coordinate values are equal.

Good to know

Supports 2–200 points with finite coordinates within ±10⁹. Pair ties use equality of computed floating distances, not an exact symbolic comparison of arbitrary real lengths. Very close distinct distances can be limited by numerical precision. At most 500 pair rows are displayed while the full tied-pair count is reported. This bounded implementation enumerates pairs rather than claiming a large-data divide-and-conquer complexity.

Input identity and coordinate equality answer different questions

A duplicate coordinate can be an intentional repeated observation, a merged location or a data-entry error. The calculator cannot choose which interpretation applies, so it retains both rows and shows their indices. Deleting duplicates automatically would change the closest-pair problem and could conceal a meaningful zero-distance finding. Review the returned row numbers against the original dataset before drawing conclusions.

For n observations there are n(n−1)/2 unordered pairs. Reversing a pair does not create a second pair, and a row is never compared with itself. The square example consequently has six comparisons, of which four reach the minimum. The table is a list of observation pairs, not a connected route or a polygon edge sequence, even when the points happen to be boundary vertices.

Four unit-square edges tie for the closest-pair distance1234Minimum = 1Four tied pairs
For the four unit-square corners, four unordered pairs have distance one. The two diagonals have distance √2 and are excluded. Vertex numbers identify original rows rather than a required traversal order.

The Voronoi diagram calculator from points with Delaunay dual partitions the plane by nearest sites. This page instead compares the distances between the entered observations themselves.

A small separation needs the coordinate system and its units

The distance formula assumes Cartesian coordinates with the same scale on both axes. Latitude and longitude degrees are not a uniform planar length system; applying this formula directly can give misleading physical separations. Project geographic coordinates appropriately or use a geodesic-distance workflow. Multiplying both coordinate axes by the same unit-conversion factor changes the reported minimum by that factor but preserves the closest-pair identities.

Exact equality of numerical lengths is deliberately distinct from an application-defined near-tie threshold. If two separations differ by less than measurement resolution, that scientific tolerance belongs in the interpretation rather than being silently introduced by the calculator. The output limit prevents an all-duplicate sample from creating an unwieldy table. Its full count still records how many pairs attained the computed minimum, even when only the first five hundred rows are shown.

A few questions, answered

Do I need to sort points first?

No. Input order only supplies the row labels. The calculation compares every unordered pair and does not assume a boundary or trajectory.

What does a zero result mean?

At least two distinct input rows have the same computed coordinate position. It does not identify whether that duplication is intentional or erroneous.

Find your calculator

Start typing to explore the library.