Identity for expected value of a discrete random variable involving higher powers I want to prove the following identity:
$$
\sum^{\infty}_{i=1}i^2P(X\geq i)=\dfrac{E(X^3)}{3}+\dfrac{E(X^2)}{2}+\dfrac{E(X)}{6}
$$
where $X$ is a discrete random variable with positive integer values.
I tried to use $E(X^n)=\sum_i i^nP(X=i)$ and I also know that $E(X)=\sum_i P(X\geq i)$ but so far I got nothing.
 A: The idea is similar to that of the proof of $\mathbb{E}[X]=\sum_{n=1}^\infty \mathbb{P}\{ X\geq n \}$ . Namely, the crux is to rewrite $\mathbb{P}\{ X\geq n \} = \sum_{\ell=n}^\infty \mathbb{P}\{X=\ell\}$, and then to swap the inner and outer sums in $\sum_{n=1}^\infty\sum_{\ell=n}^\infty$.
Specifically: rewrite
$$\begin{align}
\sum_{n=1}^{\infty}n^2\mathbb{P}\{X\geq n\}
&= \sum_{n=1}^{\infty}\sum_{\ell=n}^\infty n^2\mathbb{P}\{X=\ell\}
= \sum_{\ell=1}^\infty\sum_{n=1}^{\ell} n^2 \mathbb{P}\{X=\ell\}
\\
&= \sum_{\ell=1}^\infty \mathbb{P}\{X=\ell\}  \sum_{n=1}^{\ell} n^2
= \sum_{\ell=1}^\infty \mathbb{P}\{X=\ell\}\cdot \frac{\ell(\ell+1)(2\ell+1)}{6} \\
&= \mathbb{E}\left[ \frac{X(X+1)(2X+1)}{6} \right]
\end{align}$$
where we used the known identity $\sum_{n=1}^N n^2 = \frac{N(N+1)(2N+1)}{6}$.
Now, expand $\frac{X(X+1)(2X+1)}{6}$ and use linearity of expectation:
$$\begin{align}
\mathbb{E}\left[ \frac{X(X+1)(2X+1)}{6} \right]
&= \mathbb{E}\left[ \frac{2X^3+3X^2+X}{6} \right]
= \mathbb{E}\left[ \frac{X^3}{3}+\frac{X^2}{2}+\frac{X}{6} \right]
\\
&=  \frac{\mathbb{E}[X^3]}{3}+\frac{\mathbb{E}[X^2]}{2}+\frac{\mathbb{E}[X]}{6}
\end{align}$$
