Differentiability of $f(|x|)$ What are the rules for the differentiability of $f(|x|)$? In hindsight, and upon inspecting $\sin(|x|)$ and $\cos(|x|)$, the only rule I can deduce is that $f(x)$ should not be zero at $x=0$. But I couldn't get any polynomials for which my rule applies. So is $\cos(|x|)$, the only possible function where $f(x)$ is differentiable at $x=0$ or are there any other polynomials too?
 A: For all $x>0$, the derivative of $f(|x|)$ equals $f'(x)$, and for all $x<0$, the derivatice of $f(|x|)$ equals $-f'(-x)$. Thus, $f(|x|)$ is differentiable (at $0$) if and only if
$$\lim_{x\to 0^+}f'(x)=-\lim_{x\to 0^-}f'(-x).$$
If $f$ is continuously differentiable, above condition holds if and only if $f'(0)=0$.
This shows why your example of $f(x)=\cos x$ works: its derivative at $0$ is $-\sin 0=0$.
Further, any polynomial $f(x)$ with no linear term will also work. For instance, take $f(x)=3x^3-2x^2-5$.
A: The condition for differentiability of $f(\lvert x\rvert)$ is if and only if $f$ is differentiable on $(0,\infty)$ and $\lim_{x\to 0^+}\frac{f(x)-f(0)}x=0$. In which case, $\frac{d}{dx}f(\lvert x\rvert)=\begin{cases}0&\text{if }x=0\\ -f'(\lvert x\rvert)&\text{if }x<0\\ f'(\lvert x\rvert)&\text{if }x>0\end{cases}$.
For the $[\Leftarrow]$ part, by chain rule the only issue is differentiablity at $0$. Then, $\lim_{x\to 0}\frac{f(\lvert x\rvert)-f(0)}x$ exists if and only if $\lim_{x\to0^+}\frac{f(\lvert x\rvert)-f(0)}x$ and $\lim_{x\to0^-}\frac{f(\lvert x\rvert)-f(0)}x$ exist and they are equal. Evidently, \begin{align}&\lim_{x\to0^+}\frac{f(\lvert x\rvert)-f(0)}x=\lim_{x\to0^+}\frac{f( x)-f(0)}x=0\\ &\lim_{x\to0^-}\frac{f(-x)-f(0)}x=\lim_{x\to0^+}\frac{f(x)-f(0)}{-x}=-\lim_{x\to0^+}\frac{f(x)-f(0)}{x}=0\end{align}
For the $[\Rightarrow]$ part, notice that $g:=f(\lvert\bullet\rvert)$ and $f$ coincide on $[0,\infty)$. For $x>0$ and sufficiently small $h$, $\lvert x+h\rvert=x+h$, therefore $f'(x)=g'(x)$ for all $x>0$. Moreover, $\lim_{x\to 0^+}\frac{f(x)-f(0)}x=\lim_{x\to 0^+}\frac{f(\lvert x\rvert)-f(0)}x$. We only need to prove that $g'(0)=0$ this is because $g$ is even, and by change of variable $$g'(x)=(g\circ(-id))'(x)=-g'(-x)$$ This implies $g'(0)=-g'(-0)=-g'(0)$.
$$$$
The final identity is fairly easy to prove with chain rule, more or less in the fashion that we've discussed for $g'(0)$.
A: Consider:
$$f(x)=x^2$$
$$\Rightarrow f(|x|)=x^2$$
which is differentiable at $0$.
This reveals that a) the function $f$ does not have to exclude $(0,0)$, and b) $f'(0)=0$ might be a more reasonable condition.
Assuming that $f$ is entirely differentiable, we can show that this is a necessary and sufficient condition by breaking $f$ into piecewise:
$$f(|x|)=\left\{\begin{matrix}f(x)&x\geq0\\f(-x)&x<0\end{matrix}\right.$$
Differentiating:
$$\frac{d}{dx}f(|x|)=\left\{\begin{matrix}f'(x)&x\geq0\\-f'(-x)&x<0\end{matrix}\right.$$
Evaluating the limit from both sides of $x=0$, we get that for $f(|x|)$ to be differentiable, it must be that $f'(0)=-f'(0)$, or $f'(0)=0$.
A: I want to postulate a new rule. If $f(x)$ is symmetric about $y$ axis, then $f(|x|)$ is differentiable at $x=0$.
After briefly reading through the answers, I think the reason is that when we take $f(|x|)$, what happens is we get is $f(x)$ on the positive $x$ axis and $f(-x)$ on the negative $x$ axis. In other words, $f(|x|)$ remains the same as $f(x)$ on the $+x$ axis while on the $-x$ axis, $f(|x|)$ $-x$ axis is constituted by the mirror image of the function on the $+x$ axis.
(I know I am supposed to upload an example but the laptop I am currently using doesn't have the screenshot option, so you will have to visualise $\left(\left|x\right|-1\right)^{2}$) and $\left(x-1\right)^{2}$ as the example in your mind or on desmos)
The only way to get a differentiable function is to have a smooth line, and so the only way to get a $f(|x|)$ that is differentiable at $x=0$ would be to have a symmetric function

This was supposed to be an edit, but I thought I would post it separately so I could see if others accept this answer or not
