Is every "almost everywhere derivative" Henstock–Kurzweil integrable? It is well known that the Henstock–Kurzweil integral fixes a lot of issues with trying to integrate derivatives. The second fundamental theorem of calculus for this integral states:

Given that $f : [a,b] \rightarrow \mathbb{R}$ is a continuous function. If $f$ is differentiable co-countably everywhere (in other words: differentiable everywhere except for possibly a countable set of points), then:

*

*$f'$ is Henstock-Kurzweil integrable

*$\int_a^bf'(x) dx = f(b) - f(a)$

My question is what happens if you replace "co-countably everywhere" with "almost everywhere"? Clearly the second statement no longer holds (the Cantor function provides a counter-example), but what about the first statement?
If $f$ is continuous everywhere and differentiable almost everywhere, is $f'$ necessarily Henstock-Kurzweil integrable?
 A: The answer is no.
Here is a brief explanation: Consider a function $f$ of unbounded variation, where the increasing part comes from a differentiable function whereas the decreasing part comes from a "Cantor-staircase-type" function. Since $\int f'$ can only capture the increasing part, which itself is unbounded, the resulting integral diverges to $+\infty$ and hence $f'$ is not Henstock–Kurzweil integrable.
The following construction is a fleshed-out version of this idea.

Consider a sequence $(x_k)_{k\geq 0}$ such that $0 = x_0 < x_1 < x_2 < \cdots < 1$ and $\lim_k x_k = 1$. Also, for each $k\geq 1$, we pick a point $c_k \in (x_{k-1}, x_k)$. Then define the function $f : [0, 1] \to \mathbb{R}$ as follows:

*

*On each $[x_{k-1}, c_k]$, the graph of $f$ is a line joining $(x_{k-1}, 0)$ to $(c_k, \frac{1}{k})$.


*On each $[c_k, x_k]$, the graph of $f$ is a Cantor staircase joining $(c_k, \frac{1}{k})$ to $(x_k,  0)$.


*$f(1) = 0$.
For instance, the figure below illustrates the graph of $f$ when $x_k = \frac{k}{k+1}$ and $c_k$'s are chosen as the middle points of the subintervals.

The first two condition guarantees that $f$ is continuous on $[0, 1)$. Also, since $0 \leq f(x) \leq \frac{1}{k}$ on each interval $[x_{k-1}, x_k]$, it follows that $f(x) \to 0$ as $x \to 1^-$ and hence $f$ is also continuous at $1$. It is also obvious that $f$ is differentiable almost everywhere with the a.e.-derivative
$$ f'(x) = \begin{cases}
\frac{1}{k(c_k - x_{k-1})}, & \text{if $x \in [x_{k-1}, c_k]$}, \\
0, & \text{elsewhere.}
\end{cases} $$
Since
$$ \lim_{k\to\infty} \int_{0}^{x_k} f'(x) \, \mathrm{d}x
= \lim_{k\to\infty} \sum_{j=1}^{k} \frac{1}{j}
= \infty, $$
it follows that $f'$ is not Henstock–Kurzweil integrable.
A: Here are  three observations that should assist in thinking about this.
Suppose that  $f:[a,b]\to\mathbb R $ is a continuous function that is differentiable almost everywhere.
QUERY. What are the necessary and sufficient conditions in order that  $f'$  is
integrable on $ [a,b] $  in some sense and that $ f $ is an indefinite integral for  $f'$  in that sense, i.e.,
$$  \int_a^xf'(t)\,dt = f(x)-f(a)  \ \ \  (a<x\leq b).   \tag{*}$$

*

*For the Lebesgue integral the NASC for (*)  is that  $f $ is absolutely continuous on  $[a,b]$.


*For the Denjoy-Perron (aka Henstock, Kurzweil, Henstock-Kurzweil, etc.) integral the NASC is that  $f$  is generalized absolutely continuous
in the restricted sense on  $[a,b]$.   [This is popularly known as  ACG${}_*$.]


*Theorem (Lusin).  Suppose that  $ g:[a,b]\to\mathbb R$  is any finite-valued measurable function.  Then there exists a continuous function
$ f:[a,b]\to\mathbb R$   that is differentiable almost everywhere and with  $f'(x)=g(x)$  almost everywhere.
The moral lesson of #3 is that being the derivative a.e. of a continuous function gives you no information whatsoever beyond the obvious fact that it must be measurable.
Short Answer:  The poster asks "If $f$ is continuous everywhere and differentiable almost everywhere, is $f′$ necessarily Henstock-Kurzweil integrable?   The answer is no, not at all.  This condition says nothing about the properties of $f'$ beyond the trivial observation that it does have to be measurable.
Source:  See S. Saks, Theory of the Integral (1937) for this stuff (and many more questions of this nature).
A: Sangchul Lee's answer does a fantastic job of answering my question. But I wanted to share my own answer that I have come up with since, to provide an even more extreme example. A function $f : \mathbb{R} \rightarrow \mathbb{R}$ with the following properties:

*

*$f$ is continuous.

*$f$ is differentiable almost everywhere, with $f' \geq 0$ almost everywhere.

*$\int_a^b f' = +\infty$ for all $a, b \in \mathbb{R}$ with $a < b$.


