# How to find the MacLaurin series of $\frac{1}{1+e^x}$

Mathcad software gives me the answer as: $$\frac{1}{1+e^x} = \frac{1}{2} -\frac{x}{4} +\frac{x^3}{48} -\frac{x^5}{480} +\cdots$$ I have no idea how it found that and i don't understand. What i did is expand $(1+e^x)^{-1}$ as in the binomial MacLaurin expansion. I want until the $x^4$ term. So what i found is the following:

$$(1+e^x)^{-1} = 1 - e^x + e^{2x} + e^{3x} + e^{4x}+\cdots\tag1$$ Then by expanding each $e^{nx}$ term individually: $$e^x = 1 + x + \frac{x^2}{2} + \frac{x^3}{6} + \frac{x^4}{24}+\cdots\tag2$$ $$e^{2x} = 1 + 2x + 2x^2 + \frac{3x^3}{2} + \frac{2x^4}{3}+\cdots\tag3$$ $$e^{3x} = 1 + 3x + \frac{9x^2}{2} + \frac{9x^3}{2} + \frac{27x^4}{8}+\cdots\tag4$$ $$e^{4x} = 1 + 4x + 8x^2 + \frac{32x^3}{3} + \frac{32x^4}{3}+\cdots\tag5$$ So substituting $(2),(3),(4),(5)$ into $(1)$ i get: $$(1+e^x)^{-1} = 1 +2x+5x^2+ \frac{22x^3}{3} + \frac{95x^4}{12} +\cdots$$ Which isn't the correct result. Am i not allowed to expand this series binomially? I've seen on this site that this is an asymptotic expansion. However, i don't know about these and i haven't been able to find much information on this matter to solve this. If someone could help me understand how to solve it and why my approach isn't correct, i would be VERY grateful. Thanks in advance.

• We have $(1+e^x)^{-1}=1-e^x+e^{2x}-\cdots$ only if $x<0$. If $x>0$, you need to factor $e^x$ out of the denominator. – Clayton Aug 21 '15 at 12:55
• You forgot the series for $(1+u)^{-1}$ converges if and only if $\lvert u\rvert <1$, which is not the case of $\mathrm e^x$. – Bernard Aug 21 '15 at 13:05
• Bernard is correct, @RestlessC0bra: If $e^x<1$, we have $x<0$. We need it for the geometric series to converge. Otherwise, you can do what I (and mwomath) suggested, which is to factor $e^x$ out of the denominator. – Clayton Aug 21 '15 at 13:06
• Expanding $1/(1+a)$, you get $1-a+a^2-a^3+a^4-\cdots$, with alternating signs, not $1-a+a^2+a^4+ \cdots$, with the same sign in each term after the $1$st-degree term. It's not clear why you stopped after $(5)$. ${}\qquad{}$ – Michael Hardy Aug 21 '15 at 13:07
• @RestlessC0bra : If $x$ is real, the $e^x>0$. But one needs $e^x<1$, which means $x<0$. ${}\qquad{}$ – Michael Hardy Aug 21 '15 at 13:08

