# Triangle inequality

The triangle inequality takes a few common forms, for example: $d(x,z)\le d(x,y)+d(y,z)$ (see metric space) of which $|x-z|\le|x-y|+|y-z|$ is a special case.

Another common way of writing it is $|a+b|\le |a|+|b|$, notice if we set [ilmath]a=x-y[/ilmath] and [ilmath]b=y-z[/ilmath] then we get $|x-y+y-z|\le|x-y|+|y-z|$ which is just $|x-z|\le|x-y|+|y-z|$

## Definition

The triangle inequality is as follows:

• $|a+b|\le |a|+|b|$

### Proof

We have 4 cases:

1. Suppose that [ilmath]a>0[/ilmath] and [ilmath]b>0[/ilmath]
We see immediately that [ilmath]a>0\implies a+b>0+b=b>0[/ilmath] so [ilmath]a+b>0[/ilmath]
• thus [ilmath]\vert a+b\vert=a+b[/ilmath]
We also see that [ilmath]\vert a\vert=a[/ilmath] as [ilmath]a>0[/ilmath]
and that [ilmath]\vert b\vert=b[/ilmath] for the same reason.
• thus [ilmath]\vert a\vert+\vert b\vert=a+b[/ilmath]
• We see that [ilmath]\vert a+b\vert=\vert a\vert+\vert b\vert[/ilmath]
• Notice [ilmath]\vert a+b\vert=\vert a\vert+\vert b\vert\implies\vert a+b\vert\le\vert a\vert+\vert b\vert[/ilmath] in the literal sense of "if left then right"
([ilmath]\implies[/ilmath] denotes logical implication)
2. Suppose that [ilmath]a>0[/ilmath] and [ilmath]b\le 0[/ilmath]
3. Suppose that [ilmath]a\le 0[/ilmath] and [ilmath]b> 0[/ilmath]
• Mathematicians are lazy, as [ilmath]\mathbb{R} [/ilmath] is a field (an instance of a ring) we know that [ilmath]a+b=b+a[/ilmath] (addition is commutative)
• As [ilmath]\vert\cdot\vert:\mathbb{R}\rightarrow\mathbb{R} [/ilmath] is a function we know that if [ilmath]x=y[/ilmath] then [ilmath]\vert x\vert=\vert y\vert[/ilmath]
• As, again, [ilmath]\mathbb{R} [/ilmath] is a ring, we know that [ilmath]\vert a\vert+\vert b\vert=\vert b\vert+\vert a\vert[/ilmath]
• So:
• [ilmath]\vert a+b\vert[/ilmath]
[ilmath]=\vert b+a\vert[/ilmath] by the commutativity of addition on [ilmath]\mathbb{R} [/ilmath]
[ilmath]\le \vert b\vert+\vert a\vert[/ilmath] by the [ilmath]2^\text{nd} [/ilmath] case (above)
[ilmath]=\vert a\vert+\vert b\vert[/ilmath] again by commutativity of the real numbers
• Thus [ilmath]\vert a+b\vert\le \vert a\vert+\vert b\vert[/ilmath]
4. Both [ilmath]a\le 0[/ilmath] and [ilmath]b\le 0[/ilmath]

TODO: Finish proof

## Reverse Triangle Inequality

This is $|a|-|b|\le|a-b|$

### Proof

Take $|a|=|(a-b)+b|$ then by the triangle inequality above:
$|(a-b)+b|\le|a-b|+|b|$ then $|a|\le|a-b|+|b|$ clearly $|a|-|b|\le|a-b|$ as promised

### Note

However we see $|b|-|a|\le|b-a|$ but $|b-a|=|(-1)(a-b)|=|-1||a-b|=|a-b|$ thus $|b|-|a|\le|a-b|$ also.

That is both:

• $|a|-|b|\le|a-b|$
• $|b|-|a|\le|a-b|$

### Full form

There is a "full form" of the reverse triangle inequality, it combines the above and looks like: $|a-b|\ge|\ |a|-|b|\ |$

It follows from the properties of absolute value, I don't like this form, I prefer just "swapping" the order of things in the abs value and applying the same result