Evaluating $\int_{x=0}^a e^{-x}e^{-1/x}\,\mathrm dx$ Can anyone give me an idea of how one would evaluate:
$$\intop_{x=0}^a e^{-x}e^{-1/x}\,\mathrm dx.$$
 A: This does not have a closed form, as far as I know.  The antiderivative is not elementary.
A: Because the integrand function 
$$
f(x) = e^{-x-\frac{1}{x}}
$$
is smooth on $[0,a]$, for any finite $a$, Gaussian quadrature will work nicely.
If you wanna use Chebyshev or Legendre weight, you have to transform the integral to an integral fro $-1$ to $1$: let 
$$x = \frac{a}{2}z + \frac{a}{2},$$
then $z\in [-1,1]$, and the integral becomes:
$$
I = \frac{a}{2}\int^{1}_{-1} e^{-\left(\frac{az+a}{2} + \frac{2}{az+a}\right)}\,dz.
$$
Then the standard Gaussian quadrature using the Legendre weight would work pretty well.
If $a = +\infty$, then you wanna check with generalized Gauss–Laguerre quadrature.

Here I will present another method I like in light of Richard Feynman. For the integral has a parameter $a$, we can view as a function of $a$:
$$
I(a) = \int^a_0 e^{-x-\frac{1}{x}} \,dx,
$$
then evaluate this integral is like numerically solving the following initial value problem:

Evaluate $I(a)$ when $I(y)$ satisfies
  $$
\begin{cases}
\frac{dI}{dy} = e^{-y-\frac{1}{y}},
\\[3pt]
I(0) = 0.
\end{cases}
$$

When $a=1$, enter these into MATLAB:
[t y] = ode45(@(t,y)exp(-t-1./t),[0,1],0);

