Solve Integration area I am confused why the answer for $$\int_0^{\infty}\left(x-\frac{1}{\lambda}\right)^2\lambda e^{-\lambda x}\ dx$$
  is $$\frac{1}{\lambda^2}$$
I get mine as $$\frac{5}{\lambda^2}$$
Official answer is as follows 

but I do not get the last part when it is $$\frac{-2}{\lambda^2}$$
 instead of $$\frac{2}{\lambda^2}$$
My working for the step before is as follows
f(x) = 2x-2 \quad
f'(x) = 2 \quad
g(x) = -(e^-λx)/λ \quad
g'(x)= e^-λx
Essentially, it means Area f(x)g(x) - Integral f'(x)g(x)dx. Why is it -2/λ when f'(x)g(x) = -2(e^-λx)/λ and I take -2/λ out of the integral to make it 
2/λ∫(e^-λx)20dx
 A: $$\int_0^{\infty}\left(x-\frac{1}{\lambda}\right)^2\lambda e^{-\lambda x}\ dx$$
  is $$=\lambda \int_0^{\infty}x^2e^{-\lambda x}dx~~+\dfrac {1}{\lambda} \left (\int_0^{\infty}e^{-\lambda x}dx\right)~~-2\int_0^{\infty}xe^{-\lambda x}dx$$
$$=\dfrac {2}{\lambda^2}~~+\dfrac {1}{\lambda^2}~~-\dfrac {2}{\lambda^2}=\dfrac {1}{\lambda^2}$$
Using $\Gamma (\alpha)=\int_0^{\infty}x^{\alpha-1}e^{-x}dx $
A: In your deduction:
$$
f = (x - {1\over \lambda})^2\lambda \qquad {\rm and}\qquad g' = \lambda e^{-\lambda x}.
$$
Then
$$
f' = 2(x-{1\over\lambda})\lambda\qquad{\rm and}\qquad g = -{1\over\lambda} e^{-\lambda x}.
$$
So, when you compute $\int f'g$ you should get 
$$
\int2(x-{1\over\lambda})\lambda\cdot(-{1\over\lambda} e^{-\lambda x})\, dx =
-\int2(x-{1\over\lambda})\lambda e^{-\lambda x}\, dx.
$$
with a minus sign in front of the integral.
A: i would write $$(x-1/\lambda)^2\lambda e^{-\lambda x}=\left(x^2\lambda-2x+\frac{1}{\lambda}\right)e^{-\lambda x}=x^2\lambda e^{-\lambda x}-2xe^{-\lambda x}+1/\lambda e^{-\lambda x}$$ 
and the indefinite integrals are given by
$$\frac{1}{3} \lambda  e^{-\text{$\lambda $x}} x^3$$
$$\frac{2 e^{\lambda  (-x)} (\lambda  x+1)}{\lambda ^2}$$
$$-\frac{e^{\lambda  (-x)}}{\lambda ^2}$$
please check this and then will i post the definite integrals
A: It is because $\int_0^{\infty}e^{-\lambda x}dx = \bigg[\frac{e^{-\lambda x}}{-\lambda}\bigg]_0^{\infty}=\frac{0}{-\lambda} - \frac{1}{-\lambda}=\frac{1}{\lambda}$
So in the last row:
$$2\int_0^{\infty}xe^{-\lambda x}dx = \frac{2}{\lambda^2}$$
$$-\frac{2}{\lambda}\int_0^{\infty}e^{-\lambda x}dx = -\frac{2}{\lambda^2}$$
A: The last integral is
$$-\frac{2}{\lambda} \int_0^{\infty} e^{-\lambda x}\; dx  = \left.\frac{-2}{\lambda} \frac{e^{-\lambda x}}{-\lambda} \right|_{0}^{\infty} = \frac{2}{\lambda^2} \left(e^{-\infty} - e^0 \right) = \frac{2}{\lambda^2}(0-1) = -\frac{2}{\lambda^2} .$$
A: $$
\begin{align}
\int_0^\infty\left(x-\frac1\lambda\right)^2\lambda e^{-\lambda x}\,\mathrm{d}x
&=\frac1{\lambda^2}\int_0^\infty(x-1)^2e^{-x}\,\mathrm{d}x\\
&=\frac1{\lambda^2}\int_0^\infty\left(x^2-2x+1\right)e^{-x}\,\mathrm{d}x\\
&=\frac1{\lambda^2}(2!-2\cdot1!+0!)\\
&=\frac1{\lambda^2}
\end{align}
$$
Where we've used
$$
\int_0^\infty x^ne^{-x}\,\mathrm{d}x=n!
$$
which can be proven by induction and integration by parts.
