TITLE: Exponential integral: something is wrong.
QUESTION [12 upvotes]: Consider the function 
$$
E(z)=\int_{-\infty}^z\frac{e^t}{t}dt.\quad (1)
$$
Substituting $t\mapsto -u$ one obtains
$$
E(z)=-\int_{-z}^{\infty}\frac{e^{-u}}{u}du\equiv Ei(z).\quad (2)
$$
It is already surprising that the ugly definiton (2) and not (1) is usually used for $Ei(z)$. Much worser is the fact that both definitions lead to different results upon expanding the functions. For this we use the usual trick (standard branch cut along the negative real semi-axis is assumed, if necessary):
$$
Ei(z)=-\int_{-z}^{\infty}\frac{e^{-u}}{u}du
+\int_0^{-z}\frac{1-e^{-u}}{u}du-\int_0^{-z}\frac{1-e^{-u}}{u}du\\
=\left[\left.-e^{-u}\ln u\right|_{-z}^\infty-\int_{-z}^\infty e^{-u}\ln u du\right]+\left[\left.(1-e^{-u})\ln u\right|_0^{-z}-\int_0^{-z}e^{-u}\ln u du\right]+\int_0^z\frac{e^t-1}{t}dt\\
=\ln(-z)+\gamma+\sum_{n=1}^\infty\frac{z^n}{n!n}.
$$
Applying the same trick for (1) one obtains:
$$
E(z)=\int_{-\infty}^z\frac{e^{u}}{u}du-
\int_0^{z}\frac{e^{u}-1}{u}du+\int_0^{z}\frac{e^{u}-1}{u}du\\
=\left[\left.e^{u}\ln u\right|_{-\infty}^z-\int_{-\infty}^z e^{u}\ln u du\right]-\left[\left.(e^{u}-1)\ln u\right|_0^{z}-\int_0^{z}e^{u}\ln u du\right]+\int_0^z\frac{e^u-1}{u}dt\\
=\ln(z)-\int_{-\infty}^0e^u\ln u du+\sum_{n=1}^\infty\frac{z^n}{n!n}=
\ln(z)-\int_0^{\infty}e^{-t}\ln(-t)dt+\sum_{n=1}^\infty\frac{z^n}{n!n}\\
=\ln(z)-\int_0^{\infty}e^{-t}(\ln t+i\pi)dt+\sum_{n=1}^\infty\frac{z^n}{n!n}
=\ln(z)-i\pi+\gamma+\sum_{n=1}^\infty\frac{z^n}{n!n}.
$$
The problem is that the equality $\ln(-z)=\ln(z)-i\pi$ with usual restriction $-i\pi<\arg(z)\le i\pi$ is valid only in the upper complex half-plane (including the negative real semi-axis). In the lower complex half-plane (including the positive real semi-axis) the two values differs by $2\pi i$. 
Which result is correct? Where is hidden the error, resulting in the contradiction?

REPLY [2 votes]: It seems like a substitution error. Although (1) is equal to (2), when you replace t with u in the first line of the last derivation, u=-t so they are not equal. This results in an false statement when you try to set the end products equal to each other because the variables are used inconsistently.