Show that $f(x)=|\cos x|$ is a continuous function.
The given function is $f(x)=|\cos x|$
This function $f$ is defined for every real number and $f$ can be written as the composition of two functions as,
$f=g \circ h$, where $g(x)=|x|$ and $h(x)=\cos x$
$[\because(g o h)(x)=g(h(x))=g(\cos x)=|\cos x|=f(x)]$
It has to be first proved that $g(x)=|x|$ and $h(x)=\cos x$ are continuous functions.
$g(x)=|x|$ can be written as
$g(x)= \begin{cases}-x, & \text { if } x<0 \\ x, & \text { if } x \geq 0\end{cases}$
Clearly, $g$ is defined for all real numbers.
Let $c$ be a real number.
Case I:
If $c<0$, then $g(c)=-c$ and $\lim _{x \rightarrow c} g(x)=\lim _{x \rightarrow c}(-x)=-c$
$\therefore \lim _{x \rightarrow c} g(x)=g(c)$
Case II:
If $c>0$, then $g(c)=c$ and $\lim _{x \rightarrow c} g(x)=\lim _{x \rightarrow c} x=c$
$\therefore \lim _{x \rightarrow c} g(x)=g(c)$
So, $g$ is continuous at all points $x>0$.
Case III:
If $c=0$, then $g(c)=g(0)=0$
$\lim _{x \rightarrow 0^{-}} g(x)=\lim _{x \rightarrow 0^{-}}(-x)=0$
$\lim _{x \rightarrow 0^{+}} g(x)=\lim _{x \rightarrow 0^{+}}(x)=0$
$\therefore \lim _{x \rightarrow 0^{+}} g(x)=\lim _{x \rightarrow 0^{+}}(x)=g(0)$
So, $g$ is continuous at $x=0$
From the above three observations, it can be concluded that $g$ is continuous at all points.
Now, $h(x)=\cos x$
It is evident that $h(x)=\cos x$ is defined for every real number.
Let $c$ be a real number.
Put $x=c+h$
If $x \rightarrow c$, then $h \rightarrow 0$
$h(c)=\cos c$
$\lim _{x \rightarrow c} h(x)=\lim _{x \rightarrow c} \cos x$
$=\lim _{h \rightarrow 0} \cos (c+h)$
$=\lim _{h \rightarrow 0}[\cos c \cos h-\sin c \sin h]$
$=\lim _{h \rightarrow 0} \cos c \cos h-\lim _{h \rightarrow 0} \sin c \sin h$
$=\cos c \cos 0-\sin c \sin 0$
$=\cos c \times 1-\sin c \times 0$
$=\cos c$
$\therefore \lim _{x \rightarrow c} h(x)=h(c)$
So, $h(x)=\cos x$ is a continuous function.
It is known that for real valued functions $g$ and $h$,such that $(g \circ h)$ is defined at $x=c$, if $g$ is continuous at $x=c$ and if $f$ is continuous at $g(c)$, then ( $f \circ g$ ) is continuous at $x=c$.
Therefore, $f(x)=(g \circ h)(x)=g(h(x))=g(\cos x)=|\cos x|$ is a continuous function.