The last entry in the y array is the approximation to $I(1)$, which is $\approx 0.072198311$. Comparing with achille hui's comment, this method has $O(10^{-6})$ accuracy by the default $h = 0.025$ time step.
A: Note that the integral only converges when $a\neq0$ .
Although $\int e^{-x-\frac{1}{x}}~dx$ itself cannot be expressed as known special function, we can still express it as series form.
$\int e^{-x-\frac{1}{x}}~dx$
$=\int\sum\limits_{n=0}^\infty\dfrac{\left(x+\dfrac{1}{x}\right)^{2n}}{(2n)!}dx-\int\sum\limits_{n=0}^\infty\dfrac{\left(x+\dfrac{1}{x}\right)^{2n+1}}{(2n+1)!}dx$
$=\int\sum\limits_{n=0}^\infty\sum\limits_{k=0}^{2n}\dfrac{C_k^{2n}x^{2k-2n}}{(2n)!}dx-\int\sum\limits_{n=0}^\infty\sum\limits_{k=0}^n\dfrac{C_k^{2n+1}x^{2k-2n-1}}{(2n+1)!}dx-\int\sum\limits_{n=0}^\infty\sum\limits_{k=0}^n\dfrac{C_k^{2n+1}x^{2n-2k+1}}{(2n+1)!}dx$
$=\int\sum\limits_{n=0}^\infty\sum\limits_{k=0}^{2n}\dfrac{x^{2k-2n}}{k!(2n-k)!}dx-\int\sum\limits_{n=0}^\infty\sum\limits_{k=0}^{n-1}\dfrac{x^{2k-2n-1}}{k!(2n-k+1)!}dx-\int\sum\limits_{n=0}^\infty\sum\limits_{k=0}^n\dfrac{x^{2n-2k+1}}{k!(2n-k+1)!}dx-\int\sum\limits_{n=0}^\infty\dfrac{1}{n!(n+1)!x}dx$
$=\sum\limits_{n=0}^\infty\sum\limits_{k=0}^{2n}\dfrac{x^{2k-2n+1}}{k!(2n-k)!(2k-2n+1)}-\sum\limits_{n=0}^\infty\sum\limits_{k=0}^{n-1}\dfrac{x^{2k-2n}}{k!(2n-k+1)!(2k-2n)}-\sum\limits_{n=0}^\infty\sum\limits_{k=0}^n\dfrac{x^{2n-2k+2}}{k!(2n-k+1)!(2n-2k+2)}-\sum\limits_{n=0}^\infty\dfrac{\ln x}{n!(n+1)!}+C$
However, the above result cannot substitute $0$ , but since $\int_0^1e^{-x-\frac{1}{x}}~dx=K_1(2)-\dfrac{1}{2e^2}$ provided by @achille hui, so we can still express the result as
$\int_0^ae^{-x-\frac{1}{x}}~dx$
$=\int_0^1e^{-x-\frac{1}{x}}~dx+\int_1^a e^{-x-\frac{1}{x}}~dx$
$=K_1(2)-\dfrac{1}{2e^2}+\left[\sum\limits_{n=0}^\infty\sum\limits_{k=0}^{2n}\dfrac{x^{2k-2n+1}}{k!(2n-k)!(2k-2n+1)}-\sum\limits_{n=0}^\infty\sum\limits_{k=0}^{n-1}\dfrac{x^{2k-2n}}{k!(2n-k+1)!(2k-2n)}-\sum\limits_{n=0}^\infty\sum\limits_{k=0}^n\dfrac{x^{2n-2k+2}}{k!(2n-k+1)!(2n-2k+2)}-\sum\limits_{n=0}^\infty\dfrac{\ln x}{n!(n+1)!}\right]_1^a$
$=K_1(2)-\dfrac{1}{2e^2}+\sum\limits_{n=0}^\infty\sum\limits_{k=0}^{2n}\dfrac{a^{2k-2n+1}-1}{k!(2n-k)!(2k-2n+1)}-\sum\limits_{n=0}^\infty\sum\limits_{k=0}^{n-1}\dfrac{a^{2k-2n}-1}{k!(2n-k+1)!(2k-2n)}-\sum\limits_{n=0}^\infty\sum\limits_{k=0}^n\dfrac{a^{2n-2k+2}-1}{k!(2n-k+1)!(2n-2k+2)}-\sum\limits_{n=0}^\infty\dfrac{\ln a}{n!(n+1)!}$
A: @Harry yes, here is an alternative infinite series solution for a more general form of the integral. Similarly, it only converges for $k_0 \neq 0$. Various substitutions have been applied throughout.
\begin{eqnarray}
\intop_{x=0}^{k_{0}}e^{-\frac{k_{1}}{x}}e^{-k_{2}x}dx & = & \intop_{x=0}^{\infty}e^{-\frac{k_{1}\left(x+1\right)}{k_{0}}}e^{-\frac{ak_{2}}{x+1}}\left(\frac{\sqrt{k_{0}}}{x+1}\right)^{2}dx\nonumber \\
 & = & \intop_{x=0}^{\infty}e^{-\frac{k_{1}x}{k_{0}}}e^{-\frac{k_{0}k_{2}}{x}}\left(\frac{\sqrt{k_{0}}}{x}\right)^{2}dx-\intop_{x=0}^{1}e^{-\frac{k_{1}x}{k_{0}}}e^{-\frac{k_{0}k_{2}}{x}}\left(\frac{\sqrt{k_{0}}}{x}\right)^{2}dx\nonumber \\
 & = & 2\sqrt{\frac{k_{1}}{k_{2}}}K_{1}\left(2\sqrt{k_{1}k_{2}}\right)-k_{0}\intop_{x=0}^{1}\sum_{n=0}^{\infty}\frac{\left(-\frac{k_{1}x}{k_{0}}\right)^{n}}{n!}e^{-\frac{k_{0}k_{2}}{x}}\left(\frac{1}{x}\right)^{2}dx\nonumber \\
 & = & 2\sqrt{\frac{k_{1}}{k_{2}}}K_{1}\left(2\sqrt{k_{1}k_{2}}\right)-k_{0}\sum_{n=0}^{\infty}\frac{\left(-\frac{k_{1}x}{k_{0}}\right)^{n}}{n!}\intop_{x=0}^{1}e^{-\frac{k_{0}k_{2}}{x}}\left(\frac{1}{x}\right)^{2}dx\nonumber \\
 & = & 2\sqrt{\frac{k_{1}}{k_{2}}}K_{1}\left(2\sqrt{k_{1}k_{2}}\right)-k_{0}\sum_{n=0}^{\infty}\frac{\left(-\frac{k_{1}}{k_{0}}\right)^{n}}{n!}\intop_{x=0}^{1}e^{-\frac{k_{0}k_{2}}{x}}x^{n-2}dx\nonumber \\
 & = & 2\sqrt{\frac{k_{1}}{k_{2}}}K_{1}\left(2\sqrt{k_{1}k_{2}}\right)-k_{0}\sum_{n=0}^{\infty}\frac{\left(-\frac{k_{1}}{k_{0}}\right)^{n}}{n!}\intop_{x=1}^{\infty}\frac{e^{-k_{0}k_{2}x}}{x^{n}}dx\nonumber \\
 & = & 2\sqrt{\frac{k_{1}}{k_{2}}}K_{1}\left(2\sqrt{k_{1}k_{2}}\right)-k_{0}\sum_{n=0}^{\infty}\frac{\left(-\frac{k_{1}}{k_{0}}\right)^{n}}{n!}E_{n}\left(k_{0}k_{2}\right).\label{eq:Approximation},
\end{eqnarray} 
where $E_n(x)$ is the exponential integral.
