search
Search
Login
Unlock 100+ guides
menu
menu
web
search toc
close
Comments
Log in or sign up
Cancel
Post
account_circle
Profile
exit_to_app
Sign out
What does this mean?
Why is this true?
Give me some examples!
search
keyboard_voice
close
Searching Tips
Search for a recipe:
"Creating a table in MySQL"
Search for an API documentation: "@append"
Search for code: "!dataframe"
Apply a tag filter: "#python"
Useful Shortcuts
/ to open search panel
Esc to close search panel
to navigate between search results
d to clear all current filters
Enter to expand content preview
icon_star
Doc Search
icon_star
Code Search Beta
SORRY NOTHING FOUND!
mic
Start speaking...
Voice search is only supported in Safari and Chrome.
Navigate to

Triangle inequality

schedule Aug 12, 2023
Last updated
local_offer
Tags
mode_heat
Master the mathematics behind data science with 100+ top-tier guides
Start your free 7-days trial now!
Theorem.

Triangle inequality

For all $a\in\mathbb{R}$ and $b\in\mathbb{R}$, the following is true:

$$\vert{a+b}\vert\le\vert{a}\vert +\vert{b}\vert$$

This means that the absolute value of the sum of two real numbers is always less than or equal to the sum of their absolute values.

Proof. Let $a\in\mathbb{R}$ and $b\in\mathbb{R}$. By definition of absolute values, the following is true:

$$\begin{equation}\label{eq:PCwFwysSWTt37PSocwN} a\le\vert{a}\vert,\;\;\;\;\; b\le\vert{b}\vert \end{equation}$$

For example:

  • if $a$ is a positive number like $5$, then $5\le5$ is true.

  • if $a$ is a negative number like $-6$, then $-6\le\vert{-6}\vert$ is true.

Adding the two inequalities in \eqref{eq:PCwFwysSWTt37PSocwN} gives:

$$\begin{equation}\label{eq:JVs1Ho9a1hqDZPIbwNR} a+b\le\vert{a}\vert+\vert{b}\vert \end{equation}$$

The right-hand side of \eqref{eq:JVs1Ho9a1hqDZPIbwNR} matches the right-hand side of the triangle inequality. We will be using this inequality shortly.

Let's now consider the left-hand side of the triangle inequality. $\vert{a+b}\vert$ can be expressed as:

$$\vert{a+b}\vert =\begin{cases} a+b,&\text{if }a+b\ge0\\ -(a+b),&\text{if }a+b\lt0\\ \end{cases}$$

In the 1st case, if $a+b\ge0$, then $a+b=\vert{a+b}\vert$. Substituting this into \eqref{eq:JVs1Ho9a1hqDZPIbwNR} gives us the desired result:

$$\begin{equation}\label{eq:euHyRrhU6V9zurpJsKG} \vert{a+b}\vert \le\vert{a}\vert+\vert{b}\vert \end{equation}$$

Next, we consider the 2nd case when $a+b\lt0$, which implies $-(a+b)=\vert{a+b}\vert$. Let's simplify this:

$$\begin{equation}\label{eq:xVaeOu1ZFGfxeZu8M8N} \begin{aligned}[b] -(a+b)&=\vert{a+b}\vert\\ (-a)+(-b)&=\vert{a+b}\vert\\ \end{aligned} \end{equation}$$

We now use the property of absolute values \eqref{eq:PCwFwysSWTt37PSocwN} to obtain the following inequalities:

$$\begin{equation}\label{eq:f3TgfKyiiGEy9i4oub6} -a\le\vert{-a}\vert=\vert{a}\vert,\;\;\;\;\; -b\le\vert{-b}\vert=\vert{b}\vert \end{equation}$$

Adding the two inequalities in \eqref{eq:f3TgfKyiiGEy9i4oub6} gives:

$$\begin{equation}\label{eq:d1SA5UD9w1ytPHI7icz} (-a)+(-b)\le \vert{a}\vert+ \vert{b}\vert \end{equation}$$

Applying inequality \eqref{eq:d1SA5UD9w1ytPHI7icz} to \eqref{eq:xVaeOu1ZFGfxeZu8M8N} gives us the desired result:

$$\vert{a+b}\vert \le\vert{a}\vert+ \vert{b}\vert$$

This completes the proof.

Example.

Intuition behind triangle inequality

We've proven the triangle inequality but let's now plug in some numbers to see that it indeed holds. The triangle inequality states that:

$$\vert{a+b}\vert\le\vert{a}\vert +\vert{b}\vert$$

If $a=5$ and $b=-8$, then:

