Does Lebesgue integration guaranteed for us that we can **always** integrate after differentiation? Our professor gave us this function as a problem of Riemann integration to explain why we need Lebesgue integration :
$$ f(x) = \begin{cases} 
      x^2 \sin{\frac{1}{x^2}} & if \quad x \neq 0  \\
      0 &  if \quad x=0. 
   \end{cases} $$
They said that the problem with Riemann integration is that $f'(x)$ is unbounded on $[-1, 1]$ so we can not integrate after differentiation.
My questions are:
I calculated the derivative at $0$ by definition and it turned out to be zero. Also, the derivative at any point other than zero when I calculated it, I get the following:
$$f'(x) = 2 x \sin (1/x^2) + x^2 (-2 x^{-3})(\cos(1/x^2)). \tag{1}$$

*

*Does the derivative unbounded on $[-1,1]$ because of the zero value that $x$ may take in this interval and because of the angle $(1/x^2)$ in equation $(1)$ and the term $x^{-3}$ in equation $(1)$ also?


*Why we confined ourselves to the interval $[-1,1]$? Is there is a specific reason for that?


*Does the Lebesgue integration guarantee for us that we can always integrate after differentiation? If so, How? which theorem guarantees this?
 A: 1 Does the derivative unbounded on $[−1,1]$ because of the zero value that $x$ may take in this interval and because of the angle $\frac{1}{x^2}$ in equation (1) and the term $x^{−3}$ in equation (1) also?
Yes, the the derivative is unbonded on $[−1,1]$. The term  $2x \sin\frac{1}{x^2}$ is bounded on $(0,1]$ but if we evaluate the term $x^2(−2x^{−3})\cos\frac{1}{x^2}=−\frac{2}{x}\cos\frac{1}{x^2}$ in $a_k=\frac{1}{\sqrt{2 \pi k}}, k\in \Bbb N$ we have $−\frac{2}{a_k}\cos\frac{1}{a_k^2}=-2\sqrt{2 \pi k}$ so is not bounded.
2 Why we confined ourselves to the interval $[−1,1]$? Is there is a specific reason for that?
I think is because in every closed interval that contatins $0$ the derivate of $f$ is unbounded, so we can not use Riemann integration.
3 Does the Lebesgue integration guarantee for us that we can always integrate after differentiation? If so, how? which theorem guarantees this?
No. In fact the function $f'$ is not Lebesgue integrable. There are two conventions for Lebesgue integrability:

*

*A mesurable function is Lebesgue integrable iff
$$
\int_X \vert f \vert d \mu<+\infty
$$

