There is a standard means of approximating a bounded nonnegative function from below in a measure theoretic setting, which is
$f_n=2^{-n}\lfloor{2^nf}\rfloor\wedge n=2^{-n}\sum_{j=0}^{n2^n}j\mathbf{1}_{A_{n_j}}$
where $A_{n_j}=f^{-1}[\frac{j}{2^n},\frac{j+1}{2^n})$ for $j\neq n2^n$ and $A_{n_j}=f^{-1}[n,\infty)$ for $j=n2^n$.
I see intuitively (by drawing pictures) why this is a uniform approximation, and where the second equality comes from. However I can't see how to prove these rigorously in a clean way. Does anyone have a clean and insightful proof of (a) the second equality and (b) that the $f_n$ uniformly approximate $f$?
Many thanks!