Skip to main content

PLP: An introduction to mathematical proof

Section 5.4 Absolute values and the triangle inequality

The triangle inequality is a very simple inequality that turns out to be extremely useful. It relates the absolute value of the sum of numbers to the absolute values of those numbers. So before we state it, we should formalise the absolute value function.

Definition 5.4.1.

Let \(x \in \mathbb{R}\text{,}\) then the absolute value of \(x\) is denoted \(|x|\) and is given by
\begin{equation*} |x| = \begin{cases} x \amp \text{if } x \geq 0 \\ -x \amp \text{if } x \lt 0\end{cases} \end{equation*}
How we compute 40  the absolute value of a number depends on whether that number is negative or not — it is an example of a piecewise function.
\begin{align*} |8| \amp = 8 \\ |-5| \amp = -(-5) = 5 \end{align*}
Since the absolute value is defined in two branches like this, it naturally leads to proofs that require cases. The proof of the triangle inequality is a good example of this. Before we state (and prove) the triangle inequality, let’s prove a few useful lemmas that describe some useful properties of the absolute value.
We will split the proof into two cases. The first dealing with \(x \geq 0\) and the second with \(x \lt 0\text{.}\) Doing this allows us to rewrite the absolute value \(|x|\) as either \(x\) or \(-x\text{,}\) and so simplify our analysis.
Let \(x \in \mathbb{R}\) so that either \(x \geq 0\) or \(x \lt 0\text{.}\)
  • When \(x \geq 0\text{,}\) we know that \(|x|=x\text{,}\) and so \(|x| \geq 0\text{.}\)
  • Now assume that \(x \lt 0\text{.}\) Then \(|x| = -x\text{.}\) Now since \(x\) is negative, it follows that \(-x\) is positive, and so \(|x|= -x \gt 0\text{.}\)
In both cases we have shown that \(|x| \geq 0\text{.}\)
To prove the next result it is actually convenient to use a more symmetric definition of the absolute value function that splits into three cases:
\begin{equation*} |x| = \begin{cases} x \amp \text{if } x \gt0 \\ 0 \amp \text{if }x=0 \\ -x \amp \text{if } x \lt 0\end{cases} \end{equation*}
We do this to take advantage of the fact 41  that \(-0=0\text{.}\)
Let \(x \in \mathbb{R}\text{,}\) then either \(x=0, x\gt 0, x\lt 0\text{.}\)
  • When \(x=0\text{,}\) then \(-x=x=0\) and \(|x|=|-x|=0\text{.}\)
  • Now, let \(x \gt 0\text{.}\) This means that \(|x|=x\text{.}\) Further \(-x \lt 0\) and so \(|-x|= -(-x) = x = |x|\text{.}\)
  • Finally, let \(x \lt 0\text{,}\) so that \(|x|=-x\text{.}\) Additionally, \(-x \gt 0\) and so \(|-x| = (-x)= |x|\text{.}\)
In all three cases the result holds.
We can reuse the basic ideas of this proof to obtain the following
Let \(x \in \mathbb{R}\) so that either \(x \geq 0\) or \(x \lt 0\text{.}\)
  • When \(x \geq 0\text{,}\) we know that \(|x|=x\text{.}\) Now since \(x \geq 0\text{,}\) it follows that \(-|x| \leq 0 \leq x = |x|\text{.}\)
  • Now assume that \(x \lt 0\text{.}\) Then \(|x| = -x\text{,}\) so that \(-|x| = x\text{.}\) Now since \(x \lt 0\) it follows that \(-|x| = x \lt 0 \leq |x|\text{.}\)
In both cases we have shown that \(-|x| \leq x \leq |x|\) as required.
We can extend the above lemma a little to get a very useful result. It tells us how to transform bounds on quantity into bounds on its absolute value and vice-versa.
We prove each implication in turn.
  • Assume that \(|x| \leq y\text{.}\) Now either \(x \geq 0\) or \(x \lt 0\text{.}\)
    • When \(x \geq 0\text{,}\) we know that \(|x|=x\text{.}\) Hence \(y \geq |x|=x \geq 0 \geq -y\text{.}\)
    • On the other hand if \(x \lt 0\text{,}\) we know that \(y \geq |x|=-x \gt 0\text{.}\) So, multiplying through by \(-1\) we have \(-y \leq x \lt 0 \leq y\text{.}\)
    In both cases we have shown that \(-y \leq x \leq y\) as required.
  • Now assume that \(-y \leq x \leq y\text{.}\) Again, either \(x \geq 0\) or \(x \lt 0\text{.}\)
    • When \(x \geq 0\text{,}\) we know that \(x = |x|\text{.}\) So, by assumption \(y \geq x = |x|\text{.}\)
    • Now, when \(x \leq 0\text{,}\) \(|x|=-x\text{.}\) Transform our assumption \(y \geq x \geq -y\text{,}\) by multiplying everything by \(-1\text{,}\) giving \(-y \leq -x = |x| \leq y\text{.}\)
    In both cases we have shown that \(|x| \leq y\) as required.