$$\vert{5-8}\vert\le \vert{5}\vert +\vert{-8}\vert \;\;\;\;\; \Longleftrightarrow \;\;\;\;\; 3\le 13$$

Great, we see that the triangle inequality holds!

Theorem.

Variant of the triangle inequality

If $a\in\mathbb{R}$ and $b\in\mathbb{R}$, then:

$$\vert{a-b}\vert \ge \vert{a}\vert- \vert{b}\vert$$

This is also equivalent to the following:

$$\vert{b-a}\vert \ge \vert{b}\vert- \vert{a}\vert$$

Proof. Let $a\in\mathbb{R}$ and $b\in\mathbb{R}$. The triangle inequality states that:

$$\begin{equation}\label{eq:VYcedHjjGcYKY93viHt} \vert{a+b}\vert\le\vert{a}\vert +\vert{b}\vert \end{equation}$$

Let $c=a+b$, which implies $a=c-b$. Substituting these values into \eqref{eq:VYcedHjjGcYKY93viHt} gives:

$$\vert{c}\vert \le\vert{c-b}\vert +\vert{b}\vert$$

Rearranging this gives:

$$\vert{c-b}\vert\ge \vert{c}\vert- \vert{b}\vert$$

Since $b\in\mathbb{R}$ and $c\in\mathbb{R}$, this completes the proof of the first part.

We now assume that the following holds:

$$\vert{a-b}\vert \ge \vert{a}\vert- \vert{b}\vert$$

This must hold for any values $a$ and $b$ in $\mathbb{R}$. This means that we can simply swap the positions of $a$ and $b$, that is:

$$\vert{b-a}\vert \ge \vert{b}\vert- \vert{a}\vert$$

This completes the proof but let's take a moment to demonstrate why this is true. For example, let $a=5$ and $b=3$. The following two inequalities must hold:

$$\begin{align*} \vert{3-5}\vert\ge\vert{5}\vert-\vert3\vert\\ \vert{3-5}\vert\ge\vert{3}\vert-\vert5\vert\\ \end{align*}$$

Similarly, consider the second case when $a=3$ and $b=5$. The following must hold:

$$\begin{align*} \vert{5-3}\vert\ge\vert{3}\vert-\vert5\vert\\ \vert{5-3}\vert\ge\vert{5}\vert-\vert3\vert\\ \end{align*}$$

We see that in both cases, the theorem holds true.

Theorem.

Reverse triangle inequality

For all $a,b\in\mathbb{R}$, we have that:

$$\Big\vert \vert{a}\vert- \vert{b}\vert \Big\vert\le \vert{a-b}\vert$$

Proof. We know from the variant triangle inequality that the following inequalities hold:

$$\begin{equation}\label{eq:GFhehdE3ZtK40DVOqWx} \begin{aligned} \vert{a-b}\vert \ge\vert{a}\vert- \vert{b}\vert\\ \vert{b-a}\vert \ge\vert{b}\vert- \vert{a}\vert \end{aligned} \end{equation}$$

Since $\vert{a-b}\vert=\vert{b-a}\vert$, the second inequality can be written as:

$$\vert{a-b}\vert \ge\vert{b}\vert- \vert{a}\vert$$

Multiplying by negative one to both sides gives:

$$\begin{equation}\label{eq:kCW8dpPaYpdFGzAH6Pf} -\vert{a-b}\vert \le\vert{a}\vert- \vert{b}\vert \end{equation}$$

Combining the top inequality of \eqref{eq:GFhehdE3ZtK40DVOqWx} and \eqref{eq:kCW8dpPaYpdFGzAH6Pf} gives:

$$\begin{equation}\label{eq:L66ZIfBJviauRNngafv} -\vert{a-b}\vert \le\vert{a}\vert- \vert{b}\vert\le \vert{a-b}\vert \end{equation}$$

Now, recall the following basic property of absolute values:

$$-x \le{y}\le x \;\;\;\;\Longleftrightarrow\;\;\;\; \vert{y}\vert \le{x}$$

Where $x$ and $y$ are any value in $\mathbb{R}$. Applying this to \eqref{eq:L66ZIfBJviauRNngafv} gives us the desired result:

$$\Big\vert\vert{a}\vert- \vert{b}\vert\Big\vert\le \vert{a-b}\vert$$

This completes the proof.

robocat
Published by Isshin Inada
Edited by 0 others
Did you find this page useful?
thumb_up
thumb_down
Comment
Citation
Ask a question or leave a feedback...
thumb_up
0
thumb_down
0
chat_bubble_outline
0
settings
Enjoy our search
Hit / to insta-search docs and recipes!