Quantitative Lebesgue Differentiation Theorem proof I found this quantitative version of the Lebesgue differentiation theorem on a Terence Tao's book and I've been struggling in finding a proof, which seems to be easy (at least in Tao's mind):
First of all, we say that a function $f : [0,1] \mapsto [0,1] $ is $(\epsilon,n)$ measurable if there exist a function $g$ which is constant on the dyadic intervals $[\frac{i}{2^n},\frac{i+1}{2^n}] $ and differs from $f$ in $L^1$ norm by at most $\epsilon$.
Lebesgue differentiation theorem (quantitative version).
Let $f :  [0,1] \mapsto [0,1] $ be $(\epsilon,n)$ measurable. Then for all $x$ in $ [0,1] $ outside of a set of measure $O(\sqrt{\epsilon})$ we have $\frac{1}{r} \int_x^{x+r} f(t) \, dt = f(x) + O(\sqrt{\epsilon}) $ for all $0 < r < \sqrt{\epsilon}2^{-n} $.
Tao gives a big hint for that: exploit the low complexity of $g$ which approximate $f$ and use Hardy Littlewood maximal inequality. I've tried to do so with little success, in particular I can't figure out the reason for that $O(\sqrt{\epsilon})$ and the $r$ bound. Can someone please go through this and/or give me more precise hints? Thank you very much
 A: You can mimic the standard proof of the Lebesgue differentiation theorem through the maximal function (see for instance Wikipedia), but changing a bit the oscillation function $\Omega$.
Define 
$$f_r(x)=\frac1r \int\limits_x^{x+r}f(t)dt$$
and
$$\Omega(f)(x)=\sup_{0<r<r_0}f_r(x)-\inf_{0<r<r_0}f_r(x)$$
with $r_0$ to be determined later (instead of the usual $\limsup$ minus $\liminf$, which does not give quantitative estimates but just limiting ones) and observe that $\Omega(g)(x)=0$ for every point $x\in [0,1]$ whose "left distance" from every $n$-diadic number is greater than $r_0$ (i.e. $x-d>r_0$ for every $n$-diadic $d$) because $g$ is constant there. Call $A$ the set of all these points, and observe that $|[0,1]\backslash A|\leq 2^n r_0$.
Set $h=f-g$ so that $\|h\|_1<\varepsilon$. Then
$$\Omega(f)(x)=\Omega(g+h)(x)\leq \Omega(g)(x)+\Omega(h)(x)=\Omega(h)(x)$$
for every $x\in A$. Now 
$$\Omega(h)(x)\leq 2\sup_{0<r<r_0} h_r(x)\leq 2 M(h)(x)$$
where $M$ is the maximal function, so that for every $\lambda>0$ the Hardy-Littlewood inequality yields
$$|\{x\in [0,1]:|\Omega (h)(x)|>\lambda\}|\leq|\{x\in [0,1]:|M(h)(x)|>\lambda/2\}|\leq \frac{C}{\lambda}\|h\|_1<\frac{C}{\lambda}\varepsilon.$$
Choosing $\lambda =\sqrt{\varepsilon}$ this implies that $\Omega(h)(x)\leq \sqrt{\varepsilon}$ outside a set of measure less than $C\sqrt{\varepsilon}$. Choosing $r_0=2^{-n}\sqrt{\varepsilon}$ it is also true that $|[0,1]\backslash A|\leq \sqrt{\varepsilon}$. In this way you obtain a set $\tilde A$ on which $\Omega(f)(x)\leq \sqrt{\varepsilon}$ such that $|[0,1]\backslash \tilde A|\leq(C+1)\sqrt{\varepsilon}$. 
Now you can conclude with the classical Lebesgue theorem, which gives that a.e. the limit of $f_r$ is $f(x)$, so that it holds $|f_r(x)-f(x)|\leq \sqrt{\varepsilon}$ a.e. on $\tilde A$.
