A question on measure space and measurable function 
Let $(X,\mu)$ be a measure space, and $\mu(X)< + \infty$. Let $f$ be a nonnegative measurable function on $X$ and $E_n = \{x \in X|f(x) \geq n \}$. Then $\int_X f^2d \mu < + \infty$ if and only if $\sum_{n=1}^{\infty} n \mu(E_n) <+\infty$.

Do I have to use simple functions that converge to $f$?
Thanks a lot.
 A: First we use that
$$
\int_X g\,\mathrm d\mu=\int_0^\infty \mu\left(\{g\geq t\}\right)\,\lambda(\mathrm dt)
$$
for any non-negative measurable function $g$. Using this with $g=f^2$ we get
$$
\int_X f^2\,\mathrm d\mu=\int_0^\infty \mu\left(\{f\geq \sqrt{t}\}\right)\,\lambda(\mathrm dt)=2\int_0^\infty x\cdot \mu\left(\{f\geq x\}\right)\,\lambda(\mathrm dx)
$$
by change of variables with $x=\sqrt{t}$.
Now $x\mapsto x\cdot \mu\left(\{f\geq x\}\right)$ is measurable and $x\mapsto \mu\left(\{f\geq x\}\right)$ is decreasing, and so
$$
\sum_{n=1}^\infty n\cdot \mu\left(\{f\geq n-1\}\right)1_{(n-1,n]}(x)\geq x\cdot \mu\left(\{f\geq x\}\right)\geq \sum_{n=1}^\infty (n-1)\cdot \mu\left(\{f\geq n\}\right)1_{(n-1,n]}(x)
$$
and integrating this with respect to $\lambda$ yields
$$
\int_0^\infty x\cdot \mu\left(\{f\geq x\}\right)\,\lambda(\mathrm d x)\leq \sum_{n=1}^\infty \left(\int_0^\infty n\cdot\mu\left(\{f\geq n-1\}\right)1_{(n-1,n]}(x)\,\lambda(\mathrm d x)\right)\\
=\sum_{n=1}^\infty n\cdot\mu\left(\{f\geq n-1\}\right)=\sum_{n=0}^\infty (n+1)\cdot\mu\left(\{f\geq n\}\right).
$$
Now this last sum is finite if and only if $\sum_{n=1}^\infty n\cdot\mu\left(\{f\geq n\}\right)<\infty$ (by the limit comparison test).
A: Forward direction:
First we note that for all n $E_{n+1} \subset E_{n}$, thus $\mu(E_n-E_{n+1})=\mu(E_{n})-\mu(E_{n+1})$. We also note that $E_n-E_{n+1}=${$x∈ X|n<f(x)\leq n+1$}, thus it follows that $E_1-E_2, E_2-E_3, E_3-E_4,...$ are disjoint measurable sets. Now define a function $g:X→R$, such that $g(x)=n$ if $x\in E_n-E_{n+1}$ and 0 otherwise, it follows easily that $g(x)\leq(f(x))^2$, therefore:
$$\int_X g d \mu \leq  \int_X f^2d \mu$$ 
Hence:
$$\sum_{n=1}^{\infty} n^2(\mu(E_n)-\mu(E_{n+1})) \leq  \int_X f^2d \mu...(1)$$ 
Now define $h_n(x)=n^2$ if $x\in E_n$ and 0 otherwise. It follows that $h_n \leq f^2$, therefore:
$$\int_X h_n d \mu \leq  \int_X f^2d \mu$$ 
Hence, we have for all n:
$$n^2\mu(E_n) \leq  \int_X f^2d \mu...(2)$$ 
Now, we use Abel's identity to deduce that:
$$\sum_{n=1}^k (n+1/2)\mu(E_{n+1})=(k+1)^2\mu(E_{k+1})/2-\mu(E_1)-\sum_{n=1}^k (n^2/2)(\mu(E_{n+1})-\mu(E_n))$$
From inequalities (1),(2) we find that the R.H.S. of the previous equation is bounded, thus the sequence of partial sums $\sum_{n=1}^k (n+1/2)\mu(E_{n+1})$ is bounded from above, hence it converges. Since, for all n $n/2<n+1/2$, thus we deduce that the sequence  $\sum_{n=1}^k (n/2)\mu(E_{n+1})$ converges. 
Backward Direction:
Using the limit comparison test, we can show that $\sum_{n=1}^{\infty} (2n+3)\mu(E_{n+1})$ converges. 
Using Abel's identity we have:
$$\sum_{n=1}^k ((n+1)^2)(\mu(E_{n+1}-\mu(E_n)))=(k+2)^2\mu(E_{k+1})/2-4\mu(E_1)-\sum_{n=1}^k (2n+3)\mu(E_{n+1})$$
Since the R.H.S is bounded therefore the series in L.H.S. converges. Now by letting $g(x)=(n+1)^2$ if $x\in E_n-E_{n+1}$ and 0 otherwise we can see that g is integrable. Since $g \leq f$, therefore $f$ is integrable.
