Skip to content

Resource · Guide or article

Euclidean Distance

Short reference for Euclidean distance between points, derived from the Pythagorean theorem and extended from one dimension up to n dimensions. Handy for geometry and nearest-points questions.

Reviewed

Open the original: Euclidean Distance (opens the original site in a new tab)

Add to a roadmap

Keep this resource with a roadmap you follow. It appears as your own extra resource; the roadmap's steps don't change and it doesn't count toward your tracked steps.

Source content: English

In mathematics, the Euclidean distance between two points in Euclidean space is the length of a line segment between the two points. It can be calculated from the Cartesian coordinates of the points using the Pythagorean theorem, therefore occasionally being called the Pythagorean distance. The distance between any two points on the real line is the absolute value of the numerical difference of their coordinates In three dimensions, for points given by their Cartesian coordinates, the distance is

PrepKit overview

PrepKit editors wrote and reviewed this overview from the source repository. It is not text from the resource itself.

Suited to
The source does not state a level
Format
Reference

What it covers

  • Formulas for one, two and three dimensions and the general n-dimensional case
  • A worked three-dimensional example for the points (8,2,6) and (3,5,7)

How to use it

PrepKit study advice, not a claim made by the source.

Write one function for points of any dimension, check it on (8,2,6) and (3,5,7), then find the k closest points using squared distance.

Scope and limitations

Every formula and the 3D example are images from Wikipedia and MathIsFun, so the text alone gives little. No discussion of other metrics or of numeric precision.

Access and format

Free English README on GitHub in the MIT-licensed trekhleb/javascript-algorithms repository.

Reviewed by PrepKit on Oct 2, 2026. Listing source commit: 85293e3e2b88

Evidence behind this overview
  • src/algorithms/math/euclidean-distance/README.md

Pages that include this

Get the PrepKit newsletter

Optional. You don't need it to use PrepKit.

How we handle your email