Since you're just looking for the first few terms: $$f(x)=\frac{1}{1+e^x} \implies f(0)=\frac 12$$ $$f'(x)=\frac{-e^x}{(1+e^x)^2} \implies f'(0)=-\frac 14$$ $$f''(x)=\frac{-e^x}{(1+e^x)^2}+2\frac{e^{2x}}{(1+e^x)^3}\implies f''(0)=0$$ $$f'''(x)=f''(x)+4\frac{e^{2x}}{(1+e^x)^3}-3\times 2\frac{e^x}{(1+e^x)^4}\implies f'''(0)=\frac 18$$

You get: $$\frac{1}{1+e^x}=\frac 1{2\times 0!} -\frac 1{4\times 1!} x+\frac 1{8\times 3!}x^3+\mathcal O (x^5)$$ $$\frac{1}{1+e^x}=\frac 1{2} -\frac 1{4} x+\frac 1{48}x^3+ \mathcal O (x^5)$$

• @RestlessC0bra Since this is a truncated Taylor series we need this "Big-O" notation to describe how closely the series approximates the given function. – GeorgSaliba Aug 21 '15 at 15:15
• I mark this as the accepted answer because it was the most simple for me. But i'll study all the other answers as well. Thank you all. – Nikos Aug 21 '15 at 20:23
• @RestlessC0bra - how come your username is spelt with a lower case "o" but when typing it with an "@" it appears with a zero or "0"? maybe now you can also consider using $\Theta$ instead... :) – Hypergeometricx Aug 21 '15 at 21:12
• @GeorgSaliba - what's the difference between $O(.)$ and $\Theta (.)$ here? – Hypergeometricx Aug 21 '15 at 21:13
• @hypergeometric Sorry, it should be $\mathcal O (.)$ because it's an upper bound not a tight bound (where $\Theta (.)$ would've been correct). – GeorgSaliba Aug 21 '15 at 21:21

Let $\dfrac1{1+e^x}=a_0+a_1x+a_2x^2+\cdots$

$$\implies(1+e^x)\left(a_0+a_1x+a_2x^2+\cdots\right)=1$$

As $e^x=\sum_{r=0}^\infty\dfrac{x^r}{r!}$

$$\implies\left(2+\dfrac x1+\dfrac{x^2}2+\dfrac{x^3}{3!}+\cdots\right)\left(a_0+a_1x+a_2x^2+\cdots\right)=1$$

Comparing the coefficients of different powers of $x,$

$\implies1=2a_0\iff a_0=?$

$0=2a_1+a_0\iff a_1=?$

$0=2a_2+a_1+\dfrac{a_0}2$

and so on

• This is a nice, simple approach. – user84413 Aug 21 '15 at 17:33
• And what is the radius of convergence? – BeesaFangirl DOTO Dec 27 '19 at 21:59
• @BeesaFangirlDOTO, The Series should converge when the series of $e^x$ converges. – lab bhattacharjee Dec 28 '19 at 10:46

Just a sketch of a proof to be expanded later (sorry, I am in a hurry): by taking the logarithmic derivative of the Weierstrass product of the $\cosh$ function we have the Taylor series of the $\tanh$ function, with the coefficients depending on values of the $\zeta$ function at even integers. With a little maquillage it is not difficult to turn that into the Taylor series of $\frac{1}{1+e^x}$. Or we may just play a bit with the generating function of Bernoulli numbers.

So, I was saying: $$\cosh z = \prod_{n\geq 0}\left(1+\frac{4z^2}{(2n+1)^2 \pi^2}\right)\tag{1}$$ hence: $$\tanh z = \sum_{n\geq 0}\frac{8z}{(2n+1)^2 \pi^2 + 4z^2}\tag{2}$$ leads to: $$\tanh z = \sum_{m\geq 0}(-1)^m z^{2m+1}\sum_{n\geq 0}\frac{2^{2m+3}}{\pi^{2m+2}(2n+1)^{2m+2}}\tag{3}$$ by expanding the general term of the RHS of $(2)$ as a geometric series. Computing the innermost sum in terms of the $\zeta$ function it follows that: $$\tanh z = \sum_{m\geq 0}\frac{2(-1)^m\left(2^{2m+2}-1\right) }{\pi^{2m+2}}\zeta(2m+2)\, z^{2m+1}\tag{4}$$ but since $\frac{1}{1+e^{z}}=\frac{1-\tanh(z/2)}{2}$ it follows that: $$\frac{1}{1+e^{z}}=\frac{1}{2}-\sum_{m\geq 0}\frac{(-1)^m\left(2^{2m+2}-1\right) }{2^{2m+1}\pi^{2m+2}}\zeta(2m+2)\, z^{2m+1}\tag{5}$$ so to solve the original problem it is enough to recall that $\zeta(2)=\frac{\pi^2}{6}$ and $\zeta(4)=\frac{\pi^4}{90}$.

Moreover, through $(5)$ it is straightforward to compute the magnitude of the coefficients by simply approximating $\zeta(2m+2)$ with $1$. On the other hand, that is trivial also by considering that the radius of convergence of the Taylor series of $f(z)=\frac{1}{1+e^z}$ at $z=0$ is $\pi$, since $f(z)$ is a meromorphic function with two simple poles at $z=\pm \pi i$.

• I haven't delved that deep into mathematics yet, but i'd certainly want to see the proof. – Nikos Aug 21 '15 at 13:39
• @RestlessC0bra: please just wait a little, I'll type it later. – Jack D'Aurizio Aug 21 '15 at 13:40
• @RestlessC0bra: done ;) – Jack D'Aurizio Aug 21 '15 at 15:46

Here's another way to derive it term by term: $$y^{-1}=1+e^x\Rightarrow -y^{-2}y'=e^x=y^{-1}-1\Rightarrow y'=y^2-y$$

Now you can continue to differentiate with the minimum of fuss:

$$y''=2yy'-y'$$ $$y'''=2yy''+2y'y'-y''$$ $$y^{(4)}=2yy'''+6y''y'-y'''$$

And so on, evaluating at each step.

$\begin{array}\\ f(x) &=\frac{1}{1+e^x}\\ &=\frac{1}{2+(e^x-1)}\\ &=\frac12\frac{1}{1+(e^x-1)/2}\\ &=\frac12\sum_{n=0}^{\infty}(-1)^n\frac{(e^x-1)^n}{2^n}\\ &=\frac12\sum_{n=0}^{\infty}(-1)^n\frac{(x+x^2/2+x^3/6+...)^n}{2^n}\\ &=\frac12\sum_{n=0}^{\infty}(-1)^n(x/2)^n(1+x/2+x^2/6+...)^n\\ &=\frac12\sum_{n=0}^{\infty}(-1)^n(x/2)^n(1+nx/2+...)\\ &=\frac12\left(1-\frac{x}{2}(1+\frac{x}{2}+...)+\frac{x^2}{4}(1+...)+...\right)\\ &=\frac12\left(1-\frac{x}{2}-\frac{x^2}{4} +\frac{x^2}{4}(1+...)+...\right)\\ &=\frac12\left(1-\frac{x}{2}+O(x^3)\right)\\ &=\frac12-\frac{x}{4}+O(x^3)\\ \end{array}$