Show that $\mathbb{E}\left(X^{r}\right)=\int_{0}^{+\infty} r x^{r-1} \mathbb{P}(X>x) d x$ I'm trying to solve this exercise in the introductory probability course:



My attempt:
Let $F(x)$ be the c.d.f of $X$. We have $$\begin{aligned} \mathbb E(X^r) &= \int_{\mathbb R} x^r f(x) \, \mathrm{d}x \quad = \quad \ \int_0^\infty x^r f(x) \, \mathrm{d}x \\ &= \int_0^\infty x^r \, \mathrm{d} F(x) \quad = \quad \int_0^\infty x^r \, \mathrm{d} (1-\mathbb P(X>x)) \\ &= x^r(1-\mathbb P(X>x)) \Big|_0^{\infty} - \int_0^\infty rx^{r-1}(1-\mathbb P(X>x)) \, \mathrm{d}x \\ &= x^r \mathbb P(X\le x) \Big|_0^{\infty} - \int_0^\infty(rx^{r-1} - rx^{r-1} \mathbb P(X>x))\, \mathrm{d}x \\&= x^r \mathbb P(X\le x) \Big|_0^{\infty} - x^r  \Big|_0^{\infty} + \int_0^\infty rx^{r-1} \mathbb P(X>x)\, \mathrm{d}x \\ &= (x^r \mathbb P(X\le x) - x^r) \Big|_0^{\infty} + \int_0^\infty rx^{r-1} \mathbb P(X>x)\, \mathrm{d}x\end{aligned}$$
I'm stuck at proving $(x^r \mathbb P(X\le x) - x^r) \Big|_0^{\infty} =0$, i.e. $\lim_{x \to \infty} x^r(P(X\le x) -1) = 0$.
Could you please shed me some light?
 A: As another proof you can do this.
$$\int_{0}^{\infty} rx^{r-1}P(X>x) dx$$ $$=\int_{0}^{\infty} \int1_{\{X>x\}}(y)rx^{r-1}dP(y)dx$$ $$=^{TONELLI }\int \int_{0}^{
X(y)}  rx^{r-1}dxdP(y) =\int X^r(y)dP(y)$$
A: For your specific question, notice that
$$ 0 \leq x^r (1 - \mathbb{P}(X \leq x)) = x^r \mathbb{P}(X \geq x) = x^r \int_{x}^{\infty} f(s) \mathrm{d}s \leq \int_{x}^{\infty} s^r f(s) \mathrm{d}s. $$
Since we know that $\mathbb{E}[X^r] = \int_{0}^{\infty} s^r f(s) \, \mathrm{d}s$ is finite, it follows that $\int_{x}^{\infty} s^r f(s) \mathrm{d}s \to 0$ as $x\to\infty$. So, the quantity in question vanishes as $x\to\infty$.

For a more systematic approach, we can utilize Tonelli's theorem. (This is exactly as in @Marios Gretsas's answer, but let met recap the argument for the sake of self-containedness.)
Tonelli's theorem asserts the following: For the iterated integral of a non-negative function, we can always interchange the order of integration regardless of its finiteness. So, for any non-negative random variable $X$ and for any $r > 0$,
\begin{align*}
\mathbb{E}[X^r]
= \mathbb{E}\bigg[ \int_{0}^{X} rx^{r-1} \, \mathrm{d}x \bigg]
&= \mathbb{E}\bigg[ \int_{0}^{\infty} rx^{r-1} \mathbf{1}( x < X ) \, \mathrm{d}x \bigg] \\
&= \int_{0}^{\infty} rx^{r-1} \mathbb{E}\big[ \mathbf{1}( x < X ) \big] \, \mathrm{d}x \tag{Tonelli}\\
&= \int_{0}^{\infty} rx^{r-1} \mathbb{P}(X > x) \, \mathrm{d}x.
\end{align*}
Neither density assumption nor finiteness of $r$-th moment is used here.
A: You need to be careful here not to use $\infty-\infty$ gymnastics. The survival function $S(x):=\Bbb P(X>x)$ satisfies $S^\prime=-f(x)$, so $$\Bbb E(X^r)-\int_0^\infty rx^{r-1}S(x)dx=-\int_0^\infty(x^rS^\prime+(x^r)^\prime S)dx=[-x^rS]_0^\infty=-\lim_{x\to\infty}x^rS(x).$$That just leaves proving this limit is $0$.
