$L^p$ Approximation of a $L^p$ function on $\Bbb R$ for $1\leq p<\infty$ Let $f\in L^p(\Bbb R)$ where $p\in [1,\infty)$. For $k\in \Bbb N$ and $n\in \Bbb Z$, let $I_{k,n}$ denote the interval $(\frac{n-1}{2^k},\frac{n}{2^k}]$, so that for a fixed $k$, the $I_{k,n}$'s form a partition of $\Bbb R$. Let $f_k$ be the function defined by $f_k(x) = 2^k \int_{I_{k,n}}f(y)dy$ if $x\in I_{k,n}$. How can we show that $f_k\to f$ in $L^p(\Bbb R)$?
 A: For $1<p<\infty$ here is a sketch:

*

*For continuous functions $f$ over a compact set $[-m,m]$,

$$
\begin{align}
\Big|f_k(x)-f(x)\Big|&=\frac{1}{2^{-k}}\sum_n\Big|\int_{I_{k,n}} f(t)-f(x)\,dt\Big|\mathbb{1}_{I_{k,n}}(x)\leq \sum_n\|f-f(x)\|_{I_{k,n}}\mathbb{1}_{I_{k,n}}(x)\\
\end{align}
$$
where $\|f-f(x)\|_{n,k}=\sup_{t\in I_{k,n}}|f(t)-f(x)|$. By uniform convergence,
for $\varepsilon>0$, there is $K_\varepsilon$ such that
$$|f_k(x)-f(x)|\mathbb{1}_{I_{k,n}}(x)< \varepsilon\mathbb{1}_{I_{n,k}}(x)
$$
for $k\geq K_\varepsilon$. Hence $\|f_k-f\|_p\leq \varepsilon(2m)^{1/p}$ and so, $\lim_k\|f_k-f\|_p=0$.

*

*For a general $f\in L_p$, let $g^\ell\in\mathcal{C}_c(\mathbb{R})$ be such that $\|f-g^\ell\|_p\leq\frac1\ell$.

$|f_k-f|\leq |f_k-g^\ell_k|+|g^\ell_k-g^{\ell}|+|g^\ell-f|$ and so
$\|f_k-f\|_p\leq \|f_k-g^\ell_k\|_p+\|g^\ell_k-g^\ell\|_p+\|g^\ell -f\|_p$
The term
$\|f_k-g^{\ell}_k\|_p$ can be control by the strong p-tye Hardy-Littlewood's maximal inequality the get
$$ \|f_k-g^{\ell}_k\|_p\leq c_p\|f-g^\ell\|_p$$
for some constant $c_p$ (which depends only on $p$).
The other two terms can be made arbitrarily small by the first part of the proof and by choice of $g^\ell$ respectively.

Edit: It was brought to my attention (thanks to zhm.) that we can do without resorting to the Hardy-Littlewood maximal inequality. Here a simple proof:
$$|f_k(x)|^p=\sum_n\Big|\frac{1}{|I_{k,n}|}\int_{I_{k,n}} f\Big|^p\mathbb{1}_{I_{k,n}}(x)\leq \sum_n\Big(\frac{1}{|I_{k,n}|}\int_{I_{k,n}} |f|^p\Big)\mathbb{1}_{I_{k,n}}(x)
$$
whence, after integration, we obtain $\|f_k\|^p\leq\|f\|$ for any $f\in L_p$ ($1\leq p<\infty$).
Whit this estimate, we can then expand the validity of the statement to include $p=1$.

A: Hints: First, the result is easy for $g\in C_c.$ Second, $C_c$ is dense in $L^p.$ Third, show
$$\int_{\mathbb R} |f_k|^p \le \int_{\mathbb R} |f|^p$$
for all $k$ and all $f\in L^p.$
A: Here is a variant using some probability theory:
Using the inequality $\|f_k\|_p\leq\|f\|_p$ from the other answers, it suffices to show that $f_k|_{(-N,N]}$ converges to $f|_{(-N,N]}$ in $L^p((-N,N])$ for all $N\in\mathbb{N}$. I will write $\mathbb{P}$ for the normalized Lebesgue measure on $(-N,N]$ and $\mathbb{E}$ for the corresponding expectation (of course the normalization does not matter for the $L^p$ convergence).
Let $\mathcal{F}_k$ be the $\sigma$-algebra on $(-N,N]$ generated by the intervals $I_{k,n}\cap (-N,N]$ with $n\in \mathbb{Z}$. A direct computation shows that $\mathbb{E}[f\mid \mathcal{F}_k]=f_k$. Moreover, the $\sigma$-algebra $\bigvee_k \mathcal{F}_k$ is the Borel $\sigma$-algebra on $(-N,N]$. Now it follows from Doob's martingale convergence theorem (or Lévy's zero–one law, if you like) that $f_k\to f$ in $L^p(\mathbb{P})$ and almost everywhere.
