I'm exploring differentiation under the integral sign (I want to be much faster and more assured in doing this common task). So one thing I'm interested in is good counterexamples, where both expressions

$\frac{d}{dx} \int f(x,y)dy$

and

$\int \frac{\partial}{\partial x} f(x,y)dy$

exist at some value of x but are not equal. Thanks in advance.

Here is some of my exploration so far.

My derivation for switching the derivative and integral is as follows:

$\frac{d}{dx} \int f(x,y)dy = \frac{d}{dx}\int f(a,y)+\int_a^x \frac{\partial}{\partial s}f(s,y)dsdy = \frac{d}{dx}\int \int_a^x \frac{\partial}{\partial s}f(s,y)dsdy$,

provided f is absolutely continuous in the x-direction (used FTC). Then provided $\frac{\partial}{\partial s}f(s,y)$ is integrable in some rectangle $[x,x'] \times \Omega$, we can apply Fubini and switch the order of integration,

$= \frac{d}{dx}\int_a^x \int \frac{\partial}{\partial s}f(s,y)dyds$.

Then using FTC again, the first integral and derivative cancel provided that $\int \frac{\partial}{\partial s}f(s,y)dy$ is continuous.

Thus altogether the assumptions I need in order to switch integration order are

1) f is absolutely continuous in the x-direction

2) df/da is integrable in a rectangle where one side is a small interval containing x, and the other is the whole y-direction.

3) $\int \frac{\partial}{\partial x} f(x,y)dy$ is continuous.

4) and of course, the original expressions are defined.

This was the most general I could go. The conditions seem messy and forgettable, so I'd like to find some nicer conditions I could use in general, if possible.

Condition 3) seemed like it might be the easiest to toss, but I found a counterexample where all other conditions are satisfied but that one:

Let y be the positive integers and dy be the counting measure, so we're just trying to flip a sum and the derivative. Let

$f(x,y) = x$ for $\frac{1}{y+1} < x <\frac{1}{y}$ and zero elsewhere.

Then we see the integral of the derivative of $f$ is $0$ at $x=0$ and the derivative of the integral is $1$ at $x=0$, thus providing one counterexample. Here conditions 1) and 3) were not satisfied, but the example could be easily modified to make 1) satisfied.