TITLE: Solving the recurrence relation $A_n=n!+\sum_{i=1}^n{n\choose i}A_{n-i}$
QUESTION [10 upvotes]: I am attempting to solve the recurrence relation $A_n=n!+\sum_{i=1}^n{n\choose i}A_{n-i}$ with the initial condition $A_0=1$. By "solving" I mean finding an efficient way of computing $A_n$ for general $n$ in complexity better than $O(n^2)$.
I tried using the identity $\dbinom{n+1}i=\dbinom{n}{i-1}+\dbinom{n}i$ but I still ended up with a sum over all previous $n$'s.
Another approach was to notice that $2A_n=n!+\sum_{i=0}^{n}{n \choose i}A_{n-i}$ and so if $a(x)$ is the EFG for $A_n$, then we get the relation $$2a(x)=\frac{1}{1-x}+a(x)e^x,$$ so $$a(x)=\frac{1}{(1-x)(2-e^x)}$$ (am I correct here?) but I can't see to to use this EGF for the more efficient computation of $A_n$.

REPLY [4 votes]: You can certainly at least estimate $\frac{A_n}{n!}$ quite accurately and efficiently using the EGF by summing the contributions to the coefficients over enough of the poles of the generating function $a(z) = \frac{1}{(1 - z)(2 - e^z)}$. There are poles at $z = 1, \log 2 + 2 \pi i k, k \in \mathbb{Z}$; compute the residues at these poles and you get an expression for $\frac{A_n}{n!}$ as a sum of terms of the form $c_{\lambda} \lambda^n$ where $\lambda$ runs over the reciprocals of the poles. The $\lambda$ decrease rapidly. For more details see for example Flajolet and Sedgewick's Analytic Combinatorics.
I'm mildly curious what you need an exact value of $A_n$ for. If you know how to compute $n!$ efficiently (and I don't) you can use enough terms in the above sum that your error is better than $\frac{1}{n!}$, which shouldn't take too long.