*A mesurable function is Lebesgue integrable iff
$$
\int_X f^+ d \mu<+\infty \lor \int_X  f^- d \mu<+\infty
$$
where $f^+= \max(0,f) $ and $f^-= \max(0,-f) $
Unfortunately the function fails both conditions. Let $A_n= \{a_{k,n}\} ^{4n}_{k=0}$ where $a_{k,n}= \sqrt \frac{2}{ \pi(4n+1)- \pi k}$, note that $0<a_{0,n}=\sqrt \frac{2}{ \pi(4n+1)}<a_{4n,n}=\sqrt \frac{2}{ \pi}<1$. Then for all $n \in \Bbb N$
$$
\int_{[−1,1]}\vert 2x \sin\frac{1}{x^2}−\frac{2}{x}\cos\frac{1}{x^2}\vert d \mu \ge \sum_{k=0}^{4n-1} \int_{[a_{k,n},a_{k+1,n}]}\vert 2x \sin\frac{1}{x^2}−\frac{2}{x}\cos\frac{1}{x^2}\vert d \mu\\
\ge \sum_{k=0}^{4n-1} \vert \int_{[a_{k,n},a_{k+1,n}]} (2x \sin\frac{1}{x^2}−\frac{2}{x}\cos\frac{1}{x^2})d \mu \vert
$$
But the integrand of $\int_{[a_{k,n},a_{k+1,n}]} (2x \sin\frac{1}{x^2}−\frac{2}{x}\cos\frac{1}{x^2})d \mu$ is Riemann integrable so we can evaluate this with Barrow's rule
$$
\sum_{k=0}^{4n-1} \vert \int_{[a_{k,n},a_{k+1,n}]} (2x \sin\frac{1}{x^2}−\frac{2}{x}\cos\frac{1}{x^2})d \mu \vert= \sum_{k=0}^{4n-1}\vert a_{k+1,n}^2 \sin \frac{1}{a_{k+1,n}^2}-a_{k,n}^2 \sin \frac{1}{a_{k,n}^2}\vert=\\
\sum_{k=0}^{4n-1}\vert (-1)^{4n-k} \frac{2}{\pi}\frac{1}{4n-k}-(-1)^{4n-k+1} \frac{2}{\pi}\frac{1}{4n-k+1}\vert =\frac{2}{\pi} \sum_{k=0}^{4n-1}(\frac{1}{4n-k}+\frac{1}{4n-k+1})=\\
\frac{2}{\pi} \sum_{k=0}^{4n-1}(\frac{1}{k+1}+\frac{1}{k+2})
$$
but the armonic sum diverges, so
$$
\int_{[−1,1]}\vert 2x \sin\frac{1}{x^2}−\frac{2}{x}\cos\frac{1}{x^2}\vert d \mu= +\infty
$$
Similary one can prove that
$$
\int_{[-1,1]}f^+= \int_{[-1,1]}f^-=+ \infty
$$
However, if a function $f$ is derivable on $[a,b]$ then  $f'$ is mesurable, and if $f'$ is bounded is Lebesgue integrable and
$$
\int_{[a,b]}f' d \mu=f(b)-f(a)
$$
A: The example that your professor gave is not a good one to motivate the power of Lebesgue integration. The issue is that $f'$ is not Lebesgue integrable (this can be seen by noticing that $\int^1_{-1}|f'(x)|\,dx$ as a proper Riemann integral diverges. The change of variables $u=x^{-2}$ gives
\begin{aligned}
\lim_{\varepsilon\rightarrow\infty}\int_{-1}^{-\varepsilon}  + \int^1_{\varepsilon}\frac{1}{|x|}|\cos(x^{-2})|\,dx
&=\lim_{\varepsilon\rightarrow0}\int^{\varepsilon^{-2}}_1\frac{|\cos u|}{\sqrt{u}}\\
&=\int^\infty_0\frac{|\cos u|}{\sqrt{u}}\geq \sum_n\int^{(2k+1)\pi/2}_{(2k-1)\pi/2}\frac{|\cos u|}{\sqrt{u}}\,du=\infty
\end{aligned}
(you may try to fill in the details)

There are other theories of integration where a fundamental theorem of calculus type of formula may still apply (the so called Gauge integrals)
I will try tow explain the difference between Lebesgue and Riemann integration that fits the question you posed.

*

*One version of fundamental theorem of calculus, in the setting of Lebesgue, says that


Theorem: If $f$ is absolutely continuous on an interval $[a,b]$, then
(1) $f'$ exists at almost every point in $[a,b]$, and
(2) $f'$ is Lebesgue integrable ($\int_{[a,b]}|f'|<\infty $)
(3) $f(b)=f(a)+\int^x_af'(t)\,dt$ for all $a\leq x\leq b$
Another version of says that
Theorem: If $f$ is continuous, differentiable everywhere, with the exception of a countable set of points, and $f'$ is Lebesgue integrable then formula (3) holds.
The integral here is in the sense of Lebesgue (which may not mean much to you at this point, but it is an extension of the Riemann integral in the sense that if $f$ is Riemann integrable in $[a,b]$ then it is also Lebesgue integrable and the values of the integrals coincide). But the point is that the formula of the fundamental theorem of Calculus that one learns in highs school holds.


*

*In Riemann integration, there is a theorem that says that $f$ is Riemann intergrable in an interval $[a,b]$ iff $f$ is bounded, and $f$ is continuous at almost every point of $[a,b]$. Also, the Riemann  version of the fundamental theorem of Calculus reads

Theorem: If $f$ is differentiable in $[a,b]$, and  $f'$ is integrable (in the sense of Riemann) then formula (3) holds.

In the setting of Lebesgue integration, $f'$ may not be bounded, it may be even discontinuous in sets of positive measure.
A: There are some problems in your question.
Is $1/|x|$ Lebesgue integrable on $[-1,1]$ ? Yes in some sense : it is $+\infty$. Then $$\int_{[-1,1]} \frac{\cos(1/x^2)}{x}d\mu = \int_{[-1,1]} \max(0,\frac{\cos(1/x^2)}{x})d\mu+\int_{[-1,1]} \min(0,\frac{\cos(1/x^2)}{x})d\mu= \infty -\infty$$ is undefined.