Preliminary Constructions
Start by letting $C$ denote the Cantor function. Then define $D : \mathbb{R} \rightarrow \mathbb{R}$ as:
$$D(x) := \begin{cases}
x & \text{if $0 \leq x < \frac{1}{2}$} \\
x - C(2x-1) & \text{if $\frac{1}{2} \leq x \leq 1$} \\
0 & \text{otherwise}
\end{cases} $$
This gives an example of a continuous non-negative function, with a maximum output of $\frac{1}{2}$, which is almost everywhere differentiable with $D'=1$ almost everywhere in $[0,1]$, and $D(0) = D(1) = 0$.
So given any interval $[a,b]$, we can lay down multiple copies of rescaled versions of $D$ back to back to construct a function $D_{[a,b]} : \mathbb{R} \rightarrow \mathbb{R}$ satisfying:

*

*$D_{[a,b]}$ is non-negative, with $D_{[a,b]}(x) \leq b-a$ everywhere.

*$D_{[a,b]}$ is continuous, with $D_{[a,b]}(x) = 0$ whenever $x \not\in (a,b)$.

*$D_{[a,b]}$ is differentiable almost everywhere, with $D_{[a,b]}'(x) \geq \frac{1}{b-a}$ almost everywhere in $[a,b]$.


Main Construction
Let $\{ \frac{p_n}{q_n} : n \in \mathbb{N^{\geq 1}}\}$ be an enumeration of the rational numbers in their simplest form, with $q_n > 0$. Then for each $n \in \mathbb{N^{\geq1}}$ define the interval $I_n := [\frac{p_n}{q_n} - \frac{1}{2^{n+1}}\frac{1}{q_n^3}, \frac{p_n}{q_n} + \frac{1}{2^{n+1}}\frac{1}{q_n^3}]$.
Then finally define $f(x) := \sum_{n=1}^{\infty} D_{I_n}(x)$.
I claim that this $f$ satisfies the criteria stated at the beginning. Firstly, the convergence and continuity of $f$ is immediate by using the Weierstrass M-test with $\frac{1}{2^n}$.

Preliminaries for Differentiability
The set $A_1 := \{x \in \mathbb{R} : x \text{ does not have a Liouville-Roth irrationality measure of } 2\}$ is known to be a null set.
The set $A_2 := \bigcup_{n=1}^\infty \{x \in \mathbb{R} : D_{I_n} \text{ is not differentiable at } x\}$ is a countable union of null sets, and is therefore also null.
Finally, the set $B := A_1 \cup A_2$ is a null set.

Differentiability
Given that $r \not\in B$.
Since $r$ has an irrationality measure of $2$, there exists $N \in \mathbb{N}^{\geq 1}$ such that $|r - \frac{p_n}{q_n}| \geq \frac{1}{q_n^3}$ whenever $n \geq N$.
So if $n \geq N$, this means $D_{I_n}(r+h) = 0$ whenever $|h| \leq \frac{1}{q_n^3} - \frac{1}{2^{n+1}}\frac{1}{q_n^3}$, and hence:
$$\small{\frac{|D_{I_n}(r+h)|}{|h|} \leq \frac{\frac{1}{2^n} \frac{1}{q_n^3}}{\frac{1}{q_n^3} - \frac{1}{2^{n+1}} \frac{1}{q_n^3}}}$$
$$\small{\frac{|D_{I_n}(r+h)|}{|h|} \leq \frac{2}{2^{n+1} - 1}}$$
$$\small{\frac{|D_{I_n}(r+h)|}{|h|} \leq \frac{2}{2^n}}$$
Also clearly $r \not\in I_n$, meaning that $D_{I_n}(r) = 0$ and $D_{I_n}'(r) = 0$. Therefore:
$$\small{- \sum_{k=n+1}^{\infty} \frac{2}{2^k} \leq \frac{f(r+h) - f(r)}{h} - \frac{\sum_{k=1}^n D_{I_k}(r+h) - \sum_{k=1}^n D_{I_k}(r)}{h} \leq \sum_{k=n+1}^{\infty} \frac{2}{2^k}}$$
$$\small{-\frac{2}{2^{n}} \leq \frac{f(r+h) - f(r)}{h} - \sum_{k=1}^n \frac{D_{I_k}(r+h) - D_{I_k}(r)}{h} \leq \frac{2}{2^{n}}}$$
$$\small{- \frac{2}{2^{n}} \leq \liminf_{h \rightarrow 0}\frac{f(r+h) - f(r)}{h} - \sum_{k=1}^n D_{I_k}'(r) \leq \limsup_{h \rightarrow 0} \frac{f(r+h) - f(r)}{h} - \sum_{k=1}^n D_{I_k}'(r) \leq \frac{2}{2^{n}}}$$
$$\small{- \frac{2}{2^{n}} \leq \liminf_{h \rightarrow 0}\frac{f(r+h) - f(r)}{h} - \sum_{k=1}^{\infty} D_{I_k}'(r) \leq \limsup_{h \rightarrow 0} \frac{f(r+h) - f(r)}{h} - \sum_{k=1}^{\infty} D_{I_k}'(r) \leq \frac{2}{2^{n}}}$$
As $n$ is arbitrary, we conclude that $\lim_{h \rightarrow 0} \frac{f(r+h) - f(r)}{h} = \sum_{k=1}^{\infty} D_{I_k}'(r)$.
Hence $f$ is differentiable at $r$ with $f'(r) = \sum_{k=1}^{\infty} D_{I_k}'(r)$.

Integrability
Due to the above, clearly $\int_{I_n} f' \geq \int_{I_n} D_{I_n}' \geq 1$ for all $n \in \mathbb{N^{\geq 1}}$. Since any non-empty open interval contains infinitely many disjoint $I_{n_1}, I_{n_2}, ...$ we must have $\int_a^b f' = +\infty$ for all $a,b \in \mathbb{R}$ with $a < b$.
