TITLE: General coefficient of a Taylor series of $\frac{1}{e^{(e^{1-x})+\frac{x}{2}}+e^{\frac{x}{2}}}$
QUESTION [6 upvotes]: Is it possible to write a general Taylor coefficient of the function $$\frac{1}{e^{(e^{1-x})+\frac{x}{2}}+e^{\frac{x}{2}}}?$$
Wolfram alpha produces this nasty thing.

REPLY [6 votes]: Factoring the expression: $$\frac{1}{e^{\frac{x}{2}}} \cdot \frac{1}{e^{e^{1-x}}+1} = e^{-\frac{x}{2}} \cdot \frac{1}{1+e^{e^{1-x}}}$$
The series for the first term is given by $$e^{-\frac{x}{2}} = \sum_{n=0}^{\infty} \frac{\left(-\frac{1}{2}\right)^n}{n!}x^n \tag 1$$
Focusing on $\frac{1}{1+e^{e^{1-x}}}$ now, using the series for the Sigmoid function, this is $$\frac{1}{2}+\sum_{n=1}^{\infty}\frac{-\left(2^{2n}-1\right)B_{2n}}{\left(2n\right)!}e^{(1-x)(2n-1)}$$
where $B_n$ are the Bernoulli numbers.
Then using the expansion of $e^x$, this comes out to $$\frac{1}{2}+\sum_{n=1}^{\infty}\frac{-\left(2^{2n}-1\right)B_{2n}\ e^{\left(2n-1\right)}}{\left(2n\right)!}\sum_{m=0}^{\infty}\frac{\left(1-2n\right)^{m}}{m!}x^{m}$$
Switching the order of summation yields $$\frac{1}{2}+\sum_{m=0}^{\infty}x^{m}\sum_{n=1}^{\infty}\frac{-\left(2^{2n}-1\right)B_{2n}\ e^{\left(2n-1\right)}}{\left(2n\right)!}\frac{\left(1-2n\right)^{m}}{m!}$$
Expanding the $(1-2n)^m$ and simplifying yields $$\frac{1}{2}+\sum_{m=0}^{\infty}x^{m} 
\sum_{k=0}^m \frac{\binom{m}{k} (-2)^k}{m! \ e} \sum_{n=1}^{\infty}\frac{B_{2n}}{\left(2n\right)!} n^k (e^{2n} - e^{2n}2^{2n}) \tag 2$$
Let $f_k(x) = \sum_{n=1}^{\infty}\frac{B_{2n}\ }{\left(2n\right)!} n^k x^n$. Then $f_{k+1}(x) = xf_k'(x)$ with $f(x) = f_0(x) = -1 + \frac{\sqrt{x}}{2} \coth\left( \frac{\sqrt{x}}{2} \right)$
Then $$f_k(x) = \sum_{p=0}^k S(k, p) x^p f^{(p)}(x) \tag 3$$ where $S(k, p)$ are the Stirling numbers of the second kind. The innermost summation of $(2)$ can be expressed as $f_k\left(e^2\right) - f_k\left(4e^2\right)$
This then means that $$\frac{1}{1+e^{e^{1-x}}} = \frac{1}{2}+\sum_{m=0}^{\infty}x^{m} 
\sum_{k=0}^m \frac{\binom{m}{k} (-2)^k}{m! \ e} \left(f_k\left(e^2\right) - f_k\left(4e^2\right)\right) \tag 4$$
Multiplying $(1)$ and $(4)$ shows that $$\frac{1}{e^{(e^{1-x})+\frac{x}{2}}+e^{\frac{x}{2}}} = \sum_{n=0}^{\infty} x^n \left(\frac{\left(-\frac{1}{2}\right)^{n}}{2\ n!} + \sum_{m=0}^n \sum_{k=0}^m \frac{\binom{m}{k} (-2)^k}{m! \ e} \frac{\left(-\frac{1}{2}\right)^{n-m}}{(n-m)!} \left(f_k\left(e^2\right) - f_k\left(4e^2\right)\right) \right)$$
Plugging $(3)$ into this expands this to $$\sum_{n=0}^{\infty} x^n \left(\underbrace{\frac{\left(-\frac{1}{2}\right)^{n}}{2\ n!} + \sum_{m=0}^n \sum_{k=0}^m \sum_{p=0}^k \frac{\binom{m}{k} (-2)^k}{m!} \frac{\left(-\frac{1}{2}\right)^{n-m}}{(n-m)!}   S(k, p) e^{2p-1} \left(f^{(p)}(e^2) - 4^p f^{(p)}(4e^2)\right)}_{a_n} \right)$$
Switching the order of summation so that $m$ is the innermost sum simplifies $a_n$ to $$\frac{\left(-\frac{1}{2}\right)^{n}}{2\ n!} + \sum_{k=0}^n \sum_{p=0}^k (-2)^k S(k, p) e^{2p-1} \left(f^{(p)}(e^2) - 4^p f^{(p)}(4e^2)\right) \frac{2^{k-n}}{k!(n-k)!} \tag 5$$
Now focusing on $f^{(p)}(x)$, where $f(x) = -1 + \frac{\sqrt{x}}{2}\coth\left( \frac{\sqrt{x}}{2} \right)$: The $p$-th derivative (for $p \ge 1$) would be, using Faà di Bruno's formula: $$\sum_{j=1}^p \frac{d^j}{dt^j} (t\coth(t)) \Big|_{t=\sqrt{x}/2} B_{p, j}\left( \frac{(-1)^{1+1} (2\cdot 1-3)!!}{2^{1+1} x^{1-\frac{1}{2}}}, ..., \frac{(-1)^{p-j+1+1} (2 (p-j+1)-3)!!}{2^{p-j+1+1} x^{p-j+1-\frac{1}{2}}} \right) \tag 6$$
where $B_{p, j}$ denotes the Bell polynomials.
"Zooming" in to $\frac{d^j}{dt^j} (t \coth(t))$: This is equal to (using the general Leibniz rule) $$\sum_{i=0}^{j} \binom{j}{i} b_{j-i} (t) \frac{d^i}{dt^i} \text{csch}(t)$$
where $b_{n}(t)$ is $t\cosh(t) + n\sinh(t)$ if $n$ is even and $n\cosh(t) + t\sinh(t)$ if $n$ is odd.

 I originally had an extremely complicated (even worse than this!) formula for $\frac{d^i}{dt^i} \text{csch}(t)$ using Faà di Bruno's formula, but I decided to scrap that and just used Wolfram Alpha to find the derivative.

