Distance Formula

Formula

\[d=\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}\]

Examples

Example 1. Distance from (1,2) to (4,6).

Solution. d=√(9+16)=5.

In Depth

The distance formula \(d=\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}\) is a direct application of the Pythagorean theorem in the coordinate plane. It extends to 3D: \(d=\sqrt{(x_2-x_1)^2+(y_2-y_1)^2+(z_2-z_1)^2}\), and to \(n\) dimensions: \(d=\sqrt{\sum_{i=1}^n(b_i-a_i)^2}\).

The midpoint formula \(M=((x_1+x_2)/2,(y_1+y_2)/2)\) gives the point equidistant from both endpoints. It generalizes to the centroid of \(n\) points: \(\bar{x}=\frac{1}{n}\sum x_i\), \(\bar{y}=\frac{1}{n}\sum y_i\).

Distance from a point \((x_0,y_0)\) to a line \(ax+by+c=0\): \(d=|ax_0+by_0+c|/\sqrt{a^2+b^2}\). This formula is derived by finding the foot of the perpendicular from the point to the line.

In metric spaces, the distance function (metric) must satisfy: non-negativity, identity of indiscernibles, symmetry, and the triangle inequality \(d(A,C)\leq d(A,B)+d(B,C)\). Different metrics on the same set give different geometries: the taxicab metric \(d=|x_2-x_1|+|y_2-y_1|\) models city-block distances.

Applications: nearest-neighbor algorithms in machine learning use distance to classify points. GPS systems compute distances on the Earth's surface using the haversine formula (spherical geometry). Computer graphics use distance functions (signed distance fields) for rendering and collision detection.

Key Properties & Applications

The distance formula generalizes to non-Euclidean settings. On a sphere of radius \(R\), the great-circle distance between points with latitudes/longitudes is given by the haversine formula, used in GPS and aviation. In special relativity, the spacetime interval \(ds^2=c^2dt^2-dx^2-dy^2-dz^2\) replaces Euclidean distance.

Signed distance functions (SDFs) assign to each point the signed distance to a surface (positive outside, negative inside). They are used in computer graphics for ray marching, collision detection, and smooth blending of shapes. The gradient of an SDF has unit magnitude everywhere (the Eikonal equation).

In machine learning, distance metrics define similarity. The choice of metric profoundly affects clustering and classification. The Mahalanobis distance \(d=\sqrt{(\mathbf{x}-\boldsymbol{\mu})^T\Sigma^{-1}(\mathbf{x}-\boldsymbol{\mu})}\) accounts for correlations between features and is scale-invariant.

Further Reading & Context

The study of distance formula connects to many areas of mathematics and its applications. Understanding the foundational definitions and theorems provides the basis for advanced work in analysis, algebra, and applied mathematics.

Historical development: most mathematical concepts evolved over centuries, with contributions from mathematicians across many cultures. The modern axiomatic treatment provides rigor, while computational tools enable practical application.

In modern mathematics, this topic appears in graduate courses and research across pure and applied mathematics. Connections to computer science, physics, and engineering make it a versatile and important area of study. Mastery of the core results and techniques opens doors to research in number theory, analysis, geometry, and beyond.

Recommended next steps: work through the standard theorems with full proofs, explore the connections to related topics listed above, and practice with a variety of problems ranging from computational exercises to theoretical proofs. The interplay between different areas of mathematics is one of the subject's greatest rewards.

Deep Dive: Distance Formula

This lesson extends core ideas for distance formula with rigorous reasoning, edge-case checks, and application framing in geometry.

Practice Set

Practice. Derive one main result on this page and validate with a numeric or geometric check.

Goal. Confirm assumptions, transformation steps, and final interpretation.

References & Editorial Notes

  • Stewart, Calculus.
  • Strang, Introduction to Linear Algebra.
  • Apostol, Mathematical Analysis.

Last editorial review: 2026-04-14.