Example where integration by parts formula fails for a.e. differentiable functions I'm studying for a qual and found this problem. We were given two absolutely continuous functions $f,g$ on $[a,b]$. The first two parts of the problem involved proving the integration by parts formula:
$$
\int_{[a,b]}fg' = f(b)g(b)-f(a)g(a) - \int_{[a,b]} f'g.
$$
This was fairly straight forward. However, the last part now asks to find an example where this formula need not hold if we only assume $f$ and $g$ are differentiable almost everywhere as opposed to absolutely continuous. Can someone provide an example/a hint for me to verify?
 A: Let $f(x) = g(x) = x$ on $(0,1)$, and let $f(x) = g(x) = 0$ everywhere else. Then $f$ and $g$ are a.e. differentiable on $\mathbb{R}$ and $$
  \int_{[0,1]} fg' = \int_{[0,1]} x = \frac{1}{2}.
$$
But integration by parts yields $$
   \int_{[0,1]} fg' = \underbrace{f(1)g(1)}_{=0\cdot 0} - \underbrace{f(0)g(0)}_{=0\cdot 0} - \underbrace{\int_{[0,1]} f'g}_{=\int_{[0,1} x = \frac{1}{2} } = -\frac{1}{2}.
$$
The problem here is that $f(1)g(1)$ "should" be $1$, which would then yield the correct answer $1 - \frac{1}{2} = \frac{1}{2}$. But we forced that term to be 0 by decreeing that $f$ and $g$ be zero at one. Since this changes the functions only on a set of measure zero, it does not change any of the integrals, but it does change the value of $f(b)g(b) - f(a)g(a)$, since this expressions depends on the values of $f$ and $g$ at single points. This, as can be seen, "breaks" partial integration.
In general, whenever a formula relates the value of an integral of functions to their values at single points, it'll very likely require some property to really hold everywhere, not just a.e.. Because whenever things just hold a.e., the values at single points can be changed without changing the integrals.
A: You can write something along the lines $$f(x)=x^2/2,\quad g(x)=\begin{cases}1,&x\le \frac 12\\0,&x>\frac 12 \end{cases}.$$
Then $$\int_{[0,1]}f'g=\int_0^{1/2} xdx=\frac 14.$$ After that $f(0)=g(1)=0$, hence the non-integral parts of the intergration by parts vanish.
Yet $$\int_0^1 fg'  =0$$ if you "forget" about the discontinuity of $g$ and the fact that $g$ is only piecewise differentiable.
And, for sake of completness of the answer, the derivative of $g$ is well-defined in the sense of distributions and is equal to $-\delta_{1/2}$.
