Derivation of the expectation of exponential random variable I am following some course notes for the expectation of an exponential random variable, $X \sim \text{Expon}(\mu)$. I believe this is a correct derivation:
$$
\begin{align}
\mathbb{E}[X]
&= \int_{0}^{\infty} x \mu e^{-\mu x} dx
\\\\
&= \mu \int_{0}^{\infty} x e^{-\mu x} dx
\\\\
&= \mu \int_{0}^{\infty} \frac{d}{d \mu} -e^{-\mu x} dx
\\\\
&= -\mu \frac{d}{d \mu} \int_{0}^{\infty} e^{-\mu x} dx
\\\\
&= -\mu \frac{d}{d \mu} \frac{1}{\mu}
\\\\
&= \frac{1}{\mu}
\end{align}
$$
where we used the facts that
$$
x e^{-\mu x} = \frac{d}{d \mu} - e^{-\mu x}
$$
and
$$
\int_{0}^{\infty} e^{-\mu x} dx = \frac{1}{\mu}
$$
What I don't follow is the second fact. I would have used calculus rules to compute
$$
\int_{0}^{\infty} e^{-\mu x} dx = \frac{1}{- \mu} e^{- \mu x} + C
$$
What am I missing?
 A: This is just a formal summary of my comments above, with some detail. Recall the difference between an indefinite integral $\int f(x)dx$ and definite integral $\int_a^bf(x)dx$.


*

*Indefinite integral:  $\int e^{-\mu x}dx = \frac{-1}{\mu} e^{-\mu x} + c$

*Definite integral : $\int_a^b e^{-\mu x}dx = (\frac{-1}{\mu} e^{-\mu x} + c)|_a^b = \frac{-1}{\mu}e^{-\mu b} - \frac{-1}{\mu}e^{-\mu a}$
Notice that the $+c$ cancels out when taking the difference.  So we can use any antiderivative and we might as well use $c=0$.

On computing $E[X]$ via integration by parts: 
$$\frac{d}{dx} [f(x)g(x)] = f'(x)g(x) + f(x)g'(x) \implies \boxed{\int_a^b f(x)g'(x)dx = f(x)g(x)|_a^b - \int_a^b f'(x)g(x)dx}$$
So
$$ E[X]=\int_0^{\infty} \underbrace{x}_{f(x)} \underbrace{\mu e^{-\mu x}}_{g'(x)}dx = f(x)g(x)|_0^{\infty} - \int_0^{\infty} \underbrace{f'(x)}_{1}\underbrace{g(x)}_{-e^{-\mu x}}dx $$
and 
$$ f(x)g(x)|_0^{\infty} = (-xe^{-\mu x})|_0^{\infty} = \left(\lim_{b\rightarrow\infty} -be^{-\mu b}\right) - 0 = 0$$
