Change of Variables in Second Moment $X$ is a non-negative continuous random variable with pdf $f(x)$. 
$G(t) = \int_{t}^\infty f(x) dx$. Show that $$E[X^2] = 2 \int_{0}^\infty tG(t) dt$$.  
I tried to write out E[X^2] (second moment of X) and see if that corresponds to the G(t) equation. I wasn't able to do that well because I wasn't sure of how the change of variables works.  
 A: I'm assuming $E[X^2] < \infty$. Integration by parts gives
$$2\int_0^b t\, G(t)\, dt = b^2 G(b) - \int_0^b t^2 G'(t)\, dt = b^2 G(b) + \int_0^b t^2 f(t)\, dt.$$ 
Taking the limit as $b \to \infty$ results in 
$$2\int_0^\infty t G(t)\, dt = \int_0^\infty t^2 f(t)\, dt = E[X^2].$$
To see that $\lim\limits_{b\to \infty} b^2 G(b) = 0$, note that for $b > 0$,
$$E[X^2]  = \int_0^b x^2 f(x)\, dx + \int_b^\infty x^2 f(x)\, dx \ge \int_0^b x^2 f(x)\, dx + b^2 G(b).$$
So 
$$0 \le b^2 G(b) \le E[X^2] - \int_0^b x^2 f(x)\, dx.$$
The right-hand side tends to $0$ as $b\to \infty$, so $\lim\limits_{b\to \infty} b^2 G(b) = 0$.
A: Write $x^2=\int_{t=0}^x 2 t\,dt$ and then interchange the order of integration:
$$
\begin{align}
E(X^2)&=
\int_{x=0}^\infty \left(\int_{t=0}^x 2 t\,dt \right)f(x)\,dx\\
&=\int_{x=0}^\infty \left(\int_{t=0}^x 2 tf(x)\,dt\right)\,dx\\
&=\int_{t=0}^\infty \left(\int_{x=t}^\infty 2 tf(x)\,dx\right)\,dt\\
&=\int_{t=0}^\infty 2t\left(\int_{x=t}^\infty f(x)\,dx\right)\,dt
\end{align}
$$
Another example of this approach can be seen in this answer.
