A Lebesgue integration question involving an infinite series I came across the following interesting problem in my self-study:
Let $f: X \rightarrow [0, \infty]$ be a measurable function. Assume that $\mu(X) < \infty$. Prove that $\int f \; d\mu < \infty$ if and only if $$\sum_{n=1}^\infty 2^n \mu(x \in X : f(x) \geq 2^n) < \infty.$$
I am having trouble thinking of where to begin in proving this result, and wanted to see if anyone visiting had some suggestions on how to proceed.
 A: This is a consequence of the following two facts, which you might wish to prove carefully:


*

*The series is the integral of the function $g=\sum\limits_{n\geqslant1}2^n\mathbf 1_{A_n}$ with $A_n=\{f\geqslant 2^n\}$.

*One has $\frac12g\leqslant f\leqslant2+g$ and the function $2$ is integrable.

A: Warning: The following may contain errors since I myself is learning measure theory at the moment. I have just mentioned what I think are the basic ideas bellow. Thus if you wish you can fill in the details your self. 
For one of the directions you can use: 
We see that if $∫fdμ<∞$ holds then by markovs inequality we have $2^nμ(x∈X:f(x)≥2^n)\leq ∫fdμ<∞$ for every $n$. Hence $μ(x∈X:f(x)≥2^n)\rightarrow 0$ as $n\rightarrow 0$. Now applying abels criterium of convergence for series it follows that the series converges. 
For the reverse note that if the series converges then $μ(x∈X:f(x)≥2^n)\rightarrow 0$ as $n\rightarrow 0$. Now define $A_n:=\{x \in X | f(x)\geq2^n\}$ use downward monotone convergence of measures on these sets to conclude that the set $\{f=\infty\}$ has measure zero. Now since $\mu(X/\cap _nA_n) =\mu(X)<\infty$ and $f(x)$ is finite on $X/\cap _nA_n$ the claim follows. 
A: It makes much more sense if you draw a topographic picture. If we define $A_n = \{x\in X\ |\ f(x)\geq 2^n\}$ and $A_0 = X$, then we can write X as a disjoint union $\displaystyle X = \bigsqcup_{n=1}^{\infty} (A_{n-1}\setminus A_n)$.
Consequently, 
$$
\int_X f d\mu = \sum_{n=1}^{\infty} \int_{A_{n-1}\setminus A_n} f d\mu
$$
For the "only if" part, observe that
$$
\displaystyle \int_X f d\mu \geq \sum_{n=1}^{\infty} \int_{A_{n}\setminus A_{n+1}} f d\mu \geq \sum_{n=1}^{\infty} 2^n(\mu(A_n) - \mu(A_{n+1})) = \mu(A_1) + \sum_{n=1}^{\infty} 2^{n-1} \mu(A_n)
$$
For the "if" part, observe that
$$
\displaystyle \int_X f d\mu = \sum_{n=1}^{\infty} \int_{A_{n-1}\setminus A_n} f d\mu \leq \sum_{n=1}^{\infty} 2^n \mu(A_{n-1}) = 2\mu(X) + 2\sum_{n=1}^{\infty} 2^n \mu(A_n)
$$ 
