Using moment generating function to calculate expectation of a random variable I'm having difficulties with a statistics problem on the book Rice - Mathematical statistics regarding moment generating function. I was given a random variable $X$ and i derived that the first order derivative of mgf of $X$ is 
$$M'(t) =  2(e^t/t - 2e^t/t^2 + 2e^t/t^3 -2/t^3)$$
To calculate the $E(X)$, I have to plug in $t=0$ into $M'(t)$. However since the terms have t as denominator, I cannot simply plug in $t=0$.
I have seen solution online that takes the limit of $t$ approaching $0$ of the function $M'(t)$ instead to calculate $M'(0)$.
But I don't understand why so. Can someone please help me?

 A: By definition 
\begin{aligned}M_{X}(t):=\mathbb {E} (e^{t\,X})&=1+t\,\mathbb {E} (X)+{\frac {t^{2}\,\mathbb {E} (X^{2})}{2!}}+{\frac {t^{3}\,\mathbb {E} (X^{3})}{3!}}+\cdots +{\frac {t^{n}\,\mathbb {E} (X^{n})}{n!}}+\cdots\end{aligned} and therefore it is defined and (differentiable) for every $t\in \mathbb R$. But instead of writing the $M_X$ like that, just use your formula and take the limit as $t\to 0$. You just do not have to worry whether the limit exists or not. It does exist, by the definition, for $M$ as well as for $M'$ (or any higher derivative).

Edit: For $f_X(x)=2x\cdot \mathbf 1_{\{0\le x\le 1\}}$, the definition of the MGF gives for any $t\in \mathbb R$ 
\begin{align}M_X(t)&=\mathbb E[e^{tX}]=\int_{\mathbb R}e^{tx}f_X(x)dx=\int_{\mathbb R}e^{tx}2x\cdot \mathbf 1_{\{0\le x\le 1\}}dx\\[0.4cm]&=\int_{0}^12x\cdot e^{tx}dx=\dots\overset{t\neq0}=\frac{2(e^t(t-1)+1)}{t^2}\end{align}So, somewhere we divided with $t$ and we excluded the case $t=0$. Obviously, before the calculation of the integral $$M_X(0)=\int_{\mathbb R}1\cdot f_X(x)dx=1$$ Hence, for $t\neq0$ $$M'_X(t)=\frac{2e^t(t^2-2t+2)-4}{t^3}=2\left(\frac{e^t}{t}-\frac{2e^t}{t^2}+\frac{2e^t}{t^3}-\frac{2}{t^3}\right)$$ hence your expression is correct! Now, \begin{align}\lim_{t\to0}M'_X(t)&\overset{\frac{\infty}{\infty}}=^{\text{L'Hopital}}\lim_{t\to 0}\frac{(2e^t(t^2-2t+2)-4)'}{(t^3)'}\\[0.2cm]&=\lim_{t\to 0}\frac{2e^t(t^2-2t+2)+2e^t(2t-2)}{3t^2}\\[0.2cm]&=\lim_{t\to 0}\frac{2e^t t^2}{3t^2}=\lim_{t\to 0}\frac23e^t=\frac23\end{align}
