Differentiability of $\cos \lvert x\rvert$ I know that $f(x) = \cos\lvert x\rvert$ is differentiable at $x=0$ and I know what its graph looks like.
But if I differentiate $f(x)$ with respect to $x$ , I will have to apply the chain rule i.e,
$\frac {df(x)} {dx} = -sin\lvert x\rvert\cdot \frac {d\lvert x\rvert} {dx}$.
But $\lvert x\rvert$ is not differentiable at $x= 0$ which makes $f(x)$ non differentiable. So, where did I go wrong?
Thanks
 A: Chain rule asserts that if $f$ and $g$ are both differentiable functions, then $(f \circ g)' = (f' \circ g)g'$. In your case, $g(x) = |x|$ is not differentiable, hence chain rule does not apply. This, however, does not imply that the original function is not differentiable.
A: Note that $\cos$ is even, so $\cos (-x) = \cos x$.
Hence $\cos |x| = \cos x$. 
Similarly $f(x) = |x|^2$ is differentiable, not by the chain rule but because $f(x) = x^2$ as well.
A: For derivative definition:
$$\dfrac{1-\cos |x|}{x} = \dfrac{2 \sin^2 \dfrac{|x|}{2}}{x}  \rightarrow 0 $$
A: Notice, graph of $\cos|x|$ is symmetric about Y-axis (as shown in figure) hence $\cos|x|$ is even function i.e. $\cos|x|=\cos x $ $\forall \ \ x\in \mathbb R$ 

Now, $\cos x$ is differentiable at every point. You can't apply chain rule on $\cos|x|$
A: It is known that (more precision):
Proposition (Chain Rule for real-valued functions of one real variable).
If $g$ is a function that is differentiable at a point $c$ and $f$ is a function that is differentiable at $g(c)$, then the composite function $f\circ g$ is differentiable at $c$, and the derivative is $(f\circ g)^{'}(c) = f^{'}((g(c))g^{'}(c)$ 
But, this means that in order to apply the chain rule (for a certain point), you must ensure that both real-valued functions must be differentiable at the point and the image of that point (with respect to function $g$, in this case.)
