Finite integral with removable singularity I wanted to integrate $\frac{(exp(-x) -1)^2}{x}$ from $x=0$ to $x=a$ where $a$ is finite. Since the integrand, viz., $\frac{(exp(-x) -1)^2}{x}$ has a removable singularity at $x=0$ , I can take the lower limit to be zero for the integration. Further, if I use finite integration upper limit, I cannot use Jordan's Lemma. What approach do I use? Is there any other method? Or is there a way out using contour integration??
Thank You!
 A: Probably the best way is to regularise the integral by adding an $x^s$, calculate it in terms of incomplete Gamma functions, then let $s \to 0$. We have
$$ \int_0^a x^{s-1}(e^{-x}-1)^2 \, dx = \int_0^a x^{s-1}(e^{-2x}-2e^{-x}+1) \, dx = \frac{a^s}{s} - 2\gamma(s,a) + 2^{-s}\gamma(s,2a), $$
in terms of the lower incomplete gamma function. In terms of the upper incomplete gamma function, this is
$$ \frac{a^s}{s} + (2^{-s}-2)\Gamma(s) + 2\Gamma(s,a) - 2^{-s} \Gamma(s,2a). $$
The last two terms are analytic in $s$, so we can happily take $s=0$ in them. For the former, we have
$$ \frac{a^s}{s} = \frac{1}{s} + \log{a} + O(s), $$
using the usual series expansion for a power, and
$$ (2^{-s}-2)\Gamma(s) = \left(-1-s\log{2}+O(s^2)\right) \left( \frac{1}{s} -\gamma + O(s) \right) = -\frac{1}{s} + \gamma - \log{2} + O(s), $$
using the Laurent series of $\Gamma$ at $0$.
Adding these, the divergent $s^{-1}$s cancel as they should, and we get
$$ \int_0^a x^{-1}(e^{-x}-1)^2 \, dx = \log{a}-\log{2}+\gamma + 2\Gamma(0,a) - \Gamma(0,2a). $$
(The latter two terms can also be written using exponential integrals if so desired.)

Edited to add:
Recall a possible definition of $a^s$ is $a^s = e^{s\log{a}}$. Since we know how to expand the exponential function as a power series, we obtain the expansion
$$ a^s = e^{s\log{a}} = \sum_{k=0}^{\infty} \frac{(\log{a})^k}{k!} s^k. $$
(alternatively, consider the definition of $e^x$ as the limit of $(1+x/n)^n$: rearranging this allows us to write
$$ \log{y} = \lim_{n \to \infty} n(y^{1/n}-1) = \lim_{s \to 0} \frac{y^s-1}{s}, $$
which we recognise as the derivative quotient of $y^s$ at $s=0$.)
$\gamma$ is the Euler-Mascheroni constant, which is basically defined as $-\Gamma'(1)$: for our purposes, it comes from the integral
$$ \int_0^{\infty} e^{-t}\log{t} \, dt = -\gamma, $$
in which you can recognise the derivative of $x^{s-1} e^{-x} $ with respect to $s$ at $s=1$.
