For a nonnegative random variable $$E[X]=\int_0^\infty P(X >x)dx$$
This video on a question from IIT JAM 2023 extends it to $$E[X^2]=\int_0^\infty 2x P(X >x)dx$$
How was the result was arrived at? Where can I get references for such results? Books or structured references (rather than single links preferred).
$$E[X^2]=\int_0^\infty P(X^2 >x)dx=\int_0^\infty P(X>\sqrt{x})dx$$
Substitute $t=\sqrt{x}\implies t^2 =x\implies 2t\text{ } dt=dx$ $$=\int_0^\infty P(X>t) \text{ } 2t \text{ }dt$$
And since the variable of integration is a dummy variable, change back to $x$: $$=\int_0^\infty 2x P(X >x)dx$$