# Is the following function continuously differentiable at $x=0$?

Is the function $$f(x) = \begin{cases} 1 & x\leq0 \\ \cos(x) & x\geq 0 \end{cases}$$ differentiable at $x=0$? Is it continuously differentiable?

How can I check it? I see that $$\lim_{x\to0^+}\frac{\cos(x) - 1}{x},$$ and

$$\lim_{x\to0^-}\frac{1-1}{x-0},$$

but how can I conclude from here?

hint: $\cos x - 1 = -2\sin^2 (\frac{x}{2})$, and use $\dfrac{\sin (\frac{x}{2})}{\frac{x}{2}}\to 1$.
• One could also use L'Hospital Rule if it is allowed by instructor. (It is allowed as far as math is concerned, to find the limit: $\lim_{x\to0^+}\dfrac{\cos(x) - 1}{x}= \lim_{x\to0^+}\dfrac{-\sin(x)}1=\lim_{x\to0^+}\dfrac01=0$.) – Mirko Jul 28 '15 at 22:20
it is continue in $x=0$ so check f' $$f'(x)=\left\{\begin{matrix} 0 &x<0\\ -sin x& x>0 \end{matrix}\right.$$ $$\lim_{x\rightarrow x^+}f'(x)= \lim_{x\rightarrow x^+} -sinx =0\\ \lim_{x\rightarrow x^-}f'(x)=\lim_{x\rightarrow x^-}0=0\\f'_{0^+}=f'_{0^+}$$ so it is differentiable at $x=0$
then ,it is differentiable at every point in $\mathbb{R}$
• if you want to do by limit , it is possible . $$\lim_{x\rightarrow 0^+}\frac{f(x)-1}{x-0}=\lim_{x\rightarrow 0^+}\frac{1-1}{x-0}=0\\ \lim_{x\rightarrow 0^-}\frac{f(x)-1}{x-0}=\lim_{x\rightarrow 0^+}\frac{cosx-1}{x-0}=\\\lim_{x\rightarrow 0^-}\frac{cos x-1}{x}\frac{cos x+1}{cosx +1}= \\\lim_{x\rightarrow 0^-}\frac{-sin^2x}{x(cos x+1)}=\\ \lim_{x\rightarrow 0^-}\frac{-sinx}{(cos x+1)}=\frac{0}{1}=0$$ – Khosrotash Jul 28 '15 at 21:57
• Small typo: $\lim_{x\to0^-}\frac{-\sin(x)}{\cos(x)+1} = \frac{0}{2}=0$. – Aad Jul 28 '15 at 22:06
• This may be a very nice and accepted answer, but it is incorrect. It is an answer to a different question, not the one posted. The derivative at $0$ has not been properly found in this answer. To see the difference, try $g(x) = \begin{cases} x^2 \sin(\frac1x)& x<0 \\0&x=0\\x^2 \cos(\frac1x) & x>0\end{cases}$. The hint by KfSsOc in the other answer is correct (find both limits and see if they are equal). It is not that "if you want to find by limits": You have no other option here. This should have been your correct answer, not an extra comment. You did "continuously" but not "diffeentiable" . – Mirko Jul 28 '15 at 22:11
• @Aad One CANNOT use DIRECTLTY the knowledge of what happens with the derivatives on both sides. That knowledge is helpful to answer the question whether the derivative is continuous at $0$, if it exists. The question whether it exists must be answered on its own, by finding the limits in your question $\lim_{x\to0^+}\frac{\cos(x) - 1}{x}$ and $\lim_{x\to0^-}\frac{1-1}{x-0}$. – Mirko Jul 28 '15 at 22:28