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

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.