[Math] Proving that the absolute value of a function is continuous if the function itself is continuous

continuityreal-analysis

I would like to prove that if the function $f : D \rightarrow \mathbb{R}$ is continuous, and the function $|f| : D \rightarrow \mathbb{R}$ is defined by $|f|(x) = |f(x)|$ for all $x$, then the function $|f| : D \rightarrow \mathbb{R}$ is also continuous.

I think that the correct way to do to this is to use the fact that for two functions $f : D \rightarrow \mathbb{R}$ and $g : U \rightarrow \mathbb{R}$ such that $f(D)$ is contained in $U$, the composition of functions, $g \circ f: D \rightarrow \mathbb{R}$ is continuous if $f$ and $g$ are continuous.

So, does that mean to prove my original assertion, I should introduce a new function $f : D \rightarrow \mathbb{R}$ defined and $g : D \rightarrow \mathbb{R}$ defined by $g(x) = |x|$. Then, I should prove that $f$ and $g$ are continuous, and by the continuity of composition of functions, I can conclude that $g \circ f$ is continuous, which completes my proof?

I don't know if $f$ and $g$ should be defined on $D$, though. I believe that now I just need to show $g$ is continuous to complete my proof.

Could someone please help me check this method, and help me with this exercise? This isn't a homework problem, I'd just like to learn some analysis on my own.


My attempt at the proof:
First of all, here is the definition of continuity that I am following:

Definition: A function $f : D \rightarrow \mathbb{R}$ is said to be continuous at the point $x_{0}$ in $D$ provided that whenever $\{x_{n}\}$ is a sequence in $D$ that converges to $x_{0}$, the image sequence $\{f(x_{n}\}$ converges to $f(x_{0})$. The function is said to be continuous provided that it is continuous everywhere in $D$.


Lemma 1: The function $f : \mathbb{R} \rightarrow \mathbb{R}$ defined by $f(x) = |x|$ is continuous.

Proof of Lemma 1: Select a point $x_{0}$ in $\mathbb{R}$ and let $\{x_{n}\}$ be a sequence that converges to $x_{0}$. Then,

$$\lim_{n\to\infty}f(x_{n}) = \lim_{n\to\infty}|x_{n}| = |x_{0}| = f(x_{0}).$$

So, $f$ is continuous at $x_{0}$.

Proof of Assertion: Let $f : D \rightarrow \mathbb{R}$ and $g : D \rightarrow \mathbb{R}$ be functions, where $g(x) = |x|$. By our assumption, $f$ is continuous. Also, by Lemma $1$, $g$ is continuous. Therefore, by the continuity of composite functions, $(g \circ f)(x)$ is also continuous. This completes our proof.

Best Answer

To show that $|f(x)|$ is continuous at a point $x=a$ we need to show that given an $\epsilon>0$, there exist a $\delta $ such that $$ |x-a| <\delta \implies ||f(x)|-|f(a)||<\epsilon$$

Since $f(x)$ is continuous at $x=a$ for the given $\epsilon$ we have a $\delta$ such that $$ |x-a| <\delta \implies |f(x)-f(a)|<\epsilon$$

Note that if $$ |x-a| <\delta$$ then $$ ||f(x)|-|f(a)||\le |f(x)-f(a)|<\epsilon $$