Let $f$ be a function, $f:\mathbb{R}\to\mathbb{R}$
$$f(x)=\begin{cases}
e^{x^2}-2 & x< 0 \\
x^3+x-1 & 0\leq x \leq 1 \\
\left|\sin(x)\right| & x>1.
\end{cases}$$
Check if $f$ is continuous and differentiable at $a$, when $a=0,1,\frac{\pi}{2}, \pi$. If $f$ is differentiable at $a$, find $f'(a)$.
What I've been doing:
I found that:
- $f$ is continuous at $0$ but not differentiable.
- $f$ is not continuous at $1$ so it's not differentiable.
And then I thought that $f$ was differentiable at $\pi$ and $\frac{\pi}{2}$ because $f$ is continuous at $(1, +\infty)$ ($\left|\sin(x)\right|$), so I looked for:
- $f'(\frac{\pi}{2})=\left|\cos(\frac{\pi}{2})\right|=0$ (by the solution my prof gave me this is correct).
- $f'(\pi)=\left|\cos(\pi)\right|=-1$ Now this is wrong. The solution they gave me says that $f$ is not differentiable at $\pi$, and I'm really lost. Why is it differentiable at $\frac{\pi}{2}$ and not $\pi$?
Best Answer
Intuitively, $|\sin x|$ is not differentiable at $x=\pi$ because the graph comes to a sharp corner there.
To make this reasoning rigorous, set $f(x)=|\sin x|$ and look at the difference quotient
$$\frac{f(\pi+h)-f(\pi)}{h}=\frac{|\sin(\pi+h)|}{h}$$
When $h\to0^{+}$, the difference quotient is $-\frac{1}{h}\sin(\pi+h)=\frac{1}{h}(\sin h)$, which tends to $1$.
But when $h\to0^{-}$, the difference quotient is $\frac{1}{h}\sin(\pi+h)=-\frac{1}{h}(\sin h)$, which tends to $-1$.
Therefore the two-sided limit of the difference quotient as $h\to 0$ does not exist.
So $f$ is not differentiable at $x=\pi$.
Note that my answer does not look at the limit of $f'$. It looks at the limit of the difference quotient, working directly from the definition of the derivative.