Using WolframAlpha, this simplifies to
$$\sum_{i=0}^{j} \binom{j}{i} b_{j-i} (t) \text{csch}(t) \sum_{h=0}^i \sum_{g=0}^h (-1)^g 2^{h-g} \binom{i}{h} (1 + \coth(t))^g g! S(h, g) \tag 7$$
If I plugged $(7)$ into $(6)$, and then plugged that into $(5)$, the result would be a very long expression, but would result in a "closed form" for $a_n$.
Edit: I managed to find (partially by guessing, but I was able to prove it) that the Bell polynomial in $(6)$ is $$\frac{(-1)^{p-j} (2(p-j)-1)!! \binom{2p-j-1}{j-1}}{2^{p+j} x^{p - \frac{j}{2}}}$$
This then simplifies $(6)$, which is $f^{(p)}(x)$, to $$\sum_{j=1}^p \frac{d^j}{dt^j} (t\coth(t)) \Big|_{t=\sqrt{x}/2} \frac{(-1)^{p-j} (2(p-j)-1)!! \binom{2p-j-1}{j-1}}{2^{p+j} x^{p - \frac{j}{2}}} \tag {6.1}$$
Also using the fact that $S(k, 0) = 0$ for $k \ge 1$ makes $(5)$ into $$\frac{(-1)^n - \tanh(e/2)}{2^{n+1}\ n!} + \sum_{k=1}^n \sum_{p=1}^k (-2)^k S(k, p) e^{2p-1} \left(f^{(p)}(e^2) - 4^p f^{(p)}(4e^2)\right) \frac{2^{k-n}}{k!(n-k)!} \tag {5.1}$$
Plugging $(6.1)$ into $(5.1)$ yields $$\frac{(-1)^n - \tanh(e/2)}{2^{n+1}\ n!} + \frac{1}{2^n n!}\sum_{k=1}^n \sum_{p=1}^k \sum_{j=1}^p (-1)^k 2^{2k} \binom{n}{k} S(k, p) e^{j-1}  \frac{(-1)^{p-j} (2(p-j)-1)!! \binom{2p-j-1}{j-1}}{2^p} \left(  \frac{1}{2^{j}}\frac{d^j}{dt^j} (t\coth(t)) \Big|_{t=e/2} - \frac{d^j}{dt^j} (t\coth(t)) \Big|_{t=e}\right) $$