Suppose I have a function \begin{equation} f(x) = \begin{cases} x^2\,\,\,&\text{if}\,\,\, x<a,\\ 0\,\,\,&\text{if}\,\,\, x>a, \end{cases} \end{equation} where $a$ is a positive number, and suppose I want to compute the integral \begin{equation} \int_0^{\infty}\frac{df(x)}{dx}dx. \end{equation} We try to do this in two different ways.
We simply insert $f(x)$ and note that we need to compute the integral separately for the two different intervals: \begin{equation} \int_0^{\infty}\frac{df(x)}{dx}dx = \int_0^a2xdx = a^2. \end{equation}
We rewrite $f(x)$ using the Heaviside step function and then integrate. We get \begin{equation} f(x) = x^2(1-H(x-a)), \end{equation} which means that \begin{equation} \frac{df(x)}{dx} = 2x(1-H(x-a))-x^2\delta(x-a), \end{equation} where we have used the product rule for distributional derivatives described here, and the fact that the derivative of the Heaviside function is the Dirac delta. Inserting this into the integral gives us \begin{equation} \int_0^{\infty}\frac{df(x)}{dx}dx = \int_0^{\infty}\left(2x(1-H(x-a))-x^2\delta(x-a)\right)dx = \int_0^a2xdx - \int_0^{\infty}x^2\delta(x-a)dx = a^2-a^2 = 0. \end{equation}
Why don't I get the same answer? I realize it probably has to do with misuse of distributions, but I can’t seem to find the problem.
What does the integral you want to compute mean? The function is discontinuous, so its derivative is not well-defined everywhere, and one can consider the distributional derivative, which is in general different from computing the derivative almost everywhere. The distributional derivative is a measure that is not absolutely continuous with respect to the Lebesgue measure so one cannot cut the integral on $(0,a)$ and $(a,\infty)$ but the set $\{a\}$ has to be considered as well.
So everything is about the choice of derivative: distributional or classical derivative except where it is undefined. The same is true for the Heaviside function. Its classical derivative is $0$ except at $x=0$ where is it undefined.
The distributional derivative is often preferred because it keeps the fundamental theorem of calculus. Here, $\int_0^\infty f' = f(\infty)-f(0)=0$.