Absolute difference
Encyclopedia
The absolute difference of two real number
s x, y is given by |x − y|, the absolute value
of their difference
. It describes the distance on the real line between the points corresponding to x and y. It is a special case of the Lp distance
for all 1 ≤ p ≤ ∞ and is the standard metric
used for both the set of rational number
s Q and their completion, the set of real numbers R.
As with any metric, the metric properties hold:
By contrast, simple subtraction
is not non-negative or commutative, but it does obey the second and fourth properties above, since if and only if x = y, and
The absolute difference is used to define other quantities including the relative difference, the L1 norm used in taxicab geometry
, and graceful labeling
s in graph theory.
When it is desirable to avoid the absolute value function – for example because it is expensive to compute, or because its derivative is not continuous – it can sometimes be eliminated by the identity
This follows since |x − y|2 = (x − y)2 and squaring is monotonic
on the nonnegative reals.
Real number
In mathematics, a real number is a value that represents a quantity along a continuum, such as -5 , 4/3 , 8.6 , √2 and π...
s x, y is given by |x − y|, the absolute value
Absolute value
In mathematics, the absolute value |a| of a real number a is the numerical value of a without regard to its sign. So, for example, the absolute value of 3 is 3, and the absolute value of -3 is also 3...
of their difference
Subtraction
In arithmetic, subtraction is one of the four basic binary operations; it is the inverse of addition, meaning that if we start with any number and add any number and then subtract the same number we added, we return to the number we started with...
. It describes the distance on the real line between the points corresponding to x and y. It is a special case of the Lp distance
Lp space
In mathematics, the Lp spaces are function spaces defined using a natural generalization of the p-norm for finite-dimensional vector spaces...
for all 1 ≤ p ≤ ∞ and is the standard metric
Metric space
In mathematics, a metric space is a set where a notion of distance between elements of the set is defined.The metric space which most closely corresponds to our intuitive understanding of space is the 3-dimensional Euclidean space...
used for both the set of rational number
Rational number
In mathematics, a rational number is any number that can be expressed as the quotient or fraction a/b of two integers, with the denominator b not equal to zero. Since b may be equal to 1, every integer is a rational number...
s Q and their completion, the set of real numbers R.
As with any metric, the metric properties hold:
- |x − y| ≥ 0, since absolute value is always non-negative.
- |x − y| = 0 if and only if x = y.
- |x − y| = |y − x| (symmetry or commutativityCommutativityIn mathematics an operation is commutative if changing the order of the operands does not change the end result. It is a fundamental property of many binary operations, and many mathematical proofs depend on it...
). - |x − z| ≤ |x − y| + |y − z| (triangle inequalityTriangle inequalityIn mathematics, the triangle inequality states that for any triangle, the sum of the lengths of any two sides must be greater than or equal to the length of the remaining side ....
); in the case of the absolute difference, equality holds if and only if
By contrast, simple subtraction
Subtraction
In arithmetic, subtraction is one of the four basic binary operations; it is the inverse of addition, meaning that if we start with any number and add any number and then subtract the same number we added, we return to the number we started with...
is not non-negative or commutative, but it does obey the second and fourth properties above, since if and only if x = y, and
The absolute difference is used to define other quantities including the relative difference, the L1 norm used in taxicab geometry
Taxicab geometry
Taxicab geometry, considered by Hermann Minkowski in the 19th century, is a form of geometry in which the usual distance function or metric of Euclidean geometry is replaced by a new metric in which the distance between two points is the sum of the absolute differences of their coordinates...
, and graceful labeling
Graceful labeling
In graph theory, a graceful labeling of a graph with e edges is a labeling of its vertices with distinct integers between 0 and e inclusive, such that each edge is uniquely identified by the positive, or absolute difference between its endpoints. A graph which admits a graceful labeling is called a...
s in graph theory.
When it is desirable to avoid the absolute value function – for example because it is expensive to compute, or because its derivative is not continuous – it can sometimes be eliminated by the identity
- |x − y| < |z − w| if and only if (x − y)2 < (z − w)2.
This follows since |x − y|2 = (x − y)2 and squaring is monotonic
Monotonic function
In mathematics, a monotonic function is a function that preserves the given order. This concept first arose in calculus, and was later generalized to the more abstract setting of order theory....
on the nonnegative reals.