Integrating $e^{f(x)}$ can someone tell me a way of integrating functions like $e^{f(x)}$
I have a specific case: $\int e^{-3x}\,\mathrm{d}x$
PS: I'm not looking for the answer of this, but the way of doing it.
Thanks for your help
 A: For the case where $f(x)$ is linear, a nice $u$-substitution works. I assume you know how to integrate $\int e^xdx$? So in order to integrate a function of the form $e^{f(x)}$, let $u=f(x)$, and thus $du=f'(x)dx$, which allows you to 'solve' for $dx$ in terms of $du$. Then your original integral goes from:
$$
\int e^{f(x)}dx
$$
to
$$
\int \frac{e^u}{f'(x)}du.
$$
Of course, this is not always so easy to integrate, as Moron points out. When $f(x)$ is linear, you have a nice situation, because $f'(x)$ is just a constant. Other situations may not be so easily handled, as far as I'm aware.
A: If you mean a way to obtain an anti-derivative in terms of elementary functions, there is no such general algorithm: it is known that for $f(x) = -x^2$, $\int e^{f(x)}$ cannot be written in terms of elementary functions.
There are some general algorithms for computing anti-derivatives though, for instance: Risch's algorithm.
Your specific case is much easier than what you have generalized your problem too.
Hint: What is the derivative of $e^{-3x}$ ?
A: Interesting, I fired my old symbolic algebra program and typed the following
$$ \int{\exp\left(C_{0}+C_{1}x-C_{2}x^{2}\right)}\,\mathrm{d}x= $$
and it gave the answer
$$ =\sqrt{\frac{\pi}{4C_{2}}}\exp\left(C_{0}+\frac{C_{1}^{2}}{4C_{2}}\right)\mathrm{erf}\left(\frac{C_{1}}{2\sqrt{C_{2}}}-\sqrt{C_{2}}\, x\right) $$
or more simply
$$ \int{\exp\left(-x^2\right)}\,\mathrm{d}x = \frac{\sqrt{\pi}}{2}\,\mathrm{erf}(x) $$
with $\mathrm{erf}(x)$ the error-function which is not an elementary function.
So although a general solution may not exist, I am sure there are special cases where as solution is feasible.
A: So I went down this rabbit hole, and assuming I didn't make a mistake somewhere, figured out a series that theoretically is $\int e^{f(x)}dx$, but it diverges anywhere that $-1 < f'(x) < 1$ and successive terms make that divergence worse, not better.
Start by taking the derivative of $e^{f(x)}$, then we can solve for $e^{f(x)}$ in terms of the derivative.
\begin{align}
\frac{d e^{f(x)}}{dx} = e^{f(x)}f'(x) \\
e^{f(x)} = \frac{\frac{d e^{f(x)}}{dx}}{f'(x)}
\end{align}
Integrate by parts to get the first term.
\begin{align}
\int e^{f(x)} dx = \int \frac{\frac{d e^{f(x)}}{dx}}{f'(x)} dx = uv - \int v du \\
u = \frac{1}{f'(x)}, dv = \frac{d e^{f(x)}}{dx} dx \\
du = \frac{-f''(x)}{f'(x)^2} dx, v = \int \frac{d e^{f(x)}}{dx} dx = e^{f(x)} \\
uv - \int v du \\
= \frac{e^{f(x)}}{f'(x)} + \int e^{f(x)} \frac{f''(x)}{f'(x)^2} dx
\end{align}
Repeat the process, plug in our expression for $e^{f(x)}$
\begin{align}
\int e^{f(x)}\frac{f''(x)}{f'(x)^2} dx \\
= \int \frac{\frac{d e^{f(x)}}{dx}}{f'(x)}\frac{f''(x)}{f'(x)^2} dx \\
= \int \frac{d e^{f(x)}}{dx}\frac{f''(x)}{f'(x)^3} dx
\end{align}
Integrate by parts to get the second term.
\begin{align}
\int \frac{d e^{f(x)}}{dx}\frac{f''(x)}{f'(x)^3} dx = uv - \int v du \\
u = \frac{f''(x)}{f'(x)^3}, dv = \frac{d e^{f(x)}}{dx} dx \\
du = \frac{f^{(3)}(x)f'(x) - 3f''(x)^2}{f'(x)^4} dx, v = e^{f(x)} \\
uv - \int v du \\
= \frac{e^{f(x)} f''(x)}{f'(x)^3} + \int e^{f(x)}\frac{3f''(x)^2 - f^{(3)}(x)f'(x)}{f'(x)^4} dx
\end{align}
Continue repeating, noticing a recurrence relation. Let $g(x) = \frac{1}{f'(x)}$ and $e^{f(x)}T_k(x)$ be the $k$th term of $\int e^{f(x)} dx$.
\begin{align}
T_k(x) = -T_{k-1}'(x)g(x) \\
T_0(x) = g(x)
\end{align}
Starting with the General Leibniz Rule:
\begin{align}
\frac{d^n f(x)g(x)}{dx^n} = \sum_{i=0}^n \binom{n}{i}f^{(i)}(x)g^{(n-i)}(x) \\
\end{align}
Deriving a non-recurrent definition for $T_k$
\begin{align}
T_k(x) = -T_{k-1}'(x)g(x) \\
T_k^{(i_0+1)}(x) = -\sum_{i=0}^{i_0+1} \binom{i_0+1}{i}T_{k-1}^{(i+1)}(x)g^{(i_0-i+1)}(x) \\
= (-1)^k \sum_{i_1=0}^{i_0+1} ... \sum_{i_k=0}^{i_{k-1}+1} g^{(i_k+1)}(x) \prod_{m=1}^k \binom{i_{m-1}+1}{i_m}g^{(i_{m-1}-i_m+1)}(x)
\end{align}
Therefore:
\begin{align}
\int e^{f(x)} dx = e^{f(x)} \sum_{k=0}^\infty T_k(x) = e^{f(x)}(g(x) + \sum_{k=0}^\infty -T_k'(x)g(x)) \\
= e^{f(x)}(g(x) + \sum_{k=0}^\infty -g(x)(-1)^k \sum_{i_1=0}^{i_0+1} ... \sum_{i_k=0}^{i_{k-1}+1} g^{(i_k+1)}(x) \prod_{m=1}^k \binom{i_{m-1}+1}{i_m}g^{(i_{m-1}-i_m+1)}(x)) \\
= e^{f(x)}g(x)\left(1 - \sum_{k=0}^\infty (-1)^k \sum_{i_1=0}^{1} ... \sum_{i_k=0}^{i_{k-1}+1} g^{(i_k+1)}(x) \prod_{m=1}^k \binom{i_{m-1}+1}{i_m}g^{(i_{m-1}-i_m+1)}(x)\right)
\end{align}
I have some sense that this can be written in terms of Bell polynomials since the complete exponential Bell polynomial $B_n(g'(x), g''(x)g(x), ..., g^{(n)}(x)g(x)^{n-1})$ gives the correct terms for $T_n$, but the wrong coefficients.
To actually evaluate this, you'll need to be able to evaluate $g^{(n)}(x)=\frac{d^n \frac{1}{f'(x)}}{dx^n}$, which by itself is not easy, but oddly enough has a very similar structure.
Given a function $f(x)$ and a constant $i_0=n$, the nth derivative of $1/f(x)$ is:
\begin{align}
\frac{d^n \frac{1}{f(x)}}{dx^n} = \left(\sum_{k=2}^n \frac{n!}{f(x)^{k+1}}(-1)^k\left(\sum_{i_1=1}^{i_0-1}...\sum_{i_{k-1}=1}^{i_{k-2}-1} \frac{f^{(i_{k-1})}(x)}{i_{k-1}!} \prod_{m=1}^{k-1} \frac{f^{(i_{m-1}-i_m)}(x)}{(i_{m-1}-i_m)!} \right)\right) - \frac{f^{(n)}(x)}{f(x)^2}
\end{align}
