TITLE: How this integral $ \int_0^z\frac{1-e^x}{x} dx$ is connected to the Gamma function and Euler constant?
QUESTION [13 upvotes]: This is my first question in this forum; I hope it is an appropriate question.
The Wolframalpha website tells me that
$$
\int\nolimits_0^z\frac{1-e^x}{x} dx = \log (-z)+\Gamma(0, -z)+\gamma\quad \text{for}\quad \Re(z)<0.
$$
I tried to prove this for myself, but I would appreciate it if you could give 
me some help.
This is not a homework question, and I would appreciate it if someone could point me to a reference or tell me what you expect to happen when $ℜ(z)>0$.
Thanks.

REPLY [11 votes]: I believe that this works for both positive and negative $z$.
By definition and  change of variables
$$
\Gamma(0,-z)=\int_{-z}^\infty e^{-x}\frac{\mathrm{d}x}{x}=-\int_{-\infty}^z e^x\frac{\mathrm{d}x}{x}\tag{1}
$$
where the principal value is taken where needed. Applying $(1)$ to the integral from $w$ to $z$:
$$
\int_w^z\frac{1-e^x}{x}\mathrm{d}x=\log|z|-\log|w|+\Gamma(0,-z)-\Gamma(0,-w)\tag{2}
$$
According to $(2)$,
$$
\int_0^z\frac{1-e^x}{x}\mathrm{d}x=\log|z|+\Gamma(0,-z)-C\tag{3}
$$
where
$$
C=\lim_{w\to0}(\log|w|+\Gamma(0,|w|))\tag{4}
$$
We can use $\Gamma(0,|w|)$ in $(4)$ since either $\Gamma(0,w)$ or $\Gamma(0,-w)$ is defined by a principal value integral, so we have
$$
\lim_{w\to0}(\Gamma(0,-w)-\Gamma(0,w))=0
$$
Therefore,
$$
\begin{align}
C
&=\lim_{w\to0}(\log|w|+\Gamma(0,|w|))\\
&=\lim_{w\to0}\left(\log|w|+\int_{|w|}^\infty e^{-x}\frac{\mathrm{d}x}{x}\right)\\
&=\lim_{w\to0}\left(\log|w|-\log|w|\;e^{-|w|}+\int_{|w|}^\infty\log(x)e^{-x}\mathrm{d}x\right)\\
&=\int_0^\infty\log(x)e^{-x}\mathrm{d}x\\
&=-\gamma\tag{6}
\end{align}
$$
where $\gamma$ is the Euler-Mascheroni Constant. Combining $(3)$ and $(6)$, we get
$$
\int_0^z\frac{1-e^x}{x}\mathrm{d}x=\log|z|+\Gamma(0,-z)+\gamma\tag{7}
$$
If there is interest, I can append a proof that $\int_0^\infty\log(x)e^{-x}\mathrm{d}x=-\gamma$.