How to prove $\sum_{n=0}^\infty(-1)^ne^{-xa^n}\ne \sum_{n=0}^\infty\frac{(-x)^n}{n!(1+a^n)}$? Assume that for $x>0$ and $a>1$,$$f(x)=\sum_{n=0}^\infty(-1)^ne^{-xa^n},\quad g(x)=\sum_{n=0}^\infty\frac{(-x)^n}{n!(1+a^n)}$$
Regardless of validity, I use Taylor expansion for $e^{-xa^n}$ with respect to $x$, and then exchange the order of both series to get $g(x)$.
However, $f(x)\ne g(x)$. For example, when $a=2$, 
$$f(1)-g(1)=0.0001579\cdots.$$
So why does this kind of circumstance appear ? In other words, why does $f(x)\ne g(x)$ ?
 A: Of course, the "regardless of validity" approach is incorrect; $\sum_{n=0}^{\infty}(-1)^n a^{nk}$ doesn't sum to $(1+a^k)^{-1}$ (and in fact diverges) for $a>1$. The interesting question is "why is $f(x)$ still close to $g(x)$?".
An answer may be obtained using Cahen-Mellin integral. For any $c>0$, $$f(x)=\frac{1}{2\pi\mathrm{i}}\sum_{n=0}^{\infty}(-1)^n\int_{c-\mathrm{i}\infty}^{c+\mathrm{i}\infty}\Gamma(s)(xa^n)^{-s}\,ds=\frac{1}{2\pi\mathrm{i}}\int_{c-\mathrm{i}\infty}^{c+\mathrm{i}\infty}\frac{\Gamma(s)x^{-s}}{1+a^{-s}}\,ds$$ (this time the convergence takes place), and thus $f(x)$ is equal to the (infinite) sum of residues of the integrand at its poles (which is shown the usual way, by considering the integral along the boundary of $[-N-1/2,c]+2\pi\mathrm{i}[-N,N]/\log a$ and taking $N\to\infty$).
The residue at $s=-n$ (for $n$ a nonnegative integer) is exactly $(-x)^n/(n!(1+a^n))$, but there are also poles at $s=s_n:=(2n+1)\pi\mathrm{i}/\log a$, where $n$ is an integer, and the principal value of $\log a$ is taken: $$f(x)=g(x)+\frac{1}{\log a}\sum_{n=-\infty}^\infty\Gamma(s_n)x^{-s_n}$$ (where again the principal value of $x^{-s_n}=\exp(-s_n\log x)$ is taken). We have $|x^{-s_n}|=1$ for each $n$, but $|\Gamma(s_n)|$ decay rapidly. For $a=2$ and $x=1$, the "remainder" is $(2/\log 2)\sum_{n=0}^{\infty}\Re\Gamma(s_n)$, and $$\Re\Gamma(s_0)\approx 5.4732\cdot 10^{-5},\quad\Re\Gamma(s_1)\approx-2.258\cdot 10^{-10},\quad\Re\Gamma(s_2)\approx-1.808\cdot 10^{-16},\quad\ldots$$
