# If X~Exp(λ), what is the expected value of Y=X²?

I am trying to compute this using the integral definition of expected value but I don't think I am doing it right as I am getting a very hard integral that I can not solve.

When computing $\mathbb{E}[X]$, I used the formula $$\int_0^\infty x\,(1/λ)\exp\{-x/λ\}\,\text{d}x$$ and solved it using integration by parts, with $u = x$ and $dv=(1/λ)e^{-x/λ}$. But I can not figure out the integration by parts for $\mathbb{E}[X^2]$ because of the $\exp\{-x^2/λ\}$ when calculating the expected value of $Y$.

• Show what you tried so that we can identify where you went wrong. The correct integral is very easy, yielding to obvious application of routine integration methods. How did you do $E(X)$? – Glen_b May 2 '16 at 2:36
• I was doing the integral of x^2(1/λ)exp(-x^2/λ) and have no clue how to solve this. For E(X), it was easy to do because there was no x^2. – klw_123 May 2 '16 at 2:50
• If it was easy to do E(X) it should not be at all difficult for you to explain what it was you did. What approach did you use? – Glen_b May 2 '16 at 2:51
• Oh, I've just noticed that your integrand for $E(X^2)$ is wrong (please edit it into your question). How did you decide there should be an $x^2$ in the exponent? There are two ways to get $E(Y)=E(X^2)$: either find the distribution of $Y$ and then the expectation of it, or find the expectation of $X^2$ "directly". [Are you aware of the Law of the Unconscious Statistician?] – Glen_b May 2 '16 at 5:23
• @Xi'an I think that's sufficiently detailed guidance to count as an answer for this question, if you'd like to post it as one. – Glen_b May 2 '16 at 8:40

Following @Glen_b's remarks, I think your issue is less with integration than with properly defining the integral: $$𝔼[X^2]=∫^∞_0 x^2 \exp(−x/λ)/λ\,\text{d}x$$ rather than this erroneous version: $$𝔼[X^2]=∫^∞_0 x^2 \exp(−x^2/λ)/λ\,\text{d}x.$$ Once this straightened, (one or two) integration(s) by part should become obvious.