I need to show that $$ \sum^{\infty}_{m=1} \frac{1}{m} \frac{(-x)^m}{m!} = Ei(-x)-\ln(x)-\gamma, \qquad (1)$$ where $x>0$, (thus) $Ei(-x)=-\displaystyle \int^{\infty}_{x} \frac{e^{-t}}{t}dt$, and $\gamma$ is the Euler-Mascheroni constant. Obtaining the first two terms is not difficult (shown below), but I am not sure how to get the Euler's constant. I did not know that the constant should be $\gamma$ until I asked wolfram alpha. Here I include what I have done to get the first two terms in (1): Let \begin{equation} f(x):= \sum^{\infty}_{m=1} \frac{1}{m} \frac{(-x)^m}{m!} \qquad (2) \end{equation} Thus $$\frac{df}{dx} = - \sum^{\infty}_{m=1} \frac{(-x)^{m-1}}{m!} = \frac{1}{x} \sum^{\infty}_{m=1} \frac{(-x)^{m}}{m!} = \frac{1}{x} \left( \sum^{\infty}_{m=0} \frac{(-x)^{m}}{m!} -1 \right) = \displaystyle \frac{e^{-x}-1}{x} $$ Thus
$$f(x) = \int^{x}_{a} \frac{e^{-t}-1}{t} dt, \qquad (3)$$ for a well-chosen number $a$ which ensures that the integral in (3) represents the sum in (2). My main question is what is the criteria to correctly choose a? In fact integrating (3) yields
$$ f(x) = - \int^{a}_{x} \frac{e^{-t}}{t}\,dt - \ln(x) - \ln(a) = - \left( \int^{\infty}_{x} \frac{e^{-t}}{t}\,dt - \int^{\infty}_{a} \frac{e^{-t}}{t}\,dt \right) - \ln(x) - \ln(a) = $$ $$ Ei(-x)-\ln(x) - Ei(-a) - \ln(a) $$ So I do get the first two terms in (1) but I do not know why/how I should get the Euler's constant. I appreciate any help.
Using the power series of $e^x$, we get $$ -\int_0^x\frac{1-e^{-t}}t\,\mathrm{d}t=\sum_{n=1}^\infty\frac1n\frac{(-x)^n}{n!}\tag1 $$ Since $$\newcommand{\Ei}{\operatorname{Ei}} \Ei(-x)=-\int_x^\infty\frac{e^{-t}}t\,\mathrm{d}t\tag2 $$ we have $$ \begin{align} \sum_{n=1}^\infty\frac1n\frac{(-x)^n}{n!} &=\color{#C00}{-\int_0^x\frac{1-e^{-t}}t\,\mathrm{d}t}+\overbrace{\color{#090}{\int_x^\infty\frac{e^{-t}}t\,\mathrm{d}t}+\Ei(-x)}^0\tag3\\ &=\color{#C00}{-\int_0^1\frac{1-e^{-t}}t\,\mathrm{d}t-\int_1^x\frac{1-e^{-t}}t\,\mathrm{d}t}\\ &+\color{#090}{\int_1^\infty\frac{e^{-t}}t\,\mathrm{d}t-\int_1^x\frac{e^{-t}}t\,\mathrm{d}t}+\Ei(-x)\tag4\\ &=\underbrace{\color{#C0F}{-\int_0^1\frac{1-e^{-t}}t\,\mathrm{d}t+\int_1^\infty\frac{e^{-t}}t\,\mathrm{d}t}}_{-\gamma}-\log(x)+\Ei(-x)\tag5 \end{align} $$ Explanation:
$(3)$: combine $(1)$ and $(2)$
$(4)$: split the red and green integrals into two pieces each
$(5)$: the sum of the rightmost red and green integrals is $-\log(x)$
and since $$ \begin{align} \color{#C0F}{-\int_0^1\frac{1-e^{-t}}t\,\mathrm{d}t+\int_1^\infty\frac{e^{-t}}t\,\mathrm{d}t} &=\lim_{\delta\to0^+}\left[-\int_0^1\left(1-e^{-t}\right)t^{\delta-1}\,\mathrm{d}t+\int_1^\infty e^{-t}t^{\delta-1}\,\mathrm{d}t\right]\tag6\\ &=\lim_{\delta\to0^+}\left[-\int_0^1t^{\delta-1}\,\mathrm{d}t+\int_0^\infty e^{-t}t^{\delta-1}\,\mathrm{d}t\right]\tag7\\ &=\lim_{\delta\to0^+}\left[-\frac1\delta+\frac{\Gamma(1+\delta)}\delta\right]\tag8\\[6pt] &=\Gamma'(1)\tag9\\[12pt] &=-\gamma\tag{10} \end{align} $$ Explanation:
$\phantom{1}(6)$: write $1/t$ as $\lim\limits_{\delta\to0^+}t^{\delta-1}$
$\phantom{1}(7)$: combine the integrals of $e^{-t}t^{\delta-1}$
$\phantom{1}(8)$: evaluate the integrals; $\Gamma(\delta)=\Gamma(1+\delta)/\delta$
$\phantom{1}(9)$: since $\Gamma(1)=1$, this follows from the definition of derivative
$(10)$: there are a couple of proofs that $\Gamma'(1)=-\gamma$ in this answer
we get $$ \bbox[5px,border:2px solid #C0A000]{\sum_{n=1}^\infty\frac1n\frac{(-x)^n}{n!}=\Ei(-x)-\log(x)-\gamma}\tag{11} $$