Counterexamples to differentiation under integral sign?

Consider $$f(x,y) = \cases{ \text{sgn}(x) \dfrac{x^2-y^2}{x^2} & for $0 < |y| < |x|$ \cr 0 & otherwise }$$ Then $\displaystyle \int_{-1}^1 f(x,y)\ dy = 4 x/3$ for $-1 \le x \le 1$, so $\displaystyle \frac{\partial}{\partial x} \int_{-1}^1 f(x,y)\ dy = 4/3$, but $\dfrac{\partial f}{\partial x} (0,y) = 0$ so $\displaystyle \int_{-1}^1 \frac{\partial f}{\partial x}(0,y)\ dy = 0$.


This is an interesting question... which appears to be about "calculus", but which asks for a better answer than could be given in "calculus". And, in fact, I would advocate turning the question around so that the answer to "Can we interchange?" is "Yes, with suitable interpretation...", rather than "Sometimes, but sometimes not."

Upvoted Bob Israel's literal counter-example! :)

An easier analogue is "Clairault's theorem" (I am not at all confident of the correctness of this attribution) about equality of mixed second partials: functions like $xy/(x^2+y^2)$ have unequal mixed second partials at $0$ ... but, from a distributional viewpoint the mixed second partials are absolutely equal. The "discrepancy" is in caring about pointwise values. (Meanwhile, there is also the opposite hazard of thinking that "almost everywhere 0" is operationally $0$ for distributional computations.)

My point is that we oughtn't differentiate unless differentiation is a continuous operation on whatever space of functions, and we oughtn't integrate unless the integration is a continuous map on suitable spaces of functions... so that the question of interchange would be foregone... :)

(A happy situation is when the integrand is a continuous compactly-supported function-valued function of the parameter, and that diff'n is a continuous map from one function-space to another, and then a Gelfand-Pettis integral discussion gives the interchangeability for general reasons. This kind of thing is why L. Schwartz put a perhaps-surprising emphasis on the point that what we now call "Schwartz functions" are functions which admit a smooth extension to a certain $n$-sphere compactification of Euclidean n-space. So, truly, by now, if a situation resists compactification and application of Gelfand-Pettis ideas, perhaps there is a genuine problem. I do also note that "Bochner" or "strong" (which seems to mean "constructed by analogy with Riemann integrals") integrals do not overcome these problems.)

Reprise: there are certainly counter-examples to the literal question, but I'd recommend revising that question exactly in light of the nature of the counter-examples. :)


Set $$ f(x,y) = \begin{cases} \frac{x^3y}{(x^2+y^2)^2}, & {\rm if} \ x \not= 0 \ {\rm or } \ y \not= 0, \\ 0, & {\rm if } \ x = 0 \ {\rm and } \ y = 0, \end{cases} $$ Then the integral $$ F(x) = \int_0^1 f(x,y)\,{\rm d}y $$ can be computed to equal $\frac{x}{2(1+x^2)}$ for all $x$ (check $x = 0$ separately). This is a differentiable function for all $x$, with $$ F'(x) = \frac{1-x^2}{2(1+x^2)^2}. $$ In particular, $F'(0) = 1/2$. However, $$ \frac{\partial}{\partial x}f(x,y) = \begin{cases} \frac{x^2y(3y^2-x^2)}{(x^2+y^2)^3}, & {\rm if } \ y \not= 0, \\ 0, & {\rm if } \ y = 0, \end{cases} $$ so $f_x(0,y) = 0$. Therefore the "equation" $$ \frac{\rm d}{{\rm d}x}\int_0^1 f(x,y)\,{\rm d}y = \int_0^1 \frac{\partial}{\partial x}f(x,y)\,{\rm d}y $$ is invalid at $x = 0$, where the left side is $1/2$ and the right side is $0$. A problem is that $f_x(x,y)$ is not a continuous function of two variables: along the line $y = x$ we have $f_x(x,y) = f_x(x,x) = 1/(4x)$ for $x \not= 0$, which does not converge as $x \rightarrow 0$ even though $f_x(0,0) = 0$ is defined.