Okay, now we can prove our main result; it tells us that the absolute value of the sum of two numbers is smaller 42  than the sum of the absolute values. It is a very simple but turns out to be extremely useful 43 .
The inequality gets its name from a more geometric interpretation 44 . It tells us that the length of the third side of the triangle, \(C\text{,}\) is bounded by the sum of the lengths of the other two sides, \(A,B\text{.}\)
Now, rather than leap into a neat proof of this, we should take some time to explore the problem and the various cases that might arise. Since the values of \(|x|, |y|\) and \(|x+y|\) all depend on whether each quantity is positive or negative 45 .
  • Notice that if both \(x,y \geq 0\text{,}\) then it is easy to prove since
    \begin{equation*} |x| + |y| = x+y \end{equation*}
  • Similarly, if both \(x,y \lt 0\text{,}\) then we know that \(x+y\lt 0\) and so we have
    \begin{equation*} |x| + |y| = (-x) + (-y) = -(x+y) = |x+y| \end{equation*}
  • A little more care is required when (say) \(x \geq 0\) but \(y \lt 0\text{.}\) In this case we have
    \begin{equation*} |x| + |y| = x + (-y) = x-y \end{equation*}
    and it is not immediately obvious how to relate this to \((x+y)\text{.}\) One way to proceed is to break this case into subcases depending on whether \((x+y) \geq 0\) or \((x+y) \lt 0\text{.}\) Urgh.
Let us instead take a step back and start again, but this time from assumptions about \((a+b)\text{.}\) Either \(a+b \geq 0\) or \(a+b \lt 0\text{.}\)
  • In the first case
    \begin{equation*} |a+b| = a+b \end{equation*}
    and we know, from our lemma above, that \(a \leq |a|\) and \(b \leq |b|\text{,}\) so
    \begin{equation*} |a+b| = a+b \leq |a| + |b|. \end{equation*}
  • Now, the second case gives
    \begin{equation*} |a+b| = -(a+b) = -a - b \end{equation*}
    Our lemma above tells us that \(-a \leq |a|\) (and similarly that \(-b \leq |b|\)), so
    \begin{equation*} |a+b| = (-a) + (-b) \leq |a| + |b| \end{equation*}
Oof! Now we can write it up.
Let \(a,b \in \mathbb{R}\text{.}\) Either \((a+b) \geq 0\) or \((a+b)\lt 0\text{.}\)
  • When \((a+b) \geq 0\text{,}\) we know that \(|a+b|= a+b\text{.}\) By Lemma 5.4.4, we know that \(a \leq |a|\) and \(b \leq |b|\text{.}\) Thus \(|a+b| = a+b \leq |a|+|b|\text{.}\)
  • When \((a+b) \lt 0\text{,}\) we have \(|a+b| = -a-b = (-a)+(-b)\text{.}\) Again, by Lemma 5.4.4 \(-a \leq |-a| = |a|\) and \(-b \leq |-b| \leq |b|\text{,}\) and so \(|a+b| = -(a+b)=(-a)+(-b) \leq |a|+|b| \text{.}\)
In both cases we have that \(|a+b| \leq |a|+|b|\) as required.
This is not the only way to prove this result. We can be a little more sneaky via the inequality in Lemma 5.4.5.
Let \(x,y \in \mathbb{R}\text{.}\) Then from Lemma 5.4.4we know that \(x \leq |x|\text{,}\) and that \(-x \leq |-x|=|x|\text{,}\) and hence \(x \geq -|x|\text{.}\) Putting those together we have
\begin{equation*} -|x| \leq x \leq |x| \end{equation*}
Similarly, we know that \(-|y| \leq y \leq |y|\text{.}\) Adding these inequalities together gives
\begin{equation*} -|x|-|y| \leq (x+y) \leq |x|+|y| \end{equation*}
and so, by Lemma 5.4.5 above
\begin{equation*} |x+y| \leq |x| + |y| \end{equation*}
as required.
A useful corollary of the triangle inequality is a bound on the absolute value of the difference of two numbers. This is often called the reverse triangle inequality.
From the triangle inequality \(|x|+|y|\geq |x+y|\) we can arrive at the following two inequalities, by setting \(x=a, y=b-a\) and \(x=b, y=a-b\)
\begin{align*} |a| + |b-a| \amp \geq |b|\\ |b| + |a-b| \amp \geq |a| \end{align*}
Rearranging these gives
\begin{equation*} |b-a| \geq |b|-|a| \end{equation*}
and \(|b|-|a| \geq -|a-b|\text{,}\) which can be rewritten as
\begin{equation*} -(|b|-|a|) \leq |b-a| \end{equation*}
Putting these together gives
\begin{equation*} -(|b|-|a|) \leq |b-a| \leq |b|-|a| \end{equation*}
from which the result follows.
When we first encounter the absolute value, it is often tempting to think of it a function that “removes the minus sign”. Such thinking leads to errors. In particular, if \(x\) is a negative number then \(|x| = -x\text{,}\) and the presence of that minus sign can be very confusing.
In computing and in some applications it can be quite useful to have a “signed zero”. The interested reader should search-engine their way to more information on this topic and the related topic of the extended real number system. You have actually already seen some of the ideas when you studied limits to zero and to \(\pm \infty\) in Calculus 1.
This gives a nice counter example to the misquotation of Aristotle about sums and parts that has been worn out from (over/mis)use.
Mathematicians like results like this one. When we define a new mathematical operation or function, we want to see how it interacts with the ones we already know. When you did Calculus you saw results like this — we have just defined limits, how do limits interact with addition, multiplication and division? There are many other examples including the product rule and the quotient rule and integration by parts. We will see more examples when we get to functions in Chapter 10.
Indeed it was likely first proved by the ancient Greeks, and appears in Book 1 of Euclid’s Elements as Proposition 20. The interested reader should search-engine their way to a discussion of Euclid’s elements — likely one of the most influential books ever written.
The pedantic reader will notice that we could have said “whether each quantity is non-negative or negative”, since we have defined the absolute value function to lump \(x=0\) together with \(x \gt 0\text{.}\) We could have split absolute value function in 3 pieces \(x \gt 0, x=0, x \lt 0\) as we did in one of the proofs earlier in the section. While this is nicely symmetric, it does make our proofs longer, since we have to consider 3 cases for each quantity.