Integration of function help I'm having problems integrating this function $\displaystyle E(X)=\int^ \infty_0 x\lambda e^{-\lambda x} dx$. I did the integration by parts and had $-xe^{-\lambda x}- \lambda e^{-\lambda x}$. However the solution gives $-xe^{-\lambda x} - \dfrac{1}{\lambda}e^{-\lambda x}$. I can't find any mistakes. What am I doing wrong?
 A: Consider $$\begin{align*}\int\lambda xe^{-\lambda x}\,\mathrm{d}x&=\lambda\int\underbrace{x}_u\,\underbrace{e^{-\lambda x}\,\mathrm{d}x}_{\mathrm{d}v}\\&=\lambda\left(-\frac1\lambda xe^{-\lambda x}+\frac1\lambda\int e^{-\lambda x}\,\mathrm{d}x\right)\\&=\lambda\left(-\frac1\lambda xe^{-\lambda x}-\frac1{\lambda^2}e^{-\lambda x}\right)\\&=-e^{-\lambda x}\left(x+\frac1\lambda\right)\end{align*}$$... and so$$\begin{align*}\int_0^\infty\lambda xe^{-\lambda x}\,\mathrm{d}x&=\lim_{c\to\infty}\int_0^c\lambda xe^{-\lambda x}\,\mathrm{d}x\\&=\lim_{c\to\infty}\left[-e^{-\lambda x}\left(x+\frac1\lambda\right)\right]_0^c\\&=\lim_{c\to\infty}\left(-e^{-\lambda c}\left(c+\frac1\lambda\right)+\frac1\lambda\right)\\&=\frac1\lambda\end{align*}$$
A: Integrating by parts using $u=x \Rightarrow du=dx$ and $dv= e^{-\lambda x} dx \Rightarrow v = \dfrac{e^{-\lambda x}}{-\lambda}$, we have 
$$\begin{align}
\int x\lambda e^{-\lambda x} dx & = \lambda \int x e^{-\lambda x} dx \\
& = \lambda \left [\frac{xe^{-\lambda x}}{-\lambda} - \int \frac{e^{-\lambda x}}{(-\lambda)} dx\right] \\
& = \lambda \left [\frac{-xe^{-\lambda x}}{\lambda} + \int \frac{e^{-\lambda x}}{\lambda} dx\right] \\
& = \lambda \left [\frac{-xe^{-\lambda x}}{\lambda} + \frac{e^{-\lambda x}}{\lambda(-\lambda)} dx\right] \\
& = \lambda \left [\frac{-xe^{-\lambda x}}{\lambda} - \frac{e^{-\lambda x}}{\lambda^2} \right] \\
& = -xe^{-\lambda x} - \frac{e^{-\lambda x}}{\lambda}. \\
\end{align}$$
Therefore we have
$$\begin{align}
\int_0^\infty x\lambda e^{-\lambda x} dx & = \left[-xe^{-\lambda x} - \frac{e^{-\lambda x}}{\lambda}\right]_0^\infty \\
& = \left[\left(0 - 0\right) - \left(0 - \frac{1}{\lambda}\right) \right] \\
& = \frac{1}{\lambda}.
\end{align}$$
A: $\displaystyle  \int x\lambda e^{-\lambda x} dx$
$\displaystyle \lambda\int x e^{-\lambda x} dx$
Integrating by parts we have
$\displaystyle \lambda \left(x\int  e^{-\lambda x} dx-\int\dfrac{dx}{dx}\left(\int  e^{-\lambda x} dx\right) dx\right)$
$\displaystyle \lambda \left(\frac{xe^{-\lambda x}}{-\lambda}-\int \frac{e^{-\lambda x}}{-\lambda} dx\right)$
$\displaystyle -xe^{-\lambda x}+\int e^{-\lambda x} dx$
$\displaystyle -xe^{-\lambda x}+\frac{e^{-\lambda x}}{-\lambda}$
$\displaystyle -xe^{-\lambda x}-\frac{e^{-\lambda x}}{\lambda}$
