I saw the following integral $$\int^\infty_0 \mathrm{d}x \left(\frac{1-e^{-x}}{x}\right)^2$$ on Michael Penn's video, and tried to solve it myself. My solution is as follows:
Let $I$ denote the integral, integrating by parts we have $$ I = \int^\infty_0 \mathrm{d}x \left(\frac{1-e^{-x}}{x}\right)^2 = \left.x\left(\frac{1-e^{-x}}{x}\right)^2\right|^\infty_0 + 2\int^\infty_0 \mathrm{d}x \left[ \left(\frac{1-e^{-x}}{x}\right)^2 - \left(\frac{1-e^{-x}}{x}\right)e^{-x}\right] , $$
$$ I = 2I - 2\int^\infty_0 \mathrm{d}x \left(\frac{1-e^{-x}}{x}\right)e^{-x} , $$ So $$ I = 2 \left(\int^\infty_0 \mathrm{d}x \frac{e^{-x}}{x} - \int^\infty_0 \mathrm{d}x \frac{e^{-2x}}{x} \right). $$
The following integrals are improper integrals related to the exponential integral. In evaluating them I use Feynman's trick: Let $\bar{I}(\alpha) = \int^\infty_0 \mathrm{d}x \frac{e^{-\alpha x}}{x} $ Then $$ \frac{\mathrm{d}\bar{I}}{\mathrm{d}\alpha} = - \int^\infty_0 \mathrm{d}x \text{ } e^{-\alpha x} = -\frac{1}{\alpha} , $$ $$ \bar{I}(\alpha) = -\ln(\alpha) + \bar{C} . $$
Since $\bar{C}$ is constant for different values of $\alpha$, it cancels out nicely in the difference, and $$ I = 2\left(\bar{I}(1)-\bar{I}(2)\right) = 2\ln 2. $$
My first question is why the difference calculated this way yields the right answer, since the two integrals seem to be identical with a change of variable: $$ \int^\infty_0 \mathrm{d}x\text{ }\frac{e^{-2x}}{x} = \int^\infty_0 \mathrm{d}(2x)\text{ }\frac{e^{-2x}}{2x} = \int^\infty_0 \mathrm{d}x\text{ }\frac{e^{-x}}{x} .$$
My second question is ifi there's some way to calculate the value of $\bar{C}$ in the above equation. Normally I think this would be done by substituting suitable values for $\alpha$, but it doesn't seem like there's any value that would make the integral doable.