For the past few days, I have been trying to work out, in generality the integral $$\int \frac{f(x)dx}{1+e^x}$$ Where $f(x)$ is a general polynomial function.

The case $f(x)=1$ is trivial, but for other $f(x)$, it isn't so. Let me take an example of $f(x)=x$, and show my approach,

$$\int \frac{x dx}{1+e^x}$$ Put $x=it$, (Where $i=\sqrt{-1}$) $$\implies \int \frac{x dx}{1+e^x}=-\int \frac{t dt}{1+e^{it}}$$ $$=-\int \frac{t dt}{2\cos{\frac{t}{2}}\cdot e^{it/2}}$$ $$=-\frac{1}{2}\int t\cdot \sec{\frac{t}{2}}\cdot e^{-it/2}dt$$ $$=-\frac{1}{2}\int tdt+\frac{i}{2}\int t\tan{\frac{t}{2}}dt$$ The first one is trivial, But the second one, that is something which has been giving me nightmares. Although I suspect that no closed form exists(?) But still could anyone help?

Also, putting $x=it$ in the original integral was the best approach that I could think of, could anyone give another way of doing this?

P.S : Please don't tell me it can't be done in terms of elementary functions :(

  • $\begingroup$ WolframAlpha seems to suggest $\int \frac{x}{1+e^x}\, dx$ can't be expressed in terms of elementary functions (it uses $\text{Li}_{2}\left(-e^x\right)$). wolframalpha.com/input/?i=int%20(x%2F(1%2Be%5Ex))%20dx $\endgroup$
    – user236182
    Mar 5, 2016 at 19:58
  • $\begingroup$ So there is no hope? $\endgroup$
    – Nikunj
    Mar 5, 2016 at 19:59
  • $\begingroup$ @Nikunj Probably. However such integrals over symmetric intervals easily reduce to $\displaystyle\int_0^c f(x)\,\mathrm{d}x$. $\endgroup$
    – Workaholic
    Mar 5, 2016 at 20:02
  • $\begingroup$ @Workaholic how, please give an example. $\endgroup$
    – Nikunj
    Mar 5, 2016 at 20:11
  • $\begingroup$ @Nikunj See here for instance. $\endgroup$
    – Workaholic
    Mar 5, 2016 at 20:12

1 Answer 1


I do not guarantee that this is valid since I won't be justifying the interchange of summation and integration.

You can use the expansion $\dfrac{1}{1+x}=\sum (-1)^nx^n$ to get

$$\frac{1}{1+e^x}=\frac{1}{1+e^x}\cdot \frac{e^{-x}}{e^{-x}}=\frac{e^{-x}}{1+e^{-x}}=e^{-x}\sum _{n=0}^{\infty}(-1)^ne^{-nx}=\sum _{n=1}^{\infty}(-1)^{n+1}e^{-nx}$$

This gives

$$I(x)=\int \frac{f(x)}{1+e^x}dx=\int f(x)\sum _{n=1}^{\infty}(-1)^{n+1}e^{-nx}dx=\sum _{n=1}^{\infty}(-1)^{n+1}\int f(x)e^{-nx}dx$$

If $f(x)$ is a polynomial, then $f(x)=a_kx^k+\cdots +a_0=\sum _ia_ix^i$ and the integral reduces to

$$I(x)=\sum _{n=1}^{\infty}\sum _{i=0}^ka_i(-1)^{n+1}\int x^ie^{-nx}dx$$

This would be a good initial point for calculating a definite integral over $[0,\infty )$ since

$$\int _0^{+\infty }x^ie^{-nx}dx=\frac{1}{n^{i+1}}\int _0^{+\infty }t^ie^{-t}dt=\frac{i!}{n^{i+1}},$$

and therefore

$$I=\sum _{n=1}^{\infty}\sum _{i=0}^ka_i(-1)^{n+1}\frac{i!}{n^{i+1}}=\sum _{i=0}^ka_ii!\sum _{n=1}^{\infty}\frac{(-1)^{n+1}}{n^{i+1}}=\sum _{i=0}^ki!a_i\eta (i+1),$$ where $\eta (i)$ is the alternating Riemann zeta function (sometimes called Dirichlet eta function). Using a simple relation $\eta (i)=(1-2^{1-i})\zeta (i)$ we have

$$I=\sum _{i=0}^ki!a_i(1-2^{-i})\zeta (i+1)$$

Reverting back to the indefinite case. For $f(x)=x$ we have $a_1=1$ and all other $a_i$'s zero and thus

$$I(x)=\sum _{n=1}^{\infty}(-1)^{n+1}\int xe^{-nx}dx=\sum _{n=1}^{\infty}(-1)^{n}\frac{e^{-nx} (1 + nx)}{n^2}$$

Comparing the Wolfram's solution to this one

$$ \begin{align} F_1(x) &=\frac{x^2}{2}-x \log(1+e^x)-\mathrm{Li} _2(-e^x) \\ F_2(x) &=\sum _{n=1}^{\infty}(-1)^{n}\frac{e^{-nx} (1 + nx)}{n^2} \end{align} $$

it can be numerically shown that $F_1(x)$ and $F_2(x)$ differ by a constant factor and therefore $F_2(x)$ is a valid solution for $x\geq 0$ (as $F_2(x)$ diverges otherwise). $F_2(x)$ cannot be elementary since the first term in the sum reduces to $\mathrm{Li}_2$

It remains to be seen if the said integral can be expressed in elementary functions, although I highly doubt it.

  • $\begingroup$ >$$I(x)=\int \frac{f(x)}{1+e^x}dx=\int f(x)\sum _{n=1}^{\infty}(-1)^{n+1}e^{-nx}dx=\sum _{n=1}^{\infty}(-1)^{n+1}\int f(x)e^{-nx}dx$$ Are you sure that we can do this(exchanging the integral and sigma)? $\endgroup$
    – Nikunj
    Mar 8, 2016 at 18:30
  • $\begingroup$ If you can justify this then the rest, i.e $$\int f(x)e^{-nx}$$ can probably be done by IBP for any $f(x)$ (probably) $\endgroup$
    – Nikunj
    Mar 8, 2016 at 18:32
  • $\begingroup$ Well I can try to use dominated convergence theorem for $f(x)=x^{\alpha }$. Since $|(-1)^{n+1}x^\alpha e^{-nx}|=|x^{\alpha }|e^{-nx}\leq |x^{\alpha }|e^{-x}=g(x)$. Since $\int g(x)dx <\infty $ the integral is uniformly convergent and we can swap the operations. However, this is only viable for $x>0$. Generally, all the theorems involve definite integrals, so I really do not know how to go about this in general. The less satisfying possibility is to numerically check the validity of each result. $\endgroup$
    – eyedropper
    Mar 8, 2016 at 18:51
  • $\begingroup$ I see, it's quite beyond the scope of my knowledge and I thank you for your efforts, let's see if someone else manages to do it, otherwise you can have the +50 $\endgroup$
    – Nikunj
    Mar 8, 2016 at 20:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .