# Showing that $x\sin(1/x)$ has local maximum and local minimum in $(-1/m,1/m)$ for any positive integer $m\geq 1$.

Let $$f:\mathbb{R}\rightarrow\mathbb{R}$$ be given by $$f(x)=\begin{cases}x\sin(\frac{1}{x}), \quad x\neq 0\\ 0, \quad x=0 \end{cases}$$ Show that $$f$$ has a local maximum and a local minimum in $$(-\frac{1}{m},\frac{1}{m})$$ for every positive integer $$m\geq 1$$.

My idea was to consider the set $$A=[-\frac{1}{m},\frac{1}{m}]$$. Since $$A$$ is compact, and $$f$$ is continuous on $$A$$, by the extreme value theorem, $$f$$ attains a maximum and a minimum in $$A$$. Then I wanted to show by Rolle's theorem that the extremum values cannot be attained at the end-points. This is evident if $$f$$ is differentiable on $$(-\frac{1}{m},\frac{1}{m})$$ but I can show that for $$x\neq 0$$, $$f$$ is differentiable since $$f(x)=a(x)\cdot b(c(x))$$ where $$a(x)=x,b(x)=\sin x, c(x) = 1/x$$ which are all "well-behaved" away from $$0$$ and hence $$f$$ is differentiable by application of the product rule and chain rule. The problem arises at $$x=0$$ where $$f$$ is not differentiable. So this approach fails.

Any hints on an alternative method to prove this?

The derivative of $$f$$ (away from $$x=0$$, where $$f$$ is not differentiable) is

$$f'(x) = \sin \left( \frac 1x\right) - \frac 1x \cos \left( \frac 1x\right).$$

Thus $$f'(x) = 0$$ if

$$\tan \left( \frac 1x \right) = \frac 1x.$$

Then it is easy to see graphically that there are infinitely many critical point (say, let $$y = 1/x$$, then you are looking for the intersection of the two graphs $$z = \tan y$$ and $$z=y$$).

Rigorously that can be proved by intermediate value theorem: in the interval

$$2n\pi < y < 2n \pi + \frac \pi 2,\ \ n\neq 0,$$

the function $$g = \tan y - y$$ has

$$g(2n\pi ) = -2n\pi <0, \ \ \lim_{y \to 2n\pi + \frac \pi 2} g(y) = +\infty,$$

thus there is $$y^+_n$$ in the interval $$(2n\pi, 2n\pi + \pi/2)$$ so that $$g(y_n^+) = 0$$. So there is a sequence $$\{x_n^+ = 1/y_n^+\}$$ so that $$x_n^+ \to 0$$ and $$f'(x_n^+) = 0$$.

The second derivative of $$f$$ is

$$f''(x) = -\frac{1}{x^3} \sin \left( \frac 1x\right).$$

Since $$y_n^+ = 1/x_n^+ \in (2n\pi, 2n\pi + \pi/2)$$, $$\cos (y_n^+) >0$$ and thus

$$f''(x_n^+) <0, \ \ \ \forall n.$$

Hence $$x_n^+$$ is a local maximum.

As a result, for all $$m>0$$, one can find $$n$$ large enough so that $$|x_n^+|< 1/m$$, hence there is a local maximum in $$(-1/m, 1/m)$$.

One can similarly find a sequence of local minimum tending to zero, by examining $$g$$ in the intervals $$((2n + 1)\pi, (2n+1) \pi + \pi/2)$$. I will leave the details to you.

Let's consider an arbitrary half neighborhood of $$0$$, say $$(0,\epsilon)$$

In the open interval, at points of extrema we must have: $$f'(x)=0\implies \sin (\frac 1x)-\frac 1x\cos \frac 1x=0$$

$$f'(x)=(\tan (\frac 1x)-\frac 1x)\cos \frac 1x$$

By Archimedean property, there exists $$k\in \mathbb N\cup\{0\}$$ such that $$I_k=\Big(\frac 1{(2k+1)\pi+\frac\pi 2},\frac1{(2k+1)\pi-\frac\pi 2} \Big)\subset (0,\epsilon)$$

By IVT, you may verify that $$f'(x)=0$$ has a solution $$s_1$$ on $$I_{k1}=\Big(\frac 1{(2k+1)\pi},\frac1{(2k+1)\pi-\frac\pi 2} \Big)$$ and $$s_2$$ on $$I_{k2}=\Big(\frac 1{(2k+1)\pi+\frac\pi 2},\frac 1{(2k+1)\pi}\Big)$$

$$f''(x)=-\frac{\sin \left(\frac{1}{x}\right)}{x^3}$$ is negative for $$s_1$$ and positive for $$s_2$$ whence it follows that $$s_1$$ is a point of local maxima and $$s_2$$;a point of local minima.

The same analysis as above is valid for the other half of the interval $$(-\epsilon, \epsilon)$$ because $$f$$ is even. And since $$\epsilon\gt 0$$ is arbitrary, the result follows from Archimedean property of real numbers.