thumb|275px|A board showing distances near [[Visakhapatnam, India]]
Distance is a numerical or occasionally qualitative measurement of how far apart objects, points, people, or ideas are. In physics or everyday usage, distance may refer to a physical length or an estimation based on other criteria (e.g. "two counties over"). The term is also frequently used metaphorically to mean a measurement of the amount of difference between two similar objects (such as statistical distance between probability distributions or edit distance between strings of text) or a degree of separation (as exemplified by distance between people in a social network). Most such notions of distance, both physical and metaphorical, are formalized in mathematics using the notion of a metric space.
In the social sciences, distance can refer to a qualitative measurement of separation, such as social distance or psychological distance.
Distances in physics and geometry<!--This article violates WP:NOBACKREF all over the place, but I think it sounds better that way, and in some places genuinely requires it. Please think twice before changing it-->
The distance between physical locations can be defined in different ways in different contexts.
Straight-line or Euclidean distance
The distance between two points in physical space is the length of a straight line between them, which is the shortest possible path. This is the usual meaning of distance in classical physics, including Newtonian mechanics.
Straight-line distance is formalized mathematically as the Euclidean distance in two- and three-dimensional space. In Euclidean geometry, the distance between two points and is often denoted <math>|AB|</math>. In coordinate geometry, Euclidean distance is computed using the Pythagorean theorem. The distance between points and in the plane is given by:
<math display="block">d=\sqrt{(\Delta x)^2+(\Delta y)^2}=\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}.</math>
Similarly, given points (x<sub>1</sub>, y<sub>1</sub>, z<sub>1</sub>) and (x<sub>2</sub>, y<sub>2</sub>, z<sub>2</sub>) in three-dimensional space, the distance between them is: For example, psychological distance is "the different ways in which an object might be removed from" the self along dimensions such as "time, space, social distance, and hypotheticality". In sociology, social distance describes the separation between individuals or social groups in society along dimensions such as social class, race/ethnicity, gender or sexuality.
Mathematical formalization
thumb|Animation visualizing the function <math>(|x|^r + |y|^r)^{1/r}</math> for various values of r.
Most of the notions of distance between two points or objects described above are examples of the mathematical idea of a metric. A metric or distance function is a function which takes pairs of points or objects to real numbers and satisfies the following rules:
- The distance between an object and itself is always zero.
- The distance between distinct objects is always positive.
- Distance is symmetric: the distance from to is always the same as the distance from to .
- Distance satisfies the triangle inequality: if , , and are three objects, then <math display="block">d(x,z) \leq d(x,y)+d(y,z).</math> This condition can be described informally as "intermediate stops can't speed you up."
As an exception, many of the divergences used in statistics are not metrics.
Distance between sets
thumb|The distances between these three sets do not satisfy the triangle inequality:<math display="block">d(A,B)>d(A,C)+d(C,B)</math>
There are multiple ways of measuring the physical distance between objects that consist of more than one point:
- One may measure the distance between representative points such as the center of mass; this is used for astronomical distances such as the Earth–Moon distance.
- One may measure the distance between the closest points of the two objects; in this sense, the altitude of an airplane or spacecraft is its distance from the Earth. The same sense of distance is used in Euclidean geometry to define distance from a point to a line, distance from a point to a plane, or, more generally, perpendicular distance between affine subspaces.
: Even more generally, this idea can be used to define the distance between two subsets of a metric space. The distance between sets and is the infimum of the distances between any two of their respective points:<math display="block">d(A,B)=\inf_{x\in A, y\in B} d(x,y).</math> This does not define a metric on the set of such subsets: the distance between overlapping sets is zero, and this distance does not satisfy the triangle inequality for any metric space with two or more points (consider the triple of sets consisting of two distinct singletons and their union).
- The Hausdorff distance between two subsets of a metric space can be thought of as measuring how far they are from perfectly overlapping. Somewhat more precisely, the Hausdorff distance between and is either the distance from to the farthest point of , or the distance from to the farthest point of , whichever is larger. (Here "farthest point" must be interpreted as a supremum.) The Hausdorff distance defines a metric on the set of compact subsets of a metric space.
Related ideas
The word distance is also used for related concepts that are not encompassed by the description "a numerical measurement of how far apart points or objects are".
Distance travelled
The distance travelled by an object is the length of a specific path travelled between two points, such as the distance walked while navigating a maze or the distance marked by a milepost or an odometer. This can even be a closed distance along a closed curve which starts and ends at the same point, such as a ball thrown straight up, or the Earth when it completes one orbit. This is formalized mathematically as the arc length of the curve.
The distance travelled may also be signed: a "forward" distance is positive and a "backward" distance is negative.
Circular distance is the distance traveled by a point on the circumference of a wheel, which can be useful to consider when designing vehicles or mechanical gears (see also odometry). The circumference of the wheel is ; if the radius is 1, each revolution of the wheel causes a vehicle to travel radians.
Displacement and directed distance
thumb|Distance along a path compared with displacement. The Euclidean distance is the length of the displacement vector.
The displacement in classical physics measures the change in position of an object during an interval of time. While distance is a scalar quantity, or a magnitude, displacement is a vector quantity with both magnitude and direction. In general, the vector measuring the difference between two locations (the relative position) is sometimes called the directed distance. For example, the directed distance from the New York City Main Library flag pole to the Statue of Liberty flag pole has:
- A starting point: library flag pole
- An ending point: statue flag pole
- A direction: -38°
- A distance: 8.72 km
Signed distance
See also
- Absolute difference
- Astronomical system of units
- Color difference
- Closeness (mathematics)
- Distance geometry problem
- Dijkstra's algorithm
- Distance matrix
- Distance set
- Engineering tolerance
- Multiplicative distance
- Optical path length
- Orders of magnitude (length)
- Proper length
- Proxemics – physical distance between people
- Signed distance function
- Similarity measure
- Social distancing
- Vertical distance
Library support
- Python (programming language)
- SciPy -Distance computations (<code>scipy.spatial.distance</code>)
- Julia (programming language)
- Julia Statistics Distance -A Julia package for evaluating distances (metrics) between vectors.
