Proving Lebesgue Integral Equality I would love some help with this problem: 
Let $(X,\mathcal F,\mu)$ be a measurable space and let $f:X\to[0,\infty)$ be a positive Lebesgue integrable function.  Prove that $$\int_X fd\mu = \int_0^\infty \mu(\{x\in X : f(x) > \lambda\})d\lambda.$$
I understand why this works geometrically in two dimensions but am not really sure how to go about showing this formally. I believe a good method would be to show the equality for step functions and then somehow generalize, but I'm not sure exactly how to do this either.
I'd appreciate any help.
Thanks! 
 A: You can write
$$ f(x) = \int_0^{f(x)} \, dt = \int_0^{\infty} 1_{ \{y: f(y)>t \} }(x) \, dt, \tag{1} $$
because $1_{ \{y: f(y)>t \} }(x)$ is $1$ for $t$ between $0$ and $f(x)$ and $0$ otherwise. Now, you use Tonelli's theorem, which says that 

If $f:X \times Y \to [0,\infty)$, then
  $$ \int_{X \times Y} f(x,y) \, d\mu(x) \times d\nu(y) = \int_X \left( \int_Y f(x,y) \, d\nu(y) \right) \, d\mu(x) = \int_Y \left( \int_X f(x,y) \, d\mu(x) \right) \, d\nu(x), $$
  in the sense that the integrals all either exist have the same value, or all diverge.

In this case, take $Y=[0,\infty)$, $\nu$ normal Lebesgue measure, and then you have
$$ \int_X f(x) \, d\mu(x) = \int_X \left( \int_0^{\infty} 1_{ \{y: f(y)>t \} }(x) \, dt \right) \, d\mu(x) \\
= \int_0^{\infty} \left( \int_X 1_{ \{y: f(y)>t \} }(x) \, d\mu(x) \right)  \, dt \\
= \int_0^{\infty} \mu\{ y:f(y)>t\} \, dt,
$$
using the equality (1), then Tonelli, and lastly the definition of the integral of a characteristic function.
A: The following more general identity holds:

For $ f \in L^p(X), \quad  0 < p < \infty $ we have:
$$ ||f ||_p^p = p \int_0^{\infty} \lambda^{p-1} d_f ( \lambda )
 \text{d} \lambda $$
where $ \displaystyle  d_f ( \lambda ) = \mu \left( \{x \in X : | f(x)
 | > \lambda \} \right) $

Proof: Using Fubini's theorem http://en.wikipedia.org/wiki/Fubini%27s_theorem we have:
$ \displaystyle p \int_0^{\infty} \lambda^{p-1} d_f( \lambda) d \lambda = p \int_0^{\infty} \lambda^{p-1} \int_X \chi_{ \{x: |f(x)| > \lambda \} } d \mu (x) d \lambda= \int_X \int_0^{|f(x)|} p \lambda^{p-1} d \lambda d \mu(x)= $
$\displaystyle = \int_X |f(x)|^p d \mu (x)= ||f||_p^p $  
A: You can prove that the integrand on the right, let me call it $F$, is actually a Riemann integrable function on compact intervals. There are various ways to prove this, but they all hinge on the fact that $F$ is monotone.
As such you can write the right side as $\lim_{n \to \infty} I_n$ where $I_n$ is a Riemann sum for integrating $F \chi_{[0,n]}$. This Riemann sum is the Lebesgue integral of a certain simple approximation of $f$. (Essentially it is the simple approximation where the range of $f$ on $[m/n,(m+1)/n]$ is counted as $m/n$ for $m=0,1,\dots,n^2-1$ and the range of $f$ on $[n,\infty)$ is counted as $n$.) Now you just need to prove that this simple approximation converges in $L^1$.
