Let $$ f(x) = \begin{cases} x \cos\left(\frac{1}{x}\right) & \text{if } x \neq 0 \\ 0 & \text{if } x=0\end{cases}$$ Is $f$ continuous? Is $f$ differentiable?

$f'(x) = \cos(\frac{1}{x})+\frac{\sin(1/x)}{x}, x\neq 0\\ f'(0) = \lim \limits_{h \to 0} \frac{f(h)-f(0)}{h} \\ \lim \limits_{h \to 0} \frac{f(h)}{h} \Leftarrow \lim \limits_{h \to 0} \frac{h\cos(1/h)}{h} \\ \lim \limits_{h \to 0} \cos(\frac{1}{h}) \\ h \neq0 \\ -1 \le\cos(\frac{1}{h})\le 1 \qquad \qquad (\text{ Squeeze Theorem}) \\ \lim \limits_{h \to 0} 1 =1\\ \lim \limits_{h \to 0} -1 =-1 \\ \lim \limits_{h \to 0} \cos\frac{1}{h} = \text{DNE} \\ \text{f is not differentiable on } \mathbb{R. } \\ f'(x) = \begin{cases} \cos\frac{1}{x}+\frac{\sin1/x}{x}, & \text{if } x \neq 0 \\ 0 & \text{if } x=0\end{cases} \\ \text{ Hence f is not differentiable on } \mathbb{R}.$

$\qquad \text{My question is since this function is not differentiable.}\\\text{ How can I show whether this function is continuous or not continuous?} \\ \text{I know one way to show continuity is by showing at a point that it is } \\ \text{ continuous. For Example } \\ \text{ Showing that the left hand limit is the same as the right hand limit at zero.} \\ \text{Since at x = 0 things are changing. Is that the way to solve this problem or } \\ \text{ is a proof required to show whether this is continous or not?}$

  • 1
    $\begingroup$ Typesetting tip: the "\\" does not work inside the two $\$$s. $\endgroup$
    – xbh
    Jun 16, 2019 at 16:32
  • $\begingroup$ In general, neither you nor anybody else is required to prove that $f$ is continuous. However, if you have to answer the question "Is $f$ continuous?" and to justify your answer, then a proof is required ... $\endgroup$ Jun 16, 2019 at 16:37

2 Answers 2


Well, yes, you need to prove that it is continuous. Outside $0$, that's easy: your function is obtained from continuous function through arithmetic operations and composition. At $0$, use the fact that$$(\forall x\in\mathbb R):-\lvert x\rvert\leqslant x\cos\left(\frac1x\right)\leqslant\lvert x\rvert$$and therefore, by the squeeze theorem,$$\lim_{x\to0}f(x)=0=f(0).$$

  • $\begingroup$ So this function is continuous but not differentiable? $\endgroup$
    – Jon
    Jun 16, 2019 at 16:35
  • $\begingroup$ That is correct indeed. $\endgroup$ Jun 16, 2019 at 16:36

You got off to a good start, but you went astray. Rather, $$\lim_{h\to 0}\cos\left(\frac1h\right)=\lim_{|t|\to\infty}\cos(t),$$ which does not exist, as the cosine function never stops oscillating between $-1$ and $1.$ Thus, $f$ is not differentiable at $0.$

You do need to prove continuity, which is easy for $x\ne 0.$ To prove it for $x=0,$ you can use the fact that $-1\le\cos\left(\frac1x\right)\le1$ for all $x\ne 0,$ whence for such $x$ we have $$-|x|\le x\cos\left(\frac1x\right)\le|x|,$$ and so the Squeeze Theorem proves that $$\lim_{x\to 0}f(x)=0=f(0).$$


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .