Integral finding I want to find $$\int \left(1+\frac 1 x \right)\cdot e^{-\frac 1 x} \, dx,$$ with $x>0$. I am thinking to use that if a function $f(x)=e^{g(x)}\cdot g'(x)$ then has the integral $F(x)=e^{g(x)}+c$, but I don't know how exactly. Any ideas?
 A: Integrating by part:
$$\int e^{\frac {-1}{x}}dx=x e^{\frac {-1}{x}}-\int \frac {e^{\frac {-1}{x}}}{x}dx$$
Then :
$$\int e^{\frac {-1}{x}}dx+\int \frac {e^{\frac {-1}{x}}}{x}dx=x e^{\frac {-1}{x}}$$
$$\int e^{\frac {-1}{x}}(\frac {1}{x}+1)dx=x e^{\frac {-1}{x}}+K$$
Other way:
$$I_1=\int \left(1+\frac 1 x \right)\cdot e^{-\frac 1 x} \, dx=
\underbrace{\int e^{\frac {-1}{x}}dx}_\text{Integrate by part}+\int \frac {e^{\frac {-1}{x}}}{x}dx=x e^{\frac {-1}{x}}-\int \frac {e^{\frac {-1}{x}}}{x}dx+\int \frac {e^{\frac {-1}{x}}}{x}dx=xe^{\frac {-1}{x}}+K$$
A: If $f$ and $g$ are two differentiable functions, recognising that from the product rule 
$$\frac{d}{dx} \left (e^{f(x)} g(x) \right ) = e^{f(x)} [f'(x) g(x) + g'(x)],$$
one immediately has
$$\boxed{\int e^{f(x)} \big{(}f'(x) g(x) + g'(x) \big{)} \, dx = e^{f(x)} g(x) + C}$$
For the integral $\displaystyle{\int \left (1 + \frac{1}{x} \right ) e^{-\frac{1}{x}} \, dx}$ we see $f(x) = -1/x$. Thus $f'(x) = 1/x^2$. The function $g(x)$ can hopefully be found by inspection. We see that $g(x) = x$ giving $g'(x) = 1$. 
So for the functions $f(x) = -1/x$ and $g(x) = x$, on applying the result given in the box, one has
$$\int \left (1 + \frac{1}{x} \right ) e^{-\frac{1}{x}} \, dx = x e^{-\frac{1}{x}} + C.$$ 
A: compute the derivative of $$xe^{-1/x}+C$$
