
The absolute difference of two
real number
In mathematics, a real number is a number that can be used to measurement, measure a ''continuous'' one-dimensional quantity such as a distance, time, duration or temperature. Here, ''continuous'' means that values can have arbitrarily small var ...
s
and
is given by
, the
absolute value of their
difference. It describes the distance on the
real line
In elementary mathematics, a number line is a picture of a graduated straight line that serves as visual representation of the real numbers. Every point of a number line is assumed to correspond to a real number, and every real number to a po ...
between the points corresponding to
and
. It is a special case of the
Lp distance for all
and is the standard
metric used for both the set of
rational number
In mathematics, a rational number is a number that can be expressed as the quotient or fraction of two integers, a numerator and a non-zero denominator . For example, is a rational number, as is every integer (e.g. ). The set of all ra ...
s
and their completion, the set of real numbers
.
As with any metric, the metric properties hold:
*
, since
absolute value is always non-negative.
*
if and only if
.
*
(''
symmetry'' or ''
commutativity'').
*
(''
triangle inequality
In 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.
This statement permits the inclusion of degenerate triangles, bu ...
''); in the case of the absolute difference, equality holds if and only if
or
.
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
, and
.
The absolute difference is used to define other quantities including the
relative difference, the L
1 norm used in
taxicab geometry, and
graceful labelings in
graph theory
In mathematics, graph theory is the study of '' graphs'', which are mathematical structures used to model pairwise relations between objects. A graph in this context is made up of '' vertices'' (also called ''nodes'' or ''points'') which are conn ...
.
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
and squaring is
monotonic
In mathematics, a monotonic function (or monotone function) is a function between ordered sets that preserves or reverses the given order. This concept first arose in calculus, and was later generalized to the more abstract setting of ord ...
on the nonnegative reals.
See also
*
Absolute deviation
References
*
Real numbers
Distance
{{algebra-stub