# A proof of the triangle inequality

October 15, 2017If there was a package manager for math theorems and every proof had to install all its dependencies, I am sure that the triangle inequality would have a tremendous amount of downloads. It would be one of those utility packages from npm^{1} that everyone knew and used. With programming I believe that investigating how such a package works or even writing your own version of it is a great way to learn. Applying that analogy to math suggests that we should investigate where these utility theorems are coming from. Or put in other words: We should study their proofs.

## The triangle inequality

The triangle inequality ^{2} is such a simple yet useful theorem that I decided to revisit its proof and write it down in my own words. For real numbers, it says the following:

\( \forall x,y \in \mathbb{R}: \quad |x + y| \leq |x| + |y| \)

Where \( |x| \) denotes the absolute value of \( x\), which is just the number without the sign. For example we have \( |-2| = 2 = |2| \). It is a simple statement that can be applied whenever an upper bound for the absolute value of a sum is needed. Sometimes it is not good enough, but often this gives good estimations of upper bounds and is used in theorems of this kind.

## A proof

Proving this theorem not complicated and requires zero intuition, ideas or knowledge of other theorems. One could think such a *simple* theorem cannot be very powerful, but it actually is. There are many ways to go about this proof, I write this one here with the intent of showing the theorems simplicity. We consider two arbitrary numbers \( x,y \in \mathbb{R} \) and use definitions to conclude the inequality. For the sum of the two numbers, one of two things can happen:

- \( x + y \geq 0 \)
- \( x + y < 0 \)

Let’s consider the first case where the sum is nonnegative. We know that the absolute value of a nonnegative number is the number itself. Therefore we also know that the absolute value of a number is always greater or equal than the number itself (greater for negative numbers, equal otherwise). This yields:

\( x + y \geq 0 \Rightarrow | x + y | = x + y \leq |x| + y \leq |x| + |y| \)

This holds because replacing \( x \) and \( y \) with their absolute values means adding potentially larger numbers yielding a potentially larger result. Nothing fancy happened here, just adding and comparing numbers.

Now, you might think that the second case is the difficult one. It’s not: Consider \( x + y < 0 \). Since the sum is negative, its absolute value will have flipped sign:

\( x + y < 0 \Rightarrow | x + y | = – ( x + y ) = (-x) + (-y) \leq |x| + (-y) \leq |x| + |y| \)

This is my own proof, so if you spot a mistake please let me know! But I think the general idea is clear: Make some case distinction based on positive and negative numbers and then apply the definition of the absolute value. In the first case we used \( x \leq |x| \) and similarly \( -x \leq |x| \